r320132 - [Blocks] Inherit sanitizer options from parent decl
Vedant Kumar via cfe-commits
cfe-commits at lists.llvm.org
Thu Dec 7 18:47:58 PST 2017
Author: vedantk
Date: Thu Dec 7 18:47:58 2017
New Revision: 320132
URL: http://llvm.org/viewvc/llvm-project?rev=320132&view=rev
Log:
[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
Modified:
cfe/trunk/lib/CodeGen/CGBlocks.cpp
cfe/trunk/test/CodeGenObjC/no-sanitize.m
Modified: cfe/trunk/lib/CodeGen/CGBlocks.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBlocks.cpp?rev=320132&r1=320131&r2=320132&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGBlocks.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBlocks.cpp Thu Dec 7 18:47:58 2017
@@ -784,7 +784,9 @@ llvm::Value *CodeGenFunction::EmitBlockL
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;
Modified: cfe/trunk/test/CodeGenObjC/no-sanitize.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/no-sanitize.m?rev=320132&r1=320131&r2=320132&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenObjC/no-sanitize.m (original)
+++ cfe/trunk/test/CodeGenObjC/no-sanitize.m Thu Dec 7 18:47:58 2017
@@ -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
More information about the cfe-commits
mailing list