diff options
| author | Fangrui Song <i@maskray.me> | 2022-12-15 09:34:31 +0000 |
|---|---|---|
| committer | Fangrui Song <i@maskray.me> | 2022-12-15 09:34:31 +0000 |
| commit | 8b61376dfa1d67ef2776bcb4a5f92095132ce2fa (patch) | |
| tree | 0554b6ff52462a03c9e04b1b609e492a9349fd97 /llvm | |
| parent | 2d0ca6b68ce246fbc2280e6f9cd5f5f649931b56 (diff) | |
YAMLParser: llvm::Optional => std::optional
Diffstat (limited to 'llvm')
| -rw-r--r-- | llvm/include/llvm/Support/YAMLParser.h | 3 | ||||
| -rw-r--r-- | llvm/lib/Support/YAMLParser.cpp | 2 | ||||
| -rw-r--r-- | llvm/lib/Support/YAMLTraits.cpp | 2 | ||||
| -rw-r--r-- | llvm/unittests/Support/YAMLParserTest.cpp | 2 |
4 files changed, 5 insertions, 4 deletions
diff --git a/llvm/include/llvm/Support/YAMLParser.h b/llvm/include/llvm/Support/YAMLParser.h index 231cc1d28c9a..8c5561e90550 100644 --- a/llvm/include/llvm/Support/YAMLParser.h +++ b/llvm/include/llvm/Support/YAMLParser.h @@ -45,6 +45,7 @@ #include <iterator> #include <map> #include <memory> +#include <optional> #include <string> #include <system_error> @@ -78,7 +79,7 @@ bool scanTokens(StringRef Input); std::string escape(StringRef Input, bool EscapePrintable = true); /// Parse \p S as a bool according to https://yaml.org/type/bool.html. -llvm::Optional<bool> parseBool(StringRef S); +std::optional<bool> parseBool(StringRef S); /// This class represents a YAML stream potentially containing multiple /// documents. diff --git a/llvm/lib/Support/YAMLParser.cpp b/llvm/lib/Support/YAMLParser.cpp index 7dbb16fe88f7..b85b1eb83ef8 100644 --- a/llvm/lib/Support/YAMLParser.cpp +++ b/llvm/lib/Support/YAMLParser.cpp @@ -760,7 +760,7 @@ std::string yaml::escape(StringRef Input, bool EscapePrintable) { return EscapedInput; } -llvm::Optional<bool> yaml::parseBool(StringRef S) { +std::optional<bool> yaml::parseBool(StringRef S) { switch (S.size()) { case 1: switch (S.front()) { diff --git a/llvm/lib/Support/YAMLTraits.cpp b/llvm/lib/Support/YAMLTraits.cpp index 8cdd03149bcf..4eb0b3afd563 100644 --- a/llvm/lib/Support/YAMLTraits.cpp +++ b/llvm/lib/Support/YAMLTraits.cpp @@ -886,7 +886,7 @@ void ScalarTraits<bool>::output(const bool &Val, void *, raw_ostream &Out) { } StringRef ScalarTraits<bool>::input(StringRef Scalar, void *, bool &Val) { - if (llvm::Optional<bool> Parsed = parseBool(Scalar)) { + if (std::optional<bool> Parsed = parseBool(Scalar)) { Val = *Parsed; return StringRef(); } diff --git a/llvm/unittests/Support/YAMLParserTest.cpp b/llvm/unittests/Support/YAMLParserTest.cpp index 14def9c52887..b52a3850c02b 100644 --- a/llvm/unittests/Support/YAMLParserTest.cpp +++ b/llvm/unittests/Support/YAMLParserTest.cpp @@ -343,7 +343,7 @@ TEST(YAMLParser, FlowSequenceTokensOutsideFlowSequence) { } static void expectCanParseBool(StringRef S, bool Expected) { - llvm::Optional<bool> Parsed = yaml::parseBool(S); + std::optional<bool> Parsed = yaml::parseBool(S); EXPECT_TRUE(Parsed.has_value()); EXPECT_EQ(*Parsed, Expected); } |
