Resubmit "Add support for advanced number formatting."

This resubmits commits 284425 and r284428, which were reverted
in r284429 due to some infinite recursion caused by an incorrect
selection of function overloads.  Reproduced the failure on Linux
using GCC 4.8.4, and confirmed that with the new patch the tests
path on GCC as well as MSVC.  So hopefully this fixes everything.

llvm-svn: 284436
diff --git a/llvm/lib/Support/raw_ostream.cpp b/llvm/lib/Support/raw_ostream.cpp
index 8101bc1..3bf6b93 100644
--- a/llvm/lib/Support/raw_ostream.cpp
+++ b/llvm/lib/Support/raw_ostream.cpp
@@ -114,27 +114,27 @@
 }
 
 raw_ostream &raw_ostream::operator<<(unsigned long N) {
-  write_ulong(*this, N, 0);
+  write_integer(*this, static_cast<uint64_t>(N), IntegerStyle::Integer);
   return *this;
 }
 
 raw_ostream &raw_ostream::operator<<(long N) {
-  write_long(*this, N, 0);
+  write_integer(*this, static_cast<int64_t>(N), IntegerStyle::Integer);
   return *this;
 }
 
 raw_ostream &raw_ostream::operator<<(unsigned long long N) {
-  write_ulonglong(*this, N, 0);
+  write_integer(*this, static_cast<uint64_t>(N), IntegerStyle::Integer);
   return *this;
 }
 
 raw_ostream &raw_ostream::operator<<(long long N) {
-  write_longlong(*this, N, 0);
+  write_integer(*this, static_cast<int64_t>(N), IntegerStyle::Integer);
   return *this;
 }
 
 raw_ostream &raw_ostream::write_hex(unsigned long long N) {
-  llvm::write_hex(*this, N, 0, false, false);
+  llvm::write_hex(*this, N, HexStyle::Lower);
   return *this;
 }
 
@@ -179,12 +179,12 @@
 }
 
 raw_ostream &raw_ostream::operator<<(const void *P) {
-  llvm::write_hex(*this, (uintptr_t)P, 0, false, true);
+  llvm::write_hex(*this, (uintptr_t)P, HexStyle::PrefixLower);
   return *this;
 }
 
 raw_ostream &raw_ostream::operator<<(double N) {
-  llvm::write_double(*this, N, 0, 0, FloatStyle::Exponent);
+  llvm::write_double(*this, N, FloatStyle::Exponent);
   return *this;
 }
 
@@ -331,9 +331,19 @@
 
 raw_ostream &raw_ostream::operator<<(const FormattedNumber &FN) {
   if (FN.Hex) {
-    llvm::write_hex(*this, FN.HexValue, FN.Width, FN.Upper, FN.HexPrefix);
+    HexStyle Style;
+    if (FN.Upper && FN.HexPrefix)
+      Style = HexStyle::PrefixUpper;
+    else if (FN.Upper && !FN.HexPrefix)
+      Style = HexStyle::Upper;
+    else if (!FN.Upper && FN.HexPrefix)
+      Style = HexStyle::PrefixLower;
+    else
+      Style = HexStyle::Lower;
+    llvm::write_hex(*this, FN.HexValue, Style, FN.Width, None);
   } else {
-    llvm::write_longlong(*this, FN.DecValue, FN.Width);
+    llvm::write_integer(*this, FN.DecValue, IntegerStyle::Integer, None,
+                        FN.Width);
   }
   return *this;
 }