]> granicus.if.org Git - clang/commitdiff
When mangling an APSInt with the ms abi, make sure to look at all nibbles.
authorNico Weber <nicolasweber@gmx.de>
Wed, 3 Oct 2012 13:39:49 +0000 (13:39 +0000)
committerNico Weber <nicolasweber@gmx.de>
Wed, 3 Oct 2012 13:39:49 +0000 (13:39 +0000)
Currently, it's ignored if the number of set bits isn't divisible by 4.

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

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

index 072ad06999d1b1921c7905706ccfab83a44e6bd6..d456e822ae9a54e23c645e69bb0124a4724cc666 100644 (file)
@@ -350,7 +350,7 @@ 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() / 4; i != e; ++i) {
+    for (int i = 0, e = (Value.getActiveBits() + 3) / 4; i != e; ++i) {
       *--CurPtr = 'A' + Temp.And(NibbleMask).getLimitedValue(0xf);
       Temp = Temp.lshr(4);
     }
index 977ef353dabc652aae7862c9d46d6104ca996e01..efe9565d3324bc007b7b0d6eba26271436d216b3 100644 (file)
@@ -54,6 +54,15 @@ void template_mangling() {
   IntTemplate<11> eleven;
 // CHECK: call {{.*}} @"\01??0?$IntTemplate@$0L@@@QAE@XZ"
 
+  IntTemplate<256> _256;
+// CHECK: call {{.*}} @"\01??0?$IntTemplate@$0BAA@@@QAE@XZ"
+
+  IntTemplate<513> _513;
+// CHECK: call {{.*}} @"\01??0?$IntTemplate@$0CAB@@@QAE@XZ"
+
+  IntTemplate<1026> _1026;
+// CHECK: call {{.*}} @"\01??0?$IntTemplate@$0EAC@@@QAE@XZ"
+
   IntTemplate<65535> ffff;
 // CHECK: call {{.*}} @"\01??0?$IntTemplate@$0PPPP@@@QAE@XZ"
 }