]> granicus.if.org Git - clang/commitdiff
[Blocks] Inherit sanitizer options from parent decl
authorVedant Kumar <vsk@apple.com>
Fri, 8 Dec 2017 02:47:58 +0000 (02:47 +0000)
committerVedant Kumar <vsk@apple.com>
Fri, 8 Dec 2017 02:47:58 +0000 (02:47 +0000)
There is no way to apply sanitizer suppressions to ObjC blocks. A
reasonable default is to have blocks inherit their parent's sanitizer
options.

rdar://32769634

Differential Revision: https://reviews.llvm.org/D40668

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@320132 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGBlocks.cpp
test/CodeGenObjC/no-sanitize.m

index 850681471df2af5c553b136eb8e0884242787dbe..5f73d4cf79137a0a0b95fb047919358524f7ef6c 100644 (file)
@@ -784,7 +784,9 @@ llvm::Value *CodeGenFunction::EmitBlockLiteral(const CGBlockInfo &blockInfo,
       8);
   // Using the computed layout, generate the actual block function.
   bool isLambdaConv = blockInfo.getBlockDecl()->isConversionFromLambda();
-  auto *InvokeFn = CodeGenFunction(CGM, true).GenerateBlockFunction(
+  CodeGenFunction BlockCGF{CGM, true};
+  BlockCGF.SanOpts = SanOpts;
+  auto *InvokeFn = BlockCGF.GenerateBlockFunction(
       CurGD, blockInfo, LocalDeclMap, isLambdaConv, blockInfo.CanBeGlobal);
   if (InvokeF)
     *InvokeF = InvokeFn;
index 39f8575670d5b97641d18e972013de940f4e2d9e..07a196b6419dc26a3cf7b174d055ae4a9c050645 100644 (file)
@@ -1,8 +1,9 @@
-// RUN: %clang_cc1 %s -emit-llvm -fsanitize=address -o - | FileCheck %s
+// RUN: %clang_cc1 %s -emit-llvm -fsanitize=address -fblocks -o - | FileCheck %s
 
 @interface I0 @end
 @implementation I0
 // CHECK-NOT: sanitize_address
 - (void) im0: (int) a0 __attribute__((no_sanitize("address"))) {
+  int (^blockName)() = ^int() { return 0; };
 }
 @end