diff options
author | Gennadiy Civil <gennadiycivil@users.noreply.github.com> | 2018-01-02 10:54:26 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-01-02 10:54:26 -0500 |
commit | fa6730103ecaad750f42700c55a92c3e212a9271 (patch) | |
tree | 3c9e1638dc96dfe918b73e87d4b389d3bbe5dd86 /googletest/include/gtest/gtest-printers.h | |
parent | ca6a70c6082ff526b993c622d192c6d519800bc2 (diff) | |
parent | 1c2f1907047216654599b0057df49d21a2c1400a (diff) | |
download | googletest-fa6730103ecaad750f42700c55a92c3e212a9271.tar.gz googletest-fa6730103ecaad750f42700c55a92c3e212a9271.tar.bz2 googletest-fa6730103ecaad750f42700c55a92c3e212a9271.zip |
Merge branch 'master' into uintptr
Diffstat (limited to 'googletest/include/gtest/gtest-printers.h')
-rw-r--r-- | googletest/include/gtest/gtest-printers.h | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/googletest/include/gtest/gtest-printers.h b/googletest/include/gtest/gtest-printers.h index c6f69fa1..38c63d25 100644 --- a/googletest/include/gtest/gtest-printers.h +++ b/googletest/include/gtest/gtest-printers.h @@ -137,7 +137,8 @@ class TypeWithoutFormatter { public: // This default version is called when kTypeKind is kOtherType. static void PrintValue(const T& value, ::std::ostream* os) { - PrintBytesInObjectTo(reinterpret_cast<const unsigned char*>(&value), + PrintBytesInObjectTo(static_cast<const unsigned char*>( + reinterpret_cast<const void *>(&value)), sizeof(value), os); } }; @@ -455,15 +456,17 @@ void PrintTo(const T& value, ::std::ostream* os) { // DefaultPrintTo() is overloaded. The type of its first argument // determines which version will be picked. // - // Note that we check for container types here, prior to we check - // for protocol message types in our operator<<. The rationale is: + // Note that we check for recursive and other container types here, prior + // to we check for protocol message types in our operator<<. The rationale is: // // For protocol messages, we want to give people a chance to // override Google Mock's format by defining a PrintTo() or // operator<<. For STL containers, other formats can be // incompatible with Google Mock's format for the container // elements; therefore we check for container types here to ensure - // that our format is used. + // that our format is used. To prevent an infinite runtime recursion + // during the output of recursive container types, we check first for + // those. // // Note that MSVC and clang-cl do allow an implicit conversion from // pointer-to-function to pointer-to-object, but clang-cl warns on it. @@ -472,16 +475,17 @@ void PrintTo(const T& value, ::std::ostream* os) { // function pointers so that the `*os << p` in the object pointer overload // doesn't cause that warning either. DefaultPrintTo( - WrapPrinterType<sizeof(IsContainerTest<T>(0)) == sizeof(IsContainer) - ? kPrintContainer : !is_pointer<T>::value - ? kPrintOther + WrapPrinterType< + (sizeof(IsContainerTest<T>(0)) == sizeof(IsContainer)) && !IsRecursiveContainer<T>::value + ? kPrintContainer : !is_pointer<T>::value + ? kPrintOther #if GTEST_LANG_CXX11 : std::is_function<typename std::remove_pointer<T>::type>::value #else : !internal::ImplicitlyConvertible<T, const void*>::value #endif - ? kPrintFunctionPointer - : kPrintPointer>(), + ? kPrintFunctionPointer + : kPrintPointer>(), value, os); } |