r214699 - AST: Fix the mangling for unqualified-blocks
David Majnemer
david.majnemer at gmail.com
Sun Aug 3 23:16:51 PDT 2014
Author: majnemer
Date: Mon Aug 4 01:16:50 2014
New Revision: 214699
URL: http://llvm.org/viewvc/llvm-project?rev=214699&view=rev
Log:
AST: Fix the mangling for unqualified-blocks
CXXNameMangler::mangleUnqualifiedBlock believed that
MangleContext::getBlockId returned something that used Itanium-style
discriminator numbers.
Discriminator numbers start their numberign from 1 and the first
mangling that actually gets any sort of number mangled in is the second
discriminator.
However, Block IDs start from zero. The logic for omitting the mangling
number did a ' > 1' instead of a ' > 0' comparison; this could
potentially cause mangling conflicts.
Modified:
cfe/trunk/lib/AST/ItaniumMangle.cpp
cfe/trunk/test/CodeGenObjCXX/mangle-blocks.mm
Modified: cfe/trunk/lib/AST/ItaniumMangle.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ItaniumMangle.cpp?rev=214699&r1=214698&r2=214699&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ItaniumMangle.cpp (original)
+++ cfe/trunk/lib/AST/ItaniumMangle.cpp Mon Aug 4 01:16:50 2014
@@ -1409,8 +1409,8 @@ void CXXNameMangler::mangleUnqualifiedBl
if (!Number)
Number = Context.getBlockId(Block, false);
Out << "Ub";
- if (Number > 1)
- Out << Number - 2;
+ if (Number > 0)
+ Out << Number - 1;
Out << '_';
}
Modified: cfe/trunk/test/CodeGenObjCXX/mangle-blocks.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjCXX/mangle-blocks.mm?rev=214699&r1=214698&r2=214699&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenObjCXX/mangle-blocks.mm (original)
+++ cfe/trunk/test/CodeGenObjCXX/mangle-blocks.mm Mon Aug 4 01:16:50 2014
@@ -1,9 +1,8 @@
// RUN: %clang_cc1 -emit-llvm -fblocks -o - -triple x86_64-apple-darwin10 -fobjc-runtime=macosx-fragile-10.5 %s | FileCheck %s
-// CHECK: @_ZGVZZ3foovEUb_E5value = internal global i64 0
-// CHECK: @_ZZZN26externally_visible_statics1S3fooEiEd_Ub_E1k = linkonce_odr global i32 0
-// CHECK: @_ZZ26externally_visible_statics1S1xMUb_E1j = linkonce_odr global i32 0
-// CHECK: @_ZZZN26externally_visible_statics10inlinefuncEvEUb_E1i = linkonce_odr global i32 0
+// CHECK: @_ZZZN26externally_visible_statics1S3fooEiEd_Ub0_E1k = linkonce_odr global i32 0
+// CHECK: @_ZZ26externally_visible_statics1S1xMUb0_E1j = linkonce_odr global i32 0
+// CHECK: @_ZZZN26externally_visible_statics10inlinefuncEvEUb0_E1i = linkonce_odr global i32 0
int f();
@@ -27,7 +26,7 @@ int i = ^(int x) { return x;}(i);
- (void)method {
// CHECK: define internal signext i8 @"__11-[A method]_block_invoke"
(void)^(int x) {
- // CHECK: @"_ZZZ11-[A method]EUb0_E4name"
+ // CHECK: @"_ZZZ11-[A method]EUb1_E4name"
static const char *name = "hello";
return name[x];
};
@@ -45,7 +44,7 @@ namespace N {
// CHECK-LABEL: define internal signext i8 @___Z3fooi_block_invoke
void bar() {
(void)^(int x) {
- // CHECK: @_ZZZN1N3barEvEUb2_E4name
+ // CHECK: @_ZZZN1N3barEvEUb3_E4name
static const char *name = "hello";
return name[x];
};
@@ -57,7 +56,7 @@ class C {
};
C::C() {
(void)^(int x) {
- // CHECK: @_ZZZN1CC1EvEUb3_E5nameb
+ // CHECK: @_ZZZN1CC1EvEUb4_E5nameb
static const char *nameb = "hello";
return nameb[x];
};
More information about the cfe-commits
mailing list