Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 12 additions & 16 deletions llvm/include/llvm/ADT/Twine.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,11 +150,11 @@ class Twine {
char character;
unsigned int decUI;
int decI;
const unsigned long *decUL;
const long *decL;
const unsigned long long *decULL;
const long long *decLL;
const uint64_t *uHex;
unsigned long decUL;
long decL;
unsigned long long decULL;
long long decLL;
uint64_t uHex;
};

/// LHS - The prefix in the concatenation, which may be uninitialized for
Expand Down Expand Up @@ -336,22 +336,18 @@ class Twine {
explicit Twine(int Val) : LHSKind(DecIKind) { LHS.decI = Val; }

/// Construct a twine to print \p Val as an unsigned decimal integer.
explicit Twine(const unsigned long &Val) : LHSKind(DecULKind) {
LHS.decUL = &Val;
}
explicit Twine(unsigned long Val) : LHSKind(DecULKind) { LHS.decUL = Val; }

/// Construct a twine to print \p Val as a signed decimal integer.
explicit Twine(const long &Val) : LHSKind(DecLKind) { LHS.decL = &Val; }
explicit Twine(long Val) : LHSKind(DecLKind) { LHS.decL = Val; }

/// Construct a twine to print \p Val as an unsigned decimal integer.
explicit Twine(const unsigned long long &Val) : LHSKind(DecULLKind) {
LHS.decULL = &Val;
explicit Twine(unsigned long long Val) : LHSKind(DecULLKind) {
LHS.decULL = Val;
}

/// Construct a twine to print \p Val as a signed decimal integer.
explicit Twine(const long long &Val) : LHSKind(DecLLKind) {
LHS.decLL = &Val;
}
explicit Twine(long long Val) : LHSKind(DecLLKind) { LHS.decLL = Val; }

// FIXME: Unfortunately, to make sure this is as efficient as possible we
// need extra binary constructors from particular types. We can't rely on
Expand Down Expand Up @@ -389,9 +385,9 @@ class Twine {
/// @{

// Construct a twine to print \p Val as an unsigned hexadecimal integer.
static Twine utohexstr(const uint64_t &Val) {
static Twine utohexstr(uint64_t Val) {
Child LHS, RHS;
LHS.uHex = &Val;
LHS.uHex = Val;
RHS.twine = nullptr;
return Twine(LHS, UHexKind, RHS, EmptyKind);
}
Expand Down
18 changes: 9 additions & 9 deletions llvm/lib/Support/Twine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,19 +88,19 @@ void Twine::printOneChild(raw_ostream &OS, Child Ptr, NodeKind Kind) const {
OS << Ptr.decI;
break;
case Twine::DecULKind:
OS << *Ptr.decUL;
OS << Ptr.decUL;
break;
case Twine::DecLKind:
OS << *Ptr.decL;
OS << Ptr.decL;
break;
case Twine::DecULLKind:
OS << *Ptr.decULL;
OS << Ptr.decULL;
break;
case Twine::DecLLKind:
OS << *Ptr.decLL;
OS << Ptr.decLL;
break;
case Twine::UHexKind:
OS.write_hex(*Ptr.uHex);
OS.write_hex(Ptr.uHex);
break;
}
}
Expand Down Expand Up @@ -144,16 +144,16 @@ void Twine::printOneChildRepr(raw_ostream &OS, Child Ptr, NodeKind Kind) const {
OS << "decI:\"" << Ptr.decI << "\"";
break;
case Twine::DecULKind:
OS << "decUL:\"" << *Ptr.decUL << "\"";
OS << "decUL:\"" << Ptr.decUL << "\"";
break;
case Twine::DecLKind:
OS << "decL:\"" << *Ptr.decL << "\"";
OS << "decL:\"" << Ptr.decL << "\"";
break;
case Twine::DecULLKind:
OS << "decULL:\"" << *Ptr.decULL << "\"";
OS << "decULL:\"" << Ptr.decULL << "\"";
break;
case Twine::DecLLKind:
OS << "decLL:\"" << *Ptr.decLL << "\"";
OS << "decLL:\"" << Ptr.decLL << "\"";
break;
case Twine::UHexKind:
OS << "uhex:\"" << Ptr.uHex << "\"";
Expand Down