diff options
Diffstat (limited to 'clang')
| -rw-r--r-- | clang/lib/AST/MicrosoftMangle.cpp | 2 | ||||
| -rw-r--r-- | clang/test/CodeGenCXX/mangle-ms-templates.cpp | 9 |
2 files changed, 10 insertions, 1 deletions
diff --git a/clang/lib/AST/MicrosoftMangle.cpp b/clang/lib/AST/MicrosoftMangle.cpp index 072ad06999d..d456e822ae9 100644 --- a/clang/lib/AST/MicrosoftMangle.cpp +++ b/clang/lib/AST/MicrosoftMangle.cpp @@ -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); } diff --git a/clang/test/CodeGenCXX/mangle-ms-templates.cpp b/clang/test/CodeGenCXX/mangle-ms-templates.cpp index 977ef353dab..efe9565d332 100644 --- a/clang/test/CodeGenCXX/mangle-ms-templates.cpp +++ b/clang/test/CodeGenCXX/mangle-ms-templates.cpp @@ -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" } |

