[llvm-commits] [llvm] r74494 - in /llvm/trunk: include/llvm/ADT/APInt.h lib/Support/APInt.cpp
Dan Gohman
gohman at apple.com
Mon Jun 29 18:28:08 PDT 2009
Author: djg
Date: Mon Jun 29 20:28:08 2009
New Revision: 74494
URL: http://llvm.org/viewvc/llvm-project?rev=74494&view=rev
Log:
Define an operator<< for APInt to be used with std::ostream.
This will allow it to be used in unittests that use gtest's
EXPECT_EQ.
Modified:
llvm/trunk/include/llvm/ADT/APInt.h
llvm/trunk/lib/Support/APInt.cpp
Modified: llvm/trunk/include/llvm/ADT/APInt.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/APInt.h?rev=74494&r1=74493&r2=74494&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ADT/APInt.h (original)
+++ llvm/trunk/include/llvm/ADT/APInt.h Mon Jun 29 20:28:08 2009
@@ -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.
Modified: llvm/trunk/lib/Support/APInt.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/APInt.cpp?rev=74494&r1=74493&r2=74494&view=diff
==============================================================================
--- llvm/trunk/lib/Support/APInt.cpp (original)
+++ llvm/trunk/lib/Support/APInt.cpp Mon Jun 29 20:28:08 2009
@@ -2178,6 +2178,12 @@
OS << S.c_str();
}
+std::ostream &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.
More information about the llvm-commits
mailing list