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.

llvm-svn: 165116
This commit is contained in:
Nico Weber 2012-10-03 13:39:49 +00:00
parent 30abda1612
commit 90a415e7ca
2 changed files with 10 additions and 1 deletions

View 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);
}

View 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"
}