summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVedant Kumar <vsk@apple.com>2017-12-08 02:47:58 +0000
committerVedant Kumar <vsk@apple.com>2017-12-08 02:47:58 +0000
commit29477dc82e9f6e35a91210daa834c59d8216d308 (patch)
tree1b95f455d5c3a83dc3886ed5d33a02b4252dcc69
parent1c30924420199897009723aa637219576bbf96fc (diff)
downloadbcm5719-llvm-29477dc82e9f6e35a91210daa834c59d8216d308.tar.gz
bcm5719-llvm-29477dc82e9f6e35a91210daa834c59d8216d308.zip
[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 llvm-svn: 320132
-rw-r--r--clang/lib/CodeGen/CGBlocks.cpp4
-rw-r--r--clang/test/CodeGenObjC/no-sanitize.m3
2 files changed, 5 insertions, 2 deletions
diff --git a/clang/lib/CodeGen/CGBlocks.cpp b/clang/lib/CodeGen/CGBlocks.cpp
index 850681471df..5f73d4cf791 100644
--- a/clang/lib/CodeGen/CGBlocks.cpp
+++ b/clang/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/clang/test/CodeGenObjC/no-sanitize.m b/clang/test/CodeGenObjC/no-sanitize.m
index 39f8575670d..07a196b6419 100644
--- a/clang/test/CodeGenObjC/no-sanitize.m
+++ b/clang/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
OpenPOWER on IntegriCloud