From: David Majnemer Date: Mon, 4 Aug 2014 06:16:50 +0000 (+0000) Subject: AST: Fix the mangling for unqualified-blocks X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5a85cc570a8fb55f153afca689e905cdbfc93e7d;p=clang 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@214699 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/AST/ItaniumMangle.cpp b/lib/AST/ItaniumMangle.cpp index da83d710a1..486fab39ea 100644 --- a/lib/AST/ItaniumMangle.cpp +++ b/lib/AST/ItaniumMangle.cpp @@ -1409,8 +1409,8 @@ void CXXNameMangler::mangleUnqualifiedBlock(const BlockDecl *Block) { if (!Number) Number = Context.getBlockId(Block, false); Out << "Ub"; - if (Number > 1) - Out << Number - 2; + if (Number > 0) + Out << Number - 1; Out << '_'; } diff --git a/test/CodeGenObjCXX/mangle-blocks.mm b/test/CodeGenObjCXX/mangle-blocks.mm index 405e5282cd..1f3f163adb 100644 --- a/test/CodeGenObjCXX/mangle-blocks.mm +++ b/test/CodeGenObjCXX/mangle-blocks.mm @@ -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]; };