Hi rnk, cdavis5x,

We should mangle INT_MIN like -INT_MIN.

This fixes PR16871.

http://llvm-reviews.chandlerc.com/D1376

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

Index: lib/AST/MicrosoftMangle.cpp
===================================================================
--- lib/AST/MicrosoftMangle.cpp
+++ lib/AST/MicrosoftMangle.cpp
@@ -367,7 +367,10 @@
   // <number> ::= [?] <decimal digit> # 1 <= Number <= 10
   //          ::= [?] <hex digit>+ @ # 0 or > 9; A = 0, B = 1, etc...
   //          ::= [?] @ # 0 (alternate mangling, not emitted by VC)
-  if (Value.isSigned() && Value.isNegative()) {
+  //
+  // N.B. The representation of signed values that are their smallest possible
+  // value omits the question mark.
+  if (Value.isSigned() && Value.isNegative() && !Value.isMinSignedValue()) {
     Out << '?';
     mangleNumber(llvm::APSInt(Value.abs()));
     return;
Index: test/CodeGenCXX/mangle-ms-templates.cpp
===================================================================
--- test/CodeGenCXX/mangle-ms-templates.cpp
+++ test/CodeGenCXX/mangle-ms-templates.cpp
@@ -108,6 +108,10 @@
   IntTemplate<65535> ffff;
 // CHECK: call {{.*}} @"\01??0?$IntTemplate@$0PPPP@@@QAE@XZ"
 // X64: call {{.*}} @"\01??0?$IntTemplate@$0PPPP@@@QEAA@XZ"
+
+  IntTemplate<-2147483648> IntMin;
+// CHECK: call {{.*}} @"\01??0?$IntTemplate@$0IAAAAAAA@@@QAE@XZ"
+// X64: call {{.*}} @"\01??0?$IntTemplate@$0IAAAAAAA@@@QEAA@XZ"
 }
 
 namespace space {
Index: lib/AST/MicrosoftMangle.cpp
===================================================================
--- lib/AST/MicrosoftMangle.cpp
+++ lib/AST/MicrosoftMangle.cpp
@@ -367,7 +367,10 @@
   // <number> ::= [?] <decimal digit> # 1 <= Number <= 10
   //          ::= [?] <hex digit>+ @ # 0 or > 9; A = 0, B = 1, etc...
   //          ::= [?] @ # 0 (alternate mangling, not emitted by VC)
-  if (Value.isSigned() && Value.isNegative()) {
+  //
+  // N.B. The representation of signed values that are their smallest possible
+  // value omits the question mark.
+  if (Value.isSigned() && Value.isNegative() && !Value.isMinSignedValue()) {
     Out << '?';
     mangleNumber(llvm::APSInt(Value.abs()));
     return;
Index: test/CodeGenCXX/mangle-ms-templates.cpp
===================================================================
--- test/CodeGenCXX/mangle-ms-templates.cpp
+++ test/CodeGenCXX/mangle-ms-templates.cpp
@@ -108,6 +108,10 @@
   IntTemplate<65535> ffff;
 // CHECK: call {{.*}} @"\01??0?$IntTemplate@$0PPPP@@@QAE@XZ"
 // X64: call {{.*}} @"\01??0?$IntTemplate@$0PPPP@@@QEAA@XZ"
+
+  IntTemplate<-2147483648> IntMin;
+// CHECK: call {{.*}} @"\01??0?$IntTemplate@$0IAAAAAAA@@@QAE@XZ"
+// X64: call {{.*}} @"\01??0?$IntTemplate@$0IAAAAAAA@@@QEAA@XZ"
 }
 
 namespace space {
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to