diff options
author | Ted Kremenek <kremenek@apple.com> | 2011-06-15 00:51:55 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2011-06-15 00:51:55 +0000 |
commit | cf886188fb04d9521db39fe5213df1295673f51e (patch) | |
tree | 6ec35a5a4465367e62d725a57fc8b7aec3198f39 /include/llvm/ADT/APInt.h | |
parent | a990e071f2f29ba326b97a4288207a2c406c5b66 (diff) | |
download | external_llvm-cf886188fb04d9521db39fe5213df1295673f51e.zip external_llvm-cf886188fb04d9521db39fe5213df1295673f51e.tar.gz external_llvm-cf886188fb04d9521db39fe5213df1295673f51e.tar.bz2 |
add option for literal formatting to APInt::toString()
toString() now takes an optional bool argument that,
depending on the radix, adds the appropriate prefix
to the integer's string representation that makes it into a
meaningful C literal, e.g.:
hexademical: '-f' becomes '-0xf'
octal: '77' becomes '077'
binary: '110' becomes '0b110'
Patch by nobled@dreamwidth.org!
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@133032 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/ADT/APInt.h')
-rw-r--r-- | include/llvm/ADT/APInt.h | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/include/llvm/ADT/APInt.h b/include/llvm/ADT/APInt.h index 2feef07..e68e579 100644 --- a/include/llvm/ADT/APInt.h +++ b/include/llvm/ADT/APInt.h @@ -1241,18 +1241,19 @@ public: /// toString - Converts an APInt to a string and append it to Str. Str is /// commonly a SmallString. - void toString(SmallVectorImpl<char> &Str, unsigned Radix, bool Signed) const; + void toString(SmallVectorImpl<char> &Str, unsigned Radix, bool Signed, + bool formatAsCLiteral = false) const; /// Considers the APInt to be unsigned and converts it into a string in the /// radix given. The radix can be 2, 8, 10 or 16. void toStringUnsigned(SmallVectorImpl<char> &Str, unsigned Radix = 10) const { - toString(Str, Radix, false); + toString(Str, Radix, false, false); } /// Considers the APInt to be signed and converts it into a string in the /// radix given. The radix can be 2, 8, 10 or 16. void toStringSigned(SmallVectorImpl<char> &Str, unsigned Radix = 10) const { - toString(Str, Radix, true); + toString(Str, Radix, true, false); } /// toString - This returns the APInt as a std::string. Note that this is an |