aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNico Weber <nicolasweber@gmx.de>2012-11-08 23:38:59 +0000
committerNico Weber <nicolasweber@gmx.de>2012-11-08 23:38:59 +0000
commite95b46bf50059806d58f494f6ad3a827dce02e24 (patch)
tree802e819ed5134d96b885ec8ebbbe347a74c15283
parent458871a13c9f07bb46b4a32e3add0c9cb730f26e (diff)
[Windows] Fix mangling of number literal '0'
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
-rw-r--r--lib/AST/MicrosoftMangle.cpp4
-rw-r--r--test/CodeGenCXX/mangle-ms-templates.cpp3
2 files changed, 5 insertions, 2 deletions
diff --git a/lib/AST/MicrosoftMangle.cpp b/lib/AST/MicrosoftMangle.cpp
index 3765f3087e..b7bfc70123 100644
--- a/lib/AST/MicrosoftMangle.cpp
+++ b/lib/AST/MicrosoftMangle.cpp
@@ -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 << '@';
}
diff --git a/test/CodeGenCXX/mangle-ms-templates.cpp b/test/CodeGenCXX/mangle-ms-templates.cpp
index efe9565d33..e16fe936bc 100644
--- a/test/CodeGenCXX/mangle-ms-templates.cpp
+++ b/test/CodeGenCXX/mangle-ms-templates.cpp
@@ -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"