summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZachary Turner <zturner@google.com>2016-10-17 21:14:27 +0000
committerZachary Turner <zturner@google.com>2016-10-17 21:14:27 +0000
commit47e2c0a9cb03a4cb48af6d772e064037523485e3 (patch)
treedf5448529c693195cfd5b6409086e785168faaea
parent8716b3cbe0f47427f2a99755a1f6093b66a98391 (diff)
downloadbcm5719-llvm-47e2c0a9cb03a4cb48af6d772e064037523485e3.tar.gz
bcm5719-llvm-47e2c0a9cb03a4cb48af6d772e064037523485e3.zip
Try to fix build after invalid pointer conversion.
llvm-svn: 284428
-rw-r--r--llvm/include/llvm/Support/NativeFormatting.h2
-rw-r--r--llvm/lib/Support/NativeFormatting.cpp14
-rw-r--r--llvm/unittests/Support/NativeFormatTests.cpp4
3 files changed, 18 insertions, 2 deletions
diff --git a/llvm/include/llvm/Support/NativeFormatting.h b/llvm/include/llvm/Support/NativeFormatting.h
index f77d3b6ea2c..a4921632a14 100644
--- a/llvm/include/llvm/Support/NativeFormatting.h
+++ b/llvm/include/llvm/Support/NativeFormatting.h
@@ -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);
diff --git a/llvm/lib/Support/NativeFormatting.cpp b/llvm/lib/Support/NativeFormatting.cpp
index bf54cde08b7..27410c18df5 100644
--- a/llvm/lib/Support/NativeFormatting.cpp
+++ b/llvm/lib/Support/NativeFormatting.cpp
@@ -353,6 +353,20 @@ void llvm::write_double(raw_ostream &S, double N, FloatStyle Style,
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:
diff --git a/llvm/unittests/Support/NativeFormatTests.cpp b/llvm/unittests/Support/NativeFormatTests.cpp
index 7d1a67ff350..8475cafd0e2 100644
--- a/llvm/unittests/Support/NativeFormatTests.cpp
+++ b/llvm/unittests/Support/NativeFormatTests.cpp
@@ -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,
OpenPOWER on IntegriCloud