aboutsummaryrefslogtreecommitdiff
path: root/utils/unittest/googletest/include
diff options
context:
space:
mode:
authorJeffrey Yasskin <jyasskin@google.com>2009-09-05 18:16:17 +0000
committerJeffrey Yasskin <jyasskin@google.com>2009-09-05 18:16:17 +0000
commit9c0c3bf1ec2feb861f19867d4091350010b23de6 (patch)
tree3ef93342ed0b85c78f6229093f2902d2cb03de3e /utils/unittest/googletest/include
parent5db3084b6932903e61dac317260fe7b1d7987f2e (diff)
Teach googletest to use raw_ostream instead of just std::ostream.
This can break when there are implicit conversions from types raw_ostream understands but std::ostream doesn't, but it increases the number of cases that Just Work. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@81093 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils/unittest/googletest/include')
-rw-r--r--utils/unittest/googletest/include/gtest/internal/gtest-internal.h22
1 files changed, 21 insertions, 1 deletions
diff --git a/utils/unittest/googletest/include/gtest/internal/gtest-internal.h b/utils/unittest/googletest/include/gtest/internal/gtest-internal.h
index 37faaaebea..242ffea12f 100644
--- a/utils/unittest/googletest/include/gtest/internal/gtest-internal.h
+++ b/utils/unittest/googletest/include/gtest/internal/gtest-internal.h
@@ -56,6 +56,8 @@
#include <gtest/internal/gtest-filepath.h>
#include <gtest/internal/gtest-type-util.h>
+#include "llvm/Support/raw_os_ostream.h"
+
// Due to C++ preprocessor weirdness, we need double indirection to
// concatenate two tokens when one of them is __LINE__. Writing
//
@@ -92,9 +94,27 @@
// ::operator<<;" in the definition of Message's operator<<. That fix
// doesn't require a helper function, but unfortunately doesn't
// compile with MSVC.
+
+// LLVM INTERNAL CHANGE: To allow operator<< to work with both
+// std::ostreams and LLVM's raw_ostreams, we define a special
+// std::ostream with an implicit conversion to raw_ostream& and stream
+// to that. This causes the compiler to prefer std::ostream overloads
+// but still find raw_ostream& overloads.
+namespace llvm {
+class convertible_fwd_ostream : public std::ostream {
+ std::ostream& os_;
+ raw_os_ostream ros_;
+
+public:
+ convertible_fwd_ostream(std::ostream& os)
+ : std::ostream(os.rdbuf()), os_(os), ros_(*this) {}
+ operator raw_ostream&() { return ros_; }
+};
+}
template <typename T>
inline void GTestStreamToHelper(std::ostream* os, const T& val) {
- *os << val;
+ llvm::convertible_fwd_ostream cos(*os);
+ cos << val;
}
namespace testing {