diff --git a/llvm/include/llvm/ADT/Optional.h b/llvm/include/llvm/ADT/Optional.h --- a/llvm/include/llvm/ADT/Optional.h +++ b/llvm/include/llvm/ADT/Optional.h @@ -23,13 +23,10 @@ #include "llvm/Support/type_traits.h" #include #include -#include #include namespace llvm { -class raw_ostream; - namespace optional_detail { /// Storage for any type. @@ -479,28 +476,6 @@ return !(X < Y); } -raw_ostream &operator<<(raw_ostream &OS, std::nullopt_t); - -template () - << std::declval())> -raw_ostream &operator<<(raw_ostream &OS, const Optional &O) { - if (O) - OS << *O; - else - OS << std::nullopt; - return OS; -} - -template () - << std::declval())> -raw_ostream &operator<<(raw_ostream &OS, const std::optional &O) { - if (O) - OS << *O; - else - OS << std::nullopt; - return OS; -} - } // end namespace llvm #endif // LLVM_ADT_OPTIONAL_H diff --git a/llvm/include/llvm/Support/raw_ostream.h b/llvm/include/llvm/Support/raw_ostream.h --- a/llvm/include/llvm/Support/raw_ostream.h +++ b/llvm/include/llvm/Support/raw_ostream.h @@ -13,6 +13,7 @@ #ifndef LLVM_SUPPORT_RAW_OSTREAM_H #define LLVM_SUPPORT_RAW_OSTREAM_H +#include "llvm/ADT/Optional.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringRef.h" #include "llvm/Support/DataTypes.h" @@ -740,6 +741,28 @@ Error writeToOutput(StringRef OutputFileName, std::function Write); +raw_ostream &operator<<(raw_ostream &OS, std::nullopt_t); + +template () + << std::declval())> +raw_ostream &operator<<(raw_ostream &OS, const Optional &O) { + if (O) + OS << *O; + else + OS << std::nullopt; + return OS; +} + +template () + << std::declval())> +raw_ostream &operator<<(raw_ostream &OS, const std::optional &O) { + if (O) + OS << *O; + else + OS << std::nullopt; + return OS; +} + } // end namespace llvm #endif // LLVM_SUPPORT_RAW_OSTREAM_H