rename APInt::toString -> toStringUnsigned for symmetry with toStringSigned()
authorChris Lattner <sabre@nondot.org>
Thu, 23 Aug 2007 05:15:32 +0000 (05:15 +0000)
committerChris Lattner <sabre@nondot.org>
Thu, 23 Aug 2007 05:15:32 +0000 (05:15 +0000)
Add an APSInt::toString() method.

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

examples/Fibonacci/fibonacci.cpp
examples/HowToUseJIT/HowToUseJIT.cpp
include/llvm/ADT/APInt.h
include/llvm/ADT/APSInt.h
lib/ExecutionEngine/Interpreter/Execution.cpp
lib/Support/APInt.cpp
lib/Transforms/IPO/ArgumentPromotion.cpp

index cd35417fb3e8270d1da55aa867f620b161a7fe8b..d0ffb9ac53d2bc024bf30e2d1e625e15b3eb9b79 100644 (file)
@@ -116,6 +116,6 @@ int main(int argc, char **argv) {
   GenericValue GV = EE->runFunction(FibF, Args);
 
   // import result of execution
-  std::cout << "Result: " << GV.IntVal.toString(10) << "\n";
+  std::cout << "Result: " << GV.IntVal.toStringUnsigned(10) << "\n";
   return 0;
 }
index 621621dc46dca5945ab2684f666b5127b26d3cca..a4f6f3748e3bbd3b39a3d184b31ecb18e816d611 100644 (file)
@@ -107,6 +107,6 @@ int main() {
   GenericValue gv = EE->runFunction(FooF, noargs);
 
   // Import result of execution:
-  std::cout << "Result: " << gv.IntVal.toString(10) << "\n";
+  std::cout << "Result: " << gv.IntVal.toStringUnsigned(10) << "\n";
   return 0;
 }
index 971822f1bd4a8fbdfb4f52618ab22af3b76c1586..0102d67e07e61f50b5e3e8c9844e93a9be4b180a 100644 (file)
@@ -932,7 +932,7 @@ public:
   /// radix given. The radix can be 2, 8, 10 or 16.
   /// @returns a character interpretation of the APInt
   /// @brief Convert unsigned APInt to string representation.
-  inline std::string toString(uint8_t radix = 10) const {
+  inline std::string toStringUnsigned(uint8_t radix = 10) const {
     return toString(radix, false);
   }
 
index 7e515da704b73cf4159486676401e7f51ea3152d..91dd709000ce1c2fcf8bc4df1e3a14f52284958b 100644 (file)
@@ -52,6 +52,12 @@ public:
   void setIsUnsigned(bool Val) { IsUnsigned = Val; }
   void setIsSigned(bool Val) { IsUnsigned = !Val; }
   
+  /// This is used internally to convert an APInt to a string.
+  /// @brief Converts an APInt to a std::string
+  std::string toString(uint8_t Radix) const {
+    return toString(Radix, isSigned());
+  }
+  
   
   const APSInt &operator%=(const APSInt &RHS) {
     assert(IsUnsigned == RHS.IsUnsigned && "Signedness mismatch!");
index 281f774193fc8357e102bbdc6ecfb7897326f65f..53df5443659c2c1288d308daf552315a57d81b6d 100644 (file)
@@ -1346,8 +1346,9 @@ static void PrintGenericValue(const GenericValue &Val, const Type* Ty) {
     case Type::DoubleTyID:  DOUT << "double " << Val.DoubleVal; break;
     case Type::PointerTyID: DOUT << "void* " << intptr_t(Val.PointerVal); break;
     case Type::IntegerTyID: 
-      DOUT << "i" << Val.IntVal.getBitWidth() << " " << Val.IntVal.toString(10)
-           << " (0x" << Val.IntVal.toString(16) << ")\n";
+      DOUT << "i" << Val.IntVal.getBitWidth() << " "
+           << Val.IntVal.toStringUnsigned(10)
+           << " (0x" << Val.IntVal.toStringUnsigned(16) << ")\n";
       break;
   }
 }
index 173f28c8d1990189ecf854c3a031cde378309150..277a0b0c113c35b187b971b63b3bec286a2db164 100644 (file)
@@ -2008,8 +2008,8 @@ void APInt::dump() const
   else for (unsigned i = getNumWords(); i > 0; i--) {
     cerr << pVal[i-1] << " ";
   }
-  cerr << " U(" << this->toString(10) << ") S(" << this->toStringSigned(10)
-       << ")\n" << std::setbase(10);
+  cerr << " U(" << this->toStringUnsigned(10) << ") S("
+       << this->toStringSigned(10) << ")\n" << std::setbase(10);
 }
 #endif
 
index 78703a40b747d71c86e83d9f2259b17b3ca72dd3..d40df48b29af5560ca7615f12db8809f07c57df7 100644 (file)
@@ -519,7 +519,7 @@ Function *ArgPromotion::DoPromotion(Function *F,
           std::string NewName = I->getName();
           for (unsigned i = 0, e = Operands.size(); i != e; ++i)
             if (ConstantInt *CI = dyn_cast<ConstantInt>(Operands[i]))
-              NewName += "." + CI->getValue().toString(10);
+              NewName += "." + CI->getValue().toStringUnsigned(10);
             else
               NewName += ".x";
           TheArg->setName(NewName+".val");