llvm.org GIT mirror llvm / 9132a2b
rename APInt::toString -> toStringUnsigned for symmetry with toStringSigned() Add an APSInt::toString() method. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@41309 91177308-0d34-0410-b5e6-96231b3b80d8 Chris Lattner 12 years ago
7 changed file(s) with 15 addition(s) and 8 deletion(s). Raw diff Collapse all Expand all
115115 GenericValue GV = EE->runFunction(FibF, Args);
116116
117117 // import result of execution
118 std::cout << "Result: " << GV.IntVal.toString(10) << "\n";
118 std::cout << "Result: " << GV.IntVal.toStringUnsigned(10) << "\n";
119119 return 0;
120120 }
106106 GenericValue gv = EE->runFunction(FooF, noargs);
107107
108108 // Import result of execution:
109 std::cout << "Result: " << gv.IntVal.toString(10) << "\n";
109 std::cout << "Result: " << gv.IntVal.toStringUnsigned(10) << "\n";
110110 return 0;
111111 }
931931 /// radix given. The radix can be 2, 8, 10 or 16.
932932 /// @returns a character interpretation of the APInt
933933 /// @brief Convert unsigned APInt to string representation.
934 inline std::string toString(uint8_t radix = 10) const {
934 inline std::string toStringUnsigned(uint8_t radix = 10) const {
935935 return toString(radix, false);
936936 }
937937
5050 bool isUnsigned() const { return IsUnsigned; }
5151 void setIsUnsigned(bool Val) { IsUnsigned = Val; }
5252 void setIsSigned(bool Val) { IsUnsigned = !Val; }
53
54 /// This is used internally to convert an APInt to a string.
55 /// @brief Converts an APInt to a std::string
56 std::string toString(uint8_t Radix) const {
57 return toString(Radix, isSigned());
58 }
5359
5460
5561 const APSInt &operator%=(const APSInt &RHS) {
13451345 case Type::DoubleTyID: DOUT << "double " << Val.DoubleVal; break;
13461346 case Type::PointerTyID: DOUT << "void* " << intptr_t(Val.PointerVal); break;
13471347 case Type::IntegerTyID:
1348 DOUT << "i" << Val.IntVal.getBitWidth() << " " << Val.IntVal.toString(10)
1349 << " (0x" << Val.IntVal.toString(16) << ")\n";
1348 DOUT << "i" << Val.IntVal.getBitWidth() << " "
1349 << Val.IntVal.toStringUnsigned(10)
1350 << " (0x" << Val.IntVal.toStringUnsigned(16) << ")\n";
13501351 break;
13511352 }
13521353 }
20072007 else for (unsigned i = getNumWords(); i > 0; i--) {
20082008 cerr << pVal[i-1] << " ";
20092009 }
2010 cerr << " U(" << this->toString(10) << ") S(" << this->toStringSigned(10)
2011 << ")\n" << std::setbase(10);
2010 cerr << " U(" << this->toStringUnsigned(10) << ") S("
2011 << this->toStringSigned(10) << ")\n" << std::setbase(10);
20122012 }
20132013 #endif
20142014
518518 std::string NewName = I->getName();
519519 for (unsigned i = 0, e = Operands.size(); i != e; ++i)
520520 if (ConstantInt *CI = dyn_cast(Operands[i]))
521 NewName += "." + CI->getValue().toString(10);
521 NewName += "." + CI->getValue().toStringUnsigned(10);
522522 else
523523 NewName += ".x";
524524 TheArg->setName(NewName+".val");