diff options
Diffstat (limited to 'llvm/utils/unittest/googletest/include')
-rw-r--r-- | llvm/utils/unittest/googletest/include/gtest/internal/custom/raw-ostream.h | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/llvm/utils/unittest/googletest/include/gtest/internal/custom/raw-ostream.h b/llvm/utils/unittest/googletest/include/gtest/internal/custom/raw-ostream.h index fd993db1602..f4430f8de47 100644 --- a/llvm/utils/unittest/googletest/include/gtest/internal/custom/raw-ostream.h +++ b/llvm/utils/unittest/googletest/include/gtest/internal/custom/raw-ostream.h @@ -42,8 +42,9 @@ auto printable(const T &V) -> decltype(StreamSwitch<T>::printable(V)) { // If raw_ostream support is enabled, we specialize for types with operator<< // that takes a raw_ostream. #if !GTEST_NO_LLVM_RAW_OSTREAM -#include "llvm/Support/raw_ostream.h" +#include "llvm/ADT/Optional.h" #include "llvm/Support/raw_os_ostream.h" +#include "llvm/Support/raw_ostream.h" #include <ostream> namespace llvm_gtest { @@ -68,6 +69,18 @@ struct StreamSwitch<T, decltype((void)(std::declval<llvm::raw_ostream &>() << ConvertibleTo<const T &>()))> { static const RawStreamProxy<T> printable(const T &V) { return {V}; } }; + +// llvm::Optional has a template operator<<, which means it will not accept any +// implicit conversions, so we need to special-case it here. +template <typename T> +struct StreamSwitch<llvm::Optional<T>, + decltype((void)(std::declval<llvm::raw_ostream &>() + << std::declval<llvm::Optional<T>>()))> { + static const RawStreamProxy<llvm::Optional<T>> + printable(const llvm::Optional<T> &V) { + return {V}; + } +}; } // namespace llvm_gtest #endif // !GTEST_NO_LLVM_RAW_OSTREAM |