]> granicus.if.org Git - clang/commitdiff
[Windows] Fix mangling of number literal '0'
authorNico Weber <nicolasweber@gmx.de>
Thu, 8 Nov 2012 23:38:59 +0000 (23:38 +0000)
committerNico Weber <nicolasweber@gmx.de>
Thu, 8 Nov 2012 23:38:59 +0000 (23:38 +0000)
Do this by making the mangleNumber(APSInt) overload look like
the int64_t version. (The latter should probably just delegate
to the former).

Test from Evgeny Eltsin!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@167599 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/MicrosoftMangle.cpp
test/CodeGenCXX/mangle-ms-templates.cpp

index 3765f3087e50a89b04ec940c49bf48d7621c48f4..b7bfc70123e238974e1c7f0f69f8d2601d4dd564 100644 (file)
@@ -351,10 +351,10 @@ void MicrosoftCXXNameMangler::mangleNumber(const llvm::APSInt &Value) {
     char *CurPtr = EndPtr;
     llvm::APSInt NibbleMask(Value.getBitWidth(), Value.isUnsigned());
     NibbleMask = 0xf;
-    for (int i = 0, e = (Value.getActiveBits() + 3) / 4; i != e; ++i) {
+    do {
       *--CurPtr = 'A' + Temp.And(NibbleMask).getLimitedValue(0xf);
       Temp = Temp.lshr(4);
-    }
+    } while (Temp != 0);
     Out.write(CurPtr, EndPtr-CurPtr);
     Out << '@';
   }
index efe9565d3324bc007b7b0d6eba26271436d216b3..e16fe936bc2ec991fc79b7d89bddc21d5e35b12a 100644 (file)
@@ -48,6 +48,9 @@ void template_mangling() {
 // CHECK: call {{.*}} @"\01??0?$BoolTemplate@$00@@QAE@XZ"
 // CHECK: call {{.*}} @"\01??$Foo@H@?$BoolTemplate@$00@@QAEXH@Z"
 
+  IntTemplate<0> zero;
+// CHECK: call {{.*}} @"\01??0?$IntTemplate@$0A@@@QAE@XZ"
+
   IntTemplate<5> five;
 // CHECK: call {{.*}} @"\01??0?$IntTemplate@$04@@QAE@XZ"