]> granicus.if.org Git - clang/commitdiff
When mangling a negative number, remember that negating it does not
authorJohn McCall <rjmccall@apple.com>
Sat, 18 Aug 2012 04:51:52 +0000 (04:51 +0000)
committerJohn McCall <rjmccall@apple.com>
Sat, 18 Aug 2012 04:51:52 +0000 (04:51 +0000)
always yield a positive number.  Just print the negated result as an
unsigned number.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@162163 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/ItaniumMangle.cpp
test/CodeGenCXX/mangle-template.cpp

index 7c7a5e5de38711910694fdaa6299f8eb6ca51685..0b8a4c89f86732ff4d70393014f6f8151c30e700 100644 (file)
@@ -693,9 +693,10 @@ void CXXNameMangler::mangleFloat(const llvm::APFloat &f) {
 void CXXNameMangler::mangleNumber(const llvm::APSInt &Value) {
   if (Value.isSigned() && Value.isNegative()) {
     Out << 'n';
-    Value.abs().print(Out, true);
-  } else
-    Value.print(Out, Value.isSigned());
+    Value.abs().print(Out, /*signed*/ false);
+  } else {
+    Value.print(Out, /*signed*/ false);
+  }
 }
 
 void CXXNameMangler::mangleNumber(int64_t Number) {
index 05c3a5851e4a1c81cdbd66436172deda1e9a833c..488f6f3bb1de406ad78a82a6c61f430d8175967c 100644 (file)
@@ -170,3 +170,15 @@ namespace test12 {
     test<const int&, n>();
   }
 }
+
+// rdar://problem/12072531
+// Test the boundary condition of minimal signed integers.
+namespace test13 {
+  template <char c> char returnChar() { return c; }
+  template char returnChar<-128>();
+  // CHECK: @_ZN6test1310returnCharILcn128EEEcv()
+
+  template <short s> short returnShort() { return s; }
+  template short returnShort<-32768>();
+  // CHECK: @_ZN6test1311returnShortILsn32768EEEsv()
+}