Reapply 74494, this time removing the conflicting definition of operator<<
in APIntTest.cpp.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74550 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/llvm/ADT/APInt.h b/include/llvm/ADT/APInt.h
index 63bf4f6..56cd3cc 100644
--- a/include/llvm/ADT/APInt.h
+++ b/include/llvm/ADT/APInt.h
@@ -1426,6 +1426,8 @@
return OS;
}
+std::ostream &operator<<(std::ostream &o, const APInt &I);
+
namespace APIntOps {
/// @brief Determine the smaller of two APInts considered to be signed.
diff --git a/lib/Support/APInt.cpp b/lib/Support/APInt.cpp
index 73bf774..30dc352 100644
--- a/lib/Support/APInt.cpp
+++ b/lib/Support/APInt.cpp
@@ -2178,6 +2178,12 @@
OS << S.c_str();
}
+std::ostream &llvm::operator<<(std::ostream &o, const APInt &I) {
+ raw_os_ostream OS(o);
+ OS << I;
+ return o;
+}
+
// This implements a variety of operations on a representation of
// arbitrary precision, two's-complement, bignum integer values.
diff --git a/unittests/ADT/APIntTest.cpp b/unittests/ADT/APIntTest.cpp
index 8ff7d1d..648faf1 100644
--- a/unittests/ADT/APIntTest.cpp
+++ b/unittests/ADT/APIntTest.cpp
@@ -17,19 +17,6 @@
namespace {
-// Make the Google Test failure output equivalent to APInt::dump()
-std::ostream& operator<<(std::ostream &OS, const llvm::APInt& I) {
- llvm::raw_os_ostream raw_os(OS);
-
- SmallString<40> S, U;
- I.toStringUnsigned(U);
- I.toStringSigned(S);
- raw_os << "APInt(" << I.getBitWidth()<< "b, "
- << U.c_str() << "u " << S.c_str() << "s)";
- raw_os.flush();
- return OS;
-}
-
// Test that APInt shift left works when bitwidth > 64 and shiftamt == 0
TEST(APIntTest, ShiftLeftByZero) {
APInt One = APInt::getNullValue(65) + 1;