This changes the mangling of local static variables/etc. inside blocks
to do something simple and sane. This avoids depending on the way we mangle
blocks, which isn't really appropriate here.
John, please take a look at this to make sure the mangling I chose is sane.
Fixes <rdar://problem/
14074423>.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@184780
91177308-0d34-0410-b5e6-
96231b3b80d8
return;
if (const BlockDecl *Block = dyn_cast<BlockDecl>(DC)) {
- manglePrefix(getEffectiveParentContext(DC), NoFunction);
- SmallString<64> Name;
- llvm::raw_svector_ostream NameStream(Name);
- Context.mangleBlock(Block, NameStream);
- NameStream.flush();
- Out << Name.size() << Name;
+ // The symbol we're adding a prefix for isn't externally
+ // visible; make up something sane.
+ // FIXME: This isn't always true!
+ SmallString<16> BlockPrefix;
+ BlockPrefix += "__block_prefix_internal";
+ unsigned Number = Context.getBlockId(Block, false);
+ if (Number > 1)
+ BlockPrefix += llvm::utostr_32(Number - 2);
+ Out << BlockPrefix.size() << BlockPrefix;
return;
} else if (isa<CapturedDecl>(DC)) {
// Skip CapturedDecl context.
}
// CHECK: define internal zeroext i1 @___ZN7PR127462f1EPi_block_invoke
- // CHECK: call zeroext i1 @"_ZNK7PR127462f132___ZN7PR127462f1EPi_block_invoke3$_0clEv"
+ // CHECK: call zeroext i1 @"_ZNK23__block_prefix_internal3$_0clEv"
bool f2(int *x) {
auto outer = [&]() -> bool {
// RUN: %clang_cc1 -emit-llvm -fblocks -o - -triple x86_64-apple-darwin10 -fobjc-runtime=macosx-fragile-10.5 %s | FileCheck %s
-// CHECK: @_ZGVN3foo22___Z3foov_block_invoke5valueE = internal global i64 0
+// CHECK: @_ZGVN23__block_prefix_internal5valueE = internal global i64 0
+// CHECK: @_ZN24__block_prefix_internal35namebE = internal global i8*
int f();
void foo() {
// CHECK: define internal i32 @___Z3foov_block_invoke
- // CHECK: call i32 @__cxa_guard_acquire(i64* @_ZGVN3foo22___Z3foov_block_invoke5valueE
+ // CHECK: call i32 @__cxa_guard_acquire(i64* @_ZGVN23__block_prefix_internal5valueE
(void)^(int x) {
static int value = f();
return x + value;
- (void)method {
// CHECK: define internal signext i8 @"__11-[A method]_block_invoke"
(void)^(int x) {
- // CHECK: @"_ZN11-[A method]28__11-[A method]_block_invoke4nameE"
+ // CHECK: @_ZN24__block_prefix_internal04nameE
static const char *name = "hello";
return name[x];
};
// CHECK: define internal signext i8 @___Z3fooi_block_invoke
void bar() {
(void)^(int x) {
- // CHECK: @_ZN1N3bar26___ZN1N3barEv_block_invoke4nameE
+ // CHECK: @_ZN24__block_prefix_internal14nameE
static const char *name = "hello";
return name[x];
};
}
}
+
+class C {
+ C();
+};
+C::C() {
+ (void)^(int x) {
+ // CHECK: @_ZN24__block_prefix_internal35namebE
+ static const char *nameb = "hello";
+ return nameb[x];
+ };
+}