From: Vedant Kumar Date: Fri, 8 Dec 2017 02:47:58 +0000 (+0000) Subject: [Blocks] Inherit sanitizer options from parent decl X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4ae9615b7be11935b80652f854fb3109e1f5c875;p=clang [Blocks] Inherit sanitizer options from parent decl 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 --- diff --git a/lib/CodeGen/CGBlocks.cpp b/lib/CodeGen/CGBlocks.cpp index 850681471d..5f73d4cf79 100644 --- a/lib/CodeGen/CGBlocks.cpp +++ b/lib/CodeGen/CGBlocks.cpp @@ -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; diff --git a/test/CodeGenObjC/no-sanitize.m b/test/CodeGenObjC/no-sanitize.m index 39f8575670..07a196b641 100644 --- a/test/CodeGenObjC/no-sanitize.m +++ b/test/CodeGenObjC/no-sanitize.m @@ -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