diff options
author | Daniel Dunbar <daniel@zuster.org> | 2009-07-30 03:47:15 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2009-07-30 03:47:15 +0000 |
commit | 1d7126de19c175ddf9ff0d18671a70d7a44127ab (patch) | |
tree | e86f0c3785829879dde86657f0639df9504ad31a /include/llvm/ADT | |
parent | a89b3b3e15fce275ca9080dbe77c51034b4aedbc (diff) | |
download | external_llvm-1d7126de19c175ddf9ff0d18671a70d7a44127ab.zip external_llvm-1d7126de19c175ddf9ff0d18671a70d7a44127ab.tar.gz external_llvm-1d7126de19c175ddf9ff0d18671a70d7a44127ab.tar.bz2 |
Twine: Provide [u]int{32,64} conversions via implicit constructors instead of
explicitly.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77576 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/ADT')
-rw-r--r-- | include/llvm/ADT/Twine.h | 45 |
1 files changed, 31 insertions, 14 deletions
diff --git a/include/llvm/ADT/Twine.h b/include/llvm/ADT/Twine.h index 66a4ad3..3022812 100644 --- a/include/llvm/ADT/Twine.h +++ b/include/llvm/ADT/Twine.h @@ -101,14 +101,21 @@ namespace llvm { /// A pointer to a uint64_t value, to render as an unsigned decimal /// integer. - UDecKind, + UDec32Kind, - /// A pointer to a uint64_t value, to render as an unsigned hexadecimal + /// A pointer to a uint64_t value, to render as a signed decimal integer. + SDec32Kind, + + /// A pointer to a uint64_t value, to render as an unsigned decimal /// integer. - UHexKind, + UDec64Kind, /// A pointer to a uint64_t value, to render as a signed decimal integer. - SDecKind + SDec64Kind, + + /// A pointer to a uint64_t value, to render as an unsigned hexadecimal + /// integer. + UHexKind }; private: @@ -244,6 +251,26 @@ namespace llvm { assert(isValid() && "Invalid twine!"); } + /// Construct a twine to print \arg Val as an unsigned decimal integer. + Twine(const uint32_t &Val) + : LHS(&Val), LHSKind(UDec32Kind), RHSKind(EmptyKind) { + } + + /// Construct a twine to print \arg Val as a signed decimal integer. + Twine(const int32_t &Val) + : LHS(&Val), LHSKind(SDec32Kind), RHSKind(EmptyKind) { + } + + /// Construct a twine to print \arg Val as an unsigned decimal integer. + Twine(const uint64_t &Val) + : LHS(&Val), LHSKind(UDec64Kind), RHSKind(EmptyKind) { + } + + /// Construct a twine to print \arg Val as a signed decimal integer. + Twine(const int64_t &Val) + : LHS(&Val), LHSKind(SDec64Kind), RHSKind(EmptyKind) { + } + // FIXME: Unfortunately, to make sure this is as efficient as possible we // need extra binary constructors from particular types. We can't rely on // the compiler to be smart enough to fold operator+()/concat() down to the @@ -271,16 +298,6 @@ namespace llvm { /// @name Numeric Conversions /// @{ - /// Construct a twine to print \arg Val as an unsigned decimal integer. - static Twine utostr(const uint64_t &Val) { - return Twine(&Val, UDecKind, 0, EmptyKind); - } - - /// Construct a twine to print \arg Val as a signed decimal integer. - static Twine itostr(const int64_t &Val) { - return Twine(&Val, SDecKind, 0, EmptyKind); - } - // Construct a twine to print \arg Val as an unsigned hexadecimal integer. static Twine utohexstr(const uint64_t &Val) { return Twine(&Val, UHexKind, 0, EmptyKind); |