[PATCH] D43330: [gtest] Add PrintTo overload for StringRef.

Phabricator via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 26 07:21:54 PST 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rL326092: [gtest] Add PrintTo overload for StringRef. (authored by ibiryukov, committed by ).

Repository:
  rL LLVM

https://reviews.llvm.org/D43330

Files:
  llvm/trunk/utils/unittest/googletest/include/gtest/internal/custom/gtest-printers.h


Index: llvm/trunk/utils/unittest/googletest/include/gtest/internal/custom/gtest-printers.h
===================================================================
--- llvm/trunk/utils/unittest/googletest/include/gtest/internal/custom/gtest-printers.h
+++ llvm/trunk/utils/unittest/googletest/include/gtest/internal/custom/gtest-printers.h
@@ -39,4 +39,17 @@
 #ifndef GTEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_PRINTERS_H_
 #define GTEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_PRINTERS_H_
 
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/raw_os_ostream.h"
+#include <cassert>
+
+namespace llvm {
+// Without this overload StringRef will be printed as a generic container.
+inline void PrintTo(const llvm::StringRef &Val, std::ostream *S) {
+  assert(S);
+  llvm::raw_os_ostream OS(*S);
+  OS << Val;
+}
+} // namespace llvm
+
 #endif  // GTEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_PRINTERS_H_


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D43330.135900.patch
Type: text/x-patch
Size: 893 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180226/eb0dd46e/attachment.bin>


More information about the llvm-commits mailing list