From 2d8bc0fe70c55664b89605dbfa5c2f591446469c Mon Sep 17 00:00:00 2001 From: Daniel Dunbar Date: Thu, 30 Jul 2009 21:15:14 +0000 Subject: [PATCH] Twine: Directly support int, long, and long long types. - This should resolve Cygwin gcc ambiguities. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77624 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/ADT/Twine.h | 49 +++++++++++++++++++++++++++------------- lib/Support/Twine.cpp | 46 +++++++++++++++++++++++-------------- 2 files changed, 62 insertions(+), 33 deletions(-) diff --git a/include/llvm/ADT/Twine.h b/include/llvm/ADT/Twine.h index cb5bb4d7b9f..2c6ba0bc232 100644 --- a/include/llvm/ADT/Twine.h +++ b/include/llvm/ADT/Twine.h @@ -99,19 +99,26 @@ namespace llvm { /// A pointer to a StringRef instance. StringRefKind, - /// A pointer to a uint64_t value, to render as an unsigned decimal + /// A pointer to an unsigned int value, to render as an unsigned decimal /// integer. - UDec32Kind, + DecUIKind, - /// A pointer to a uint64_t value, to render as a signed decimal integer. - SDec32Kind, + /// A pointer to an int value, to render as a signed decimal integer. + DecIKind, - /// A pointer to a uint64_t value, to render as an unsigned decimal + /// A pointer to an unsigned long value, to render as an unsigned decimal /// integer. - UDec64Kind, + DecULKind, - /// A pointer to a uint64_t value, to render as a signed decimal integer. - SDec64Kind, + /// A pointer to a long value, to render as a signed decimal integer. + DecLKind, + + /// A pointer to an unsigned long long value, to render as an unsigned + /// decimal integer. + DecULLKind, + + /// A pointer to a long long value, to render as a signed decimal integer. + DecLLKind, /// A pointer to a uint64_t value, to render as an unsigned hexadecimal /// integer. @@ -252,23 +259,33 @@ namespace llvm { } /// Construct a twine to print \arg Val as an unsigned decimal integer. - explicit Twine(const uint32_t &Val) - : LHS(&Val), LHSKind(UDec32Kind), RHSKind(EmptyKind) { + explicit Twine(const unsigned int &Val) + : LHS(&Val), LHSKind(DecUIKind), RHSKind(EmptyKind) { } /// Construct a twine to print \arg Val as a signed decimal integer. - explicit Twine(const int32_t &Val) - : LHS(&Val), LHSKind(SDec32Kind), RHSKind(EmptyKind) { + explicit Twine(const int &Val) + : LHS(&Val), LHSKind(DecIKind), RHSKind(EmptyKind) { } /// Construct a twine to print \arg Val as an unsigned decimal integer. - explicit Twine(const uint64_t &Val) - : LHS(&Val), LHSKind(UDec64Kind), RHSKind(EmptyKind) { + explicit Twine(const unsigned long &Val) + : LHS(&Val), LHSKind(DecULKind), RHSKind(EmptyKind) { } /// Construct a twine to print \arg Val as a signed decimal integer. - explicit Twine(const int64_t &Val) - : LHS(&Val), LHSKind(SDec64Kind), RHSKind(EmptyKind) { + explicit Twine(const long &Val) + : LHS(&Val), LHSKind(DecLKind), RHSKind(EmptyKind) { + } + + /// Construct a twine to print \arg Val as an unsigned decimal integer. + explicit Twine(const unsigned long long &Val) + : LHS(&Val), LHSKind(DecULLKind), RHSKind(EmptyKind) { + } + + /// Construct a twine to print \arg Val as a signed decimal integer. + explicit Twine(const long long &Val) + : LHS(&Val), LHSKind(DecLLKind), RHSKind(EmptyKind) { } // FIXME: Unfortunately, to make sure this is as efficient as possible we diff --git a/lib/Support/Twine.cpp b/lib/Support/Twine.cpp index 83a3a6180f3..8b8c0f0db80 100644 --- a/lib/Support/Twine.cpp +++ b/lib/Support/Twine.cpp @@ -47,17 +47,23 @@ void Twine::printOneChild(raw_ostream &OS, const void *Ptr, case Twine::StringRefKind: OS << *static_cast(Ptr); break; - case Twine::UDec32Kind: - OS << *static_cast(Ptr); + case Twine::DecUIKind: + OS << *static_cast(Ptr); break; - case Twine::SDec32Kind: - OS << *static_cast(Ptr); + case Twine::DecIKind: + OS << *static_cast(Ptr); break; - case Twine::UDec64Kind: - OS << *static_cast(Ptr); + case Twine::DecULKind: + OS << *static_cast(Ptr); break; - case Twine::SDec64Kind: - OS << *static_cast(Ptr); + case Twine::DecLKind: + OS << *static_cast(Ptr); + break; + case Twine::DecULLKind: + OS << *static_cast(Ptr); + break; + case Twine::DecLLKind: + OS << *static_cast(Ptr); break; case Twine::UHexKind: OS.write_hex(*static_cast(Ptr)); @@ -88,20 +94,26 @@ void Twine::printOneChildRepr(raw_ostream &OS, const void *Ptr, OS << "stringref:\"" << static_cast(Ptr) << "\""; break; - case Twine::UDec32Kind: - OS << "udec32:" << static_cast(Ptr) << "\""; + case Twine::DecUIKind: + OS << "decUI:\"" << *static_cast(Ptr) << "\""; break; - case Twine::SDec32Kind: - OS << "sdec32:" << static_cast(Ptr) << "\""; + case Twine::DecIKind: + OS << "decI:\"" << *static_cast(Ptr) << "\""; break; - case Twine::UDec64Kind: - OS << "udec64:" << static_cast(Ptr) << "\""; + case Twine::DecULKind: + OS << "decUL:\"" << *static_cast(Ptr) << "\""; break; - case Twine::SDec64Kind: - OS << "sdec64:" << static_cast(Ptr) << "\""; + case Twine::DecLKind: + OS << "decL:\"" << *static_cast(Ptr) << "\""; + break; + case Twine::DecULLKind: + OS << "decULL:\"" << *static_cast(Ptr) << "\""; + break; + case Twine::DecLLKind: + OS << "decLL:\"" << *static_cast(Ptr) << "\""; break; case Twine::UHexKind: - OS << "uhex:" << static_cast(Ptr) << "\""; + OS << "uhex:\"" << static_cast(Ptr) << "\""; break; } }