[llvm] r284428 - Try to fix build after invalid pointer conversion.
Zachary Turner via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 17 14:14:27 PDT 2016
Author: zturner
Date: Mon Oct 17 16:14:27 2016
New Revision: 284428
URL: http://llvm.org/viewvc/llvm-project?rev=284428&view=rev
Log:
Try to fix build after invalid pointer conversion.
Modified:
llvm/trunk/include/llvm/Support/NativeFormatting.h
llvm/trunk/lib/Support/NativeFormatting.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=284428&r1=284427&r2=284428&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/NativeFormatting.h (original)
+++ llvm/trunk/include/llvm/Support/NativeFormatting.h Mon Oct 17 16:14:27 2016
@@ -31,6 +31,8 @@ enum class IntegerStyle {
};
enum class HexStyle { Upper, Lower, PrefixUpper, PrefixLower };
+IntegerStyle hexStyleToIntHexStyle(HexStyle S);
+
size_t getDefaultPrecision(FloatStyle Style);
size_t getDefaultPrecision(IntegerStyle Style);
size_t getDefaultPrecision(HexStyle Style);
Modified: llvm/trunk/lib/Support/NativeFormatting.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/NativeFormatting.cpp?rev=284428&r1=284427&r2=284428&view=diff
==============================================================================
--- llvm/trunk/lib/Support/NativeFormatting.cpp (original)
+++ llvm/trunk/lib/Support/NativeFormatting.cpp Mon Oct 17 16:14:27 2016
@@ -353,6 +353,20 @@ void llvm::write_double(raw_ostream &S,
S << '%';
}
+IntegerStyle llvm::hexStyleToIntHexStyle(HexStyle S) {
+ switch (S) {
+ case HexStyle::Upper:
+ return IntegerStyle::HexUpperNoPrefix;
+ case HexStyle::Lower:
+ return IntegerStyle::HexLowerNoPrefix;
+ case HexStyle::PrefixUpper:
+ return IntegerStyle::HexUpperPrefix;
+ case HexStyle::PrefixLower:
+ return IntegerStyle::HexLowerPrefix;
+ }
+ LLVM_BUILTIN_UNREACHABLE;
+}
+
size_t llvm::getDefaultPrecision(FloatStyle Style) {
switch (Style) {
case FloatStyle::Exponent:
Modified: llvm/trunk/unittests/Support/NativeFormatTests.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Support/NativeFormatTests.cpp?rev=284428&r1=284427&r2=284428&view=diff
==============================================================================
--- llvm/trunk/unittests/Support/NativeFormatTests.cpp (original)
+++ llvm/trunk/unittests/Support/NativeFormatTests.cpp Mon Oct 17 16:14:27 2016
@@ -36,8 +36,8 @@ 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,
Optional<int> Width = None) {
-
- return format_number(reinterpret_cast<uintptr_t>(N), Style, Precision, Width);
+ IntegerStyle IS = hexStyleToIntHexStyle(Style);
+ return format_number(reinterpret_cast<uintptr_t>(N), IS, Precision, Width);
}
std::string format_number(unsigned long N, IntegerStyle Style,
More information about the llvm-commits
mailing list