[llvm] r284437 - Rename HexStyle -> HexFormatStyle, and remove a constexpr.
Zachary Turner via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 17 16:08:48 PDT 2016
Author: zturner
Date: Mon Oct 17 18:08:47 2016
New Revision: 284437
URL: http://llvm.org/viewvc/llvm-project?rev=284437&view=rev
Log:
Rename HexStyle -> HexFormatStyle, and remove a constexpr.
This should fix the remaining broken builds.
Modified:
llvm/trunk/include/llvm/Support/NativeFormatting.h
llvm/trunk/lib/Support/NativeFormatting.cpp
llvm/trunk/lib/Support/raw_ostream.cpp
llvm/trunk/unittests/Support/NativeFormatTests.cpp
Modified: llvm/trunk/include/llvm/Support/NativeFormatting.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/NativeFormatting.h?rev=284437&r1=284436&r2=284437&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/NativeFormatting.h (original)
+++ llvm/trunk/include/llvm/Support/NativeFormatting.h Mon Oct 17 18:08:47 2016
@@ -29,13 +29,13 @@ enum class IntegerStyle {
HexLowerPrefix,
HexLowerNoPrefix
};
-enum class HexStyle { Upper, Lower, PrefixUpper, PrefixLower };
+enum class HexPrintStyle { Upper, Lower, PrefixUpper, PrefixLower };
-IntegerStyle hexStyleToIntHexStyle(HexStyle S);
+IntegerStyle hexStyleToIntHexStyle(HexPrintStyle S);
size_t getDefaultPrecision(FloatStyle Style);
size_t getDefaultPrecision(IntegerStyle Style);
-size_t getDefaultPrecision(HexStyle Style);
+size_t getDefaultPrecision(HexPrintStyle Style);
void write_integer(raw_ostream &S, unsigned int N, IntegerStyle Style,
Optional<size_t> Precision = None,
@@ -56,7 +56,7 @@ void write_integer(raw_ostream &S, long
Optional<size_t> Precision = None,
Optional<int> Width = None);
-void write_hex(raw_ostream &S, uint64_t N, HexStyle Style,
+void write_hex(raw_ostream &S, uint64_t N, HexPrintStyle Style,
Optional<size_t> Precision = None, Optional<int> Width = None);
void write_double(raw_ostream &S, double D, FloatStyle Style,
Optional<size_t> Precision = None,
Modified: llvm/trunk/lib/Support/NativeFormatting.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/NativeFormatting.cpp?rev=284437&r1=284436&r2=284437&view=diff
==============================================================================
--- llvm/trunk/lib/Support/NativeFormatting.cpp (original)
+++ llvm/trunk/lib/Support/NativeFormatting.cpp Mon Oct 17 18:08:47 2016
@@ -29,17 +29,17 @@ static bool isHexStyle(IntegerStyle S) {
LLVM_BUILTIN_UNREACHABLE;
}
-static HexStyle intHexStyleToHexStyle(IntegerStyle S) {
+static HexPrintStyle intHexStyleToHexStyle(IntegerStyle S) {
assert(isHexStyle(S));
switch (S) {
case IntegerStyle::HexLowerNoPrefix:
- return HexStyle::Lower;
+ return HexPrintStyle::Lower;
case IntegerStyle::HexLowerPrefix:
- return HexStyle::PrefixLower;
+ return HexPrintStyle::PrefixLower;
case IntegerStyle::HexUpperNoPrefix:
- return HexStyle::Upper;
+ return HexPrintStyle::Upper;
case IntegerStyle::HexUpperPrefix:
- return HexStyle::PrefixUpper;
+ return HexPrintStyle::PrefixUpper;
default:
break;
}
@@ -234,17 +234,18 @@ void llvm::write_integer(raw_ostream &S,
write_signed(S, N, Style, Precision, Width);
}
-void llvm::write_hex(raw_ostream &S, uint64_t N, HexStyle Style,
+void llvm::write_hex(raw_ostream &S, uint64_t N, HexPrintStyle Style,
Optional<size_t> Precision, Optional<int> Width) {
- constexpr size_t kMaxWidth = 128u;
+ const size_t kMaxWidth = 128u;
size_t Prec =
std::min(kMaxWidth, Precision.getValueOr(getDefaultPrecision(Style)));
unsigned Nibbles = (64 - countLeadingZeros(N) + 3) / 4;
- bool Prefix =
- (Style == HexStyle::PrefixLower || Style == HexStyle::PrefixUpper);
- bool Upper = (Style == HexStyle::Upper || Style == HexStyle::PrefixUpper);
+ bool Prefix = (Style == HexPrintStyle::PrefixLower ||
+ Style == HexPrintStyle::PrefixUpper);
+ bool Upper =
+ (Style == HexPrintStyle::Upper || Style == HexPrintStyle::PrefixUpper);
unsigned PrefixChars = Prefix ? 2 : 0;
unsigned NumChars = std::max(static_cast<unsigned>(Prec),
std::max(1u, Nibbles) + PrefixChars);
@@ -356,15 +357,15 @@ void llvm::write_double(raw_ostream &S,
S << '%';
}
-IntegerStyle llvm::hexStyleToIntHexStyle(HexStyle S) {
+IntegerStyle llvm::hexStyleToIntHexStyle(HexPrintStyle S) {
switch (S) {
- case HexStyle::Upper:
+ case HexPrintStyle::Upper:
return IntegerStyle::HexUpperNoPrefix;
- case HexStyle::Lower:
+ case HexPrintStyle::Lower:
return IntegerStyle::HexLowerNoPrefix;
- case HexStyle::PrefixUpper:
+ case HexPrintStyle::PrefixUpper:
return IntegerStyle::HexUpperPrefix;
- case HexStyle::PrefixLower:
+ case HexPrintStyle::PrefixLower:
return IntegerStyle::HexLowerPrefix;
}
LLVM_BUILTIN_UNREACHABLE;
@@ -403,7 +404,7 @@ size_t llvm::getDefaultPrecision(Integer
LLVM_BUILTIN_UNREACHABLE;
}
-size_t llvm::getDefaultPrecision(HexStyle) {
+size_t llvm::getDefaultPrecision(HexPrintStyle) {
// Number of digits in the resulting string.
return 0;
}
Modified: llvm/trunk/lib/Support/raw_ostream.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/raw_ostream.cpp?rev=284437&r1=284436&r2=284437&view=diff
==============================================================================
--- llvm/trunk/lib/Support/raw_ostream.cpp (original)
+++ llvm/trunk/lib/Support/raw_ostream.cpp Mon Oct 17 18:08:47 2016
@@ -134,7 +134,7 @@ raw_ostream &raw_ostream::operator<<(lon
}
raw_ostream &raw_ostream::write_hex(unsigned long long N) {
- llvm::write_hex(*this, N, HexStyle::Lower);
+ llvm::write_hex(*this, N, HexPrintStyle::Lower);
return *this;
}
@@ -179,7 +179,7 @@ raw_ostream &raw_ostream::write_escaped(
}
raw_ostream &raw_ostream::operator<<(const void *P) {
- llvm::write_hex(*this, (uintptr_t)P, HexStyle::PrefixLower);
+ llvm::write_hex(*this, (uintptr_t)P, HexPrintStyle::PrefixLower);
return *this;
}
@@ -331,15 +331,15 @@ raw_ostream &raw_ostream::operator<<(con
raw_ostream &raw_ostream::operator<<(const FormattedNumber &FN) {
if (FN.Hex) {
- HexStyle Style;
+ HexPrintStyle Style;
if (FN.Upper && FN.HexPrefix)
- Style = HexStyle::PrefixUpper;
+ Style = HexPrintStyle::PrefixUpper;
else if (FN.Upper && !FN.HexPrefix)
- Style = HexStyle::Upper;
+ Style = HexPrintStyle::Upper;
else if (!FN.Upper && FN.HexPrefix)
- Style = HexStyle::PrefixLower;
+ Style = HexPrintStyle::PrefixLower;
else
- Style = HexStyle::Lower;
+ Style = HexPrintStyle::Lower;
llvm::write_hex(*this, FN.HexValue, Style, FN.Width, None);
} else {
llvm::write_integer(*this, FN.DecValue, IntegerStyle::Integer, None,
Modified: llvm/trunk/unittests/Support/NativeFormatTests.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Support/NativeFormatTests.cpp?rev=284437&r1=284436&r2=284437&view=diff
==============================================================================
--- llvm/trunk/unittests/Support/NativeFormatTests.cpp (original)
+++ llvm/trunk/unittests/Support/NativeFormatTests.cpp Mon Oct 17 18:08:47 2016
@@ -31,13 +31,13 @@ std::string format_number(T N, IntegerSt
template <typename T>
typename std::enable_if<std::is_pointer<T>::value, std::string>::type
-format_number(T N, HexStyle Style, Optional<size_t> Precision = None,
+format_number(T N, HexPrintStyle Style, Optional<size_t> Precision = None,
Optional<int> Width = None) {
IntegerStyle IS = hexStyleToIntHexStyle(Style);
return format_number(reinterpret_cast<uintptr_t>(N), IS, Precision, Width);
}
-std::string format_number(uint64_t N, HexStyle Style,
+std::string format_number(uint64_t N, HexPrintStyle Style,
Optional<size_t> Precision = None,
Optional<int> Width = None) {
std::string S;
@@ -104,24 +104,26 @@ TEST(NativeFormatTest, BasicIntegerTests
// Hex formatting. Default precision is 0.
// lower case, prefix.
- EXPECT_EQ("0x0", format_number(0, HexStyle::PrefixLower));
- EXPECT_EQ("0xbeef", format_number(0xbeefLL, HexStyle::PrefixLower));
- EXPECT_EQ("0xdeadbeef", format_number(0xdeadbeefLL, HexStyle::PrefixLower));
+ EXPECT_EQ("0x0", format_number(0, HexPrintStyle::PrefixLower));
+ EXPECT_EQ("0xbeef", format_number(0xbeefLL, HexPrintStyle::PrefixLower));
+ EXPECT_EQ("0xdeadbeef",
+ format_number(0xdeadbeefLL, HexPrintStyle::PrefixLower));
// upper-case, prefix.
- EXPECT_EQ("0x0", format_number(0, HexStyle::PrefixUpper));
- EXPECT_EQ("0xBEEF", format_number(0xbeefLL, HexStyle::PrefixUpper));
- EXPECT_EQ("0xDEADBEEF", format_number(0xdeadbeefLL, HexStyle::PrefixUpper));
+ EXPECT_EQ("0x0", format_number(0, HexPrintStyle::PrefixUpper));
+ EXPECT_EQ("0xBEEF", format_number(0xbeefLL, HexPrintStyle::PrefixUpper));
+ EXPECT_EQ("0xDEADBEEF",
+ format_number(0xdeadbeefLL, HexPrintStyle::PrefixUpper));
// lower-case, no prefix
- EXPECT_EQ("0", format_number(0, HexStyle::Lower));
- EXPECT_EQ("beef", format_number(0xbeefLL, HexStyle::Lower));
- EXPECT_EQ("deadbeef", format_number(0xdeadbeefLL, HexStyle::Lower));
+ EXPECT_EQ("0", format_number(0, HexPrintStyle::Lower));
+ EXPECT_EQ("beef", format_number(0xbeefLL, HexPrintStyle::Lower));
+ EXPECT_EQ("deadbeef", format_number(0xdeadbeefLL, HexPrintStyle::Lower));
// upper-case, no prefix.
- EXPECT_EQ("0", format_number(0, HexStyle::Upper));
- EXPECT_EQ("BEEF", format_number(0xbeef, HexStyle::Upper));
- EXPECT_EQ("DEADBEEF", format_number(0xdeadbeef, HexStyle::Upper));
+ EXPECT_EQ("0", format_number(0, HexPrintStyle::Upper));
+ EXPECT_EQ("BEEF", format_number(0xbeef, HexPrintStyle::Upper));
+ EXPECT_EQ("DEADBEEF", format_number(0xdeadbeef, HexPrintStyle::Upper));
EXPECT_EQ("0xFFFFFFFF", format_number(-1, IntegerStyle::HexUpperPrefix));
}
@@ -130,26 +132,30 @@ TEST(NativeFormatTest, BasicIntegerTests
// precision.
TEST(NativeFormatTest, BasicPointerTests) {
// lower-case, prefix
- EXPECT_EQ("0x0", format_number((void *)nullptr, HexStyle::PrefixLower));
- EXPECT_EQ("0xbeef", format_number((void *)0xbeefLL, HexStyle::PrefixLower));
+ EXPECT_EQ("0x0", format_number((void *)nullptr, HexPrintStyle::PrefixLower));
+ EXPECT_EQ("0xbeef",
+ format_number((void *)0xbeefLL, HexPrintStyle::PrefixLower));
EXPECT_EQ("0xdeadbeef",
- format_number((void *)0xdeadbeefLL, HexStyle::PrefixLower));
+ format_number((void *)0xdeadbeefLL, HexPrintStyle::PrefixLower));
// upper-case, prefix.
- EXPECT_EQ("0x0", format_number((void *)nullptr, HexStyle::PrefixUpper));
- EXPECT_EQ("0xBEEF", format_number((void *)0xbeefLL, HexStyle::PrefixUpper));
+ EXPECT_EQ("0x0", format_number((void *)nullptr, HexPrintStyle::PrefixUpper));
+ EXPECT_EQ("0xBEEF",
+ format_number((void *)0xbeefLL, HexPrintStyle::PrefixUpper));
EXPECT_EQ("0xDEADBEEF",
- format_number((void *)0xdeadbeefLL, HexStyle::PrefixUpper));
+ format_number((void *)0xdeadbeefLL, HexPrintStyle::PrefixUpper));
// lower-case, no prefix
- EXPECT_EQ("0", format_number((void *)nullptr, HexStyle::Lower));
- EXPECT_EQ("beef", format_number((void *)0xbeefLL, HexStyle::Lower));
- EXPECT_EQ("deadbeef", format_number((void *)0xdeadbeefLL, HexStyle::Lower));
+ EXPECT_EQ("0", format_number((void *)nullptr, HexPrintStyle::Lower));
+ EXPECT_EQ("beef", format_number((void *)0xbeefLL, HexPrintStyle::Lower));
+ EXPECT_EQ("deadbeef",
+ format_number((void *)0xdeadbeefLL, HexPrintStyle::Lower));
// upper-case, no prefix.
- EXPECT_EQ("0", format_number((void *)nullptr, HexStyle::Upper));
- EXPECT_EQ("BEEF", format_number((void *)0xbeefLL, HexStyle::Upper));
- EXPECT_EQ("DEADBEEF", format_number((void *)0xdeadbeefLL, HexStyle::Upper));
+ EXPECT_EQ("0", format_number((void *)nullptr, HexPrintStyle::Upper));
+ EXPECT_EQ("BEEF", format_number((void *)0xbeefLL, HexPrintStyle::Upper));
+ EXPECT_EQ("DEADBEEF",
+ format_number((void *)0xdeadbeefLL, HexPrintStyle::Upper));
}
// Test basic floating point formatting with various styles and default width
@@ -229,7 +235,7 @@ TEST(NativeFormatTest, HexTests) {
// And with pointers.
EXPECT_EQ(" 0x000",
- format_number((void *)nullptr, HexStyle::PrefixLower, 5, 7));
+ format_number((void *)nullptr, HexPrintStyle::PrefixLower, 5, 7));
// Try printing more digits than can fit in a uint64.
EXPECT_EQ(" 0x000abcde",
More information about the llvm-commits
mailing list