[cfe-commits] r165116 - in /cfe/trunk: lib/AST/MicrosoftMangle.cpp test/CodeGenCXX/mangle-ms-templates.cpp

Nico Weber nicolasweber at gmx.de
Wed Oct 3 06:39:49 PDT 2012


Author: nico
Date: Wed Oct  3 08:39:49 2012
New Revision: 165116

URL: http://llvm.org/viewvc/llvm-project?rev=165116&view=rev
Log:
When mangling an APSInt with the ms abi, make sure to look at all nibbles.

Currently, it's ignored if the number of set bits isn't divisible by 4.


Modified:
    cfe/trunk/lib/AST/MicrosoftMangle.cpp
    cfe/trunk/test/CodeGenCXX/mangle-ms-templates.cpp

Modified: cfe/trunk/lib/AST/MicrosoftMangle.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/MicrosoftMangle.cpp?rev=165116&r1=165115&r2=165116&view=diff
==============================================================================
--- cfe/trunk/lib/AST/MicrosoftMangle.cpp (original)
+++ cfe/trunk/lib/AST/MicrosoftMangle.cpp Wed Oct  3 08:39:49 2012
@@ -350,7 +350,7 @@
     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);
     }

Modified: cfe/trunk/test/CodeGenCXX/mangle-ms-templates.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/mangle-ms-templates.cpp?rev=165116&r1=165115&r2=165116&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/mangle-ms-templates.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/mangle-ms-templates.cpp Wed Oct  3 08:39:49 2012
@@ -54,6 +54,15 @@
   IntTemplate<11> eleven;
 // CHECK: call {{.*}} @"\01??0?$IntTemplate@$0L@@@QAE at XZ"
 
+  IntTemplate<256> _256;
+// CHECK: call {{.*}} @"\01??0?$IntTemplate@$0BAA@@@QAE at XZ"
+
+  IntTemplate<513> _513;
+// CHECK: call {{.*}} @"\01??0?$IntTemplate@$0CAB@@@QAE at XZ"
+
+  IntTemplate<1026> _1026;
+// CHECK: call {{.*}} @"\01??0?$IntTemplate@$0EAC@@@QAE at XZ"
+
   IntTemplate<65535> ffff;
 // CHECK: call {{.*}} @"\01??0?$IntTemplate@$0PPPP@@@QAE at XZ"
 }





More information about the cfe-commits mailing list