diff --git a/clang-tools-extra/clang-tidy/ClangTidyOptions.h b/clang-tools-extra/clang-tidy/ClangTidyOptions.h index 6102399d9d3875..727c533335c3ed 100644 --- a/clang-tools-extra/clang-tidy/ClangTidyOptions.h +++ b/clang-tools-extra/clang-tidy/ClangTidyOptions.h @@ -10,7 +10,6 @@ #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CLANGTIDYOPTIONS_H #include "llvm/ADT/IntrusiveRefCntPtr.h" -#include "llvm/ADT/Optional.h" #include "llvm/ADT/StringMap.h" #include "llvm/ADT/StringRef.h" #include "llvm/Support/ErrorOr.h" @@ -232,7 +231,7 @@ class FileOptionsBaseProvider : public DefaultOptionsProvider { /// Try to read configuration files from \p Directory using registered /// \c ConfigHandlers. - llvm::Optional tryReadConfigFile(llvm::StringRef Directory); + std::optional tryReadConfigFile(llvm::StringRef Directory); llvm::StringMap CachedOptions; ClangTidyOptions OverrideOptions; diff --git a/clang-tools-extra/clang-tidy/ClangTidyProfiling.cpp b/clang-tools-extra/clang-tidy/ClangTidyProfiling.cpp index 6c5d86a69821b4..3a03dc033f802e 100644 --- a/clang-tools-extra/clang-tidy/ClangTidyProfiling.cpp +++ b/clang-tools-extra/clang-tidy/ClangTidyProfiling.cpp @@ -11,6 +11,7 @@ #include "llvm/Support/FileSystem.h" #include "llvm/Support/Path.h" #include "llvm/Support/raw_ostream.h" +#include #include #include @@ -74,7 +75,7 @@ void ClangTidyProfiling::storeProfileData() { printAsJSON(OS); } -ClangTidyProfiling::ClangTidyProfiling(llvm::Optional Storage) +ClangTidyProfiling::ClangTidyProfiling(std::optional Storage) : Storage(std::move(Storage)) {} ClangTidyProfiling::~ClangTidyProfiling() { diff --git a/clang-tools-extra/clang-tidy/ClangTidyProfiling.h b/clang-tools-extra/clang-tidy/ClangTidyProfiling.h index 9487a34620e0a6..bf21659a502fb5 100644 --- a/clang-tools-extra/clang-tidy/ClangTidyProfiling.h +++ b/clang-tools-extra/clang-tidy/ClangTidyProfiling.h @@ -9,10 +9,10 @@ #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CLANGTIDYPROFILING_H #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CLANGTIDYPROFILING_H -#include "llvm/ADT/Optional.h" #include "llvm/ADT/StringMap.h" #include "llvm/Support/Chrono.h" #include "llvm/Support/Timer.h" +#include #include namespace llvm { @@ -35,9 +35,9 @@ class ClangTidyProfiling { }; private: - llvm::Optional TG; + std::optional TG; - llvm::Optional Storage; + std::optional Storage; void printUserFriendlyTable(llvm::raw_ostream &OS); void printAsJSON(llvm::raw_ostream &OS); @@ -49,7 +49,7 @@ class ClangTidyProfiling { ClangTidyProfiling() = default; - ClangTidyProfiling(llvm::Optional Storage); + ClangTidyProfiling(std::optional Storage); ~ClangTidyProfiling(); }; diff --git a/clang-tools-extra/clangd/ConfigFragment.h b/clang-tools-extra/clangd/ConfigFragment.h index 98923b516752b2..bcd1a05b4a999c 100644 --- a/clang-tools-extra/clangd/ConfigFragment.h +++ b/clang-tools-extra/clangd/ConfigFragment.h @@ -33,9 +33,9 @@ #define LLVM_CLANG_TOOLS_EXTRA_CLANGD_CONFIGFRAGMENT_H #include "ConfigProvider.h" -#include "llvm/ADT/Optional.h" #include "llvm/Support/SMLoc.h" #include "llvm/Support/SourceMgr.h" +#include #include #include @@ -140,7 +140,7 @@ struct Fragment { /// /// (That this simply replaces argv[0], and may mangle commands that use /// more complicated drivers like ccache). - llvm::Optional> Compiler; + std::optional> Compiler; /// List of flags to append to the compile command. std::vector> Add; @@ -168,7 +168,7 @@ struct Fragment { /// - A single path to a directory (absolute, or relative to the fragment) /// - Ancestors: search all parent directories (the default) /// - None: do not use a compilation database, just default flags. - llvm::Optional> CompilationDatabase; + std::optional> CompilationDatabase; }; CompileFlagsBlock CompileFlags; @@ -179,7 +179,7 @@ struct Fragment { /// Whether files are built in the background to produce a project index. /// This is checked for translation units only, not headers they include. /// Legal values are "Build" or "Skip". - llvm::Optional> Background; + std::optional> Background; /// An external index uses data source outside of clangd itself. This is /// usually prepared using clangd-indexer. /// Exactly one source (File/Server) should be configured. @@ -189,19 +189,19 @@ struct Fragment { Located IsNone = false; /// Path to an index file generated by clangd-indexer. Relative paths may /// be used, if config fragment is associated with a directory. - llvm::Optional> File; + std::optional> File; /// Address and port number for a clangd-index-server. e.g. /// `123.1.1.1:13337`. - llvm::Optional> Server; + std::optional> Server; /// Source root governed by this index. Default is the directory /// associated with the config fragment. Absolute in case of user config /// and relative otherwise. Should always use forward-slashes. - llvm::Optional> MountPoint; + std::optional> MountPoint; }; - llvm::Optional> External; + std::optional> External; // Whether the standard library visible from this file should be indexed. // This makes all standard library symbols available, included or not. - llvm::Optional> StandardLibrary; + std::optional> StandardLibrary; }; IndexBlock Index; @@ -233,7 +233,7 @@ struct Fragment { /// Valid values are: /// - Strict /// - None - llvm::Optional> UnusedIncludes; + std::optional> UnusedIncludes; /// Controls IncludeCleaner diagnostics. struct IncludesBlock { @@ -283,28 +283,28 @@ struct Fragment { struct CompletionBlock { /// Whether code completion should include suggestions from scopes that are /// not visible. The required scope prefix will be inserted. - llvm::Optional> AllScopes; + std::optional> AllScopes; }; CompletionBlock Completion; /// Describes hover preferences. struct HoverBlock { /// Whether hover show a.k.a type. - llvm::Optional> ShowAKA; + std::optional> ShowAKA; }; HoverBlock Hover; /// Configures labels shown inline with the code. struct InlayHintsBlock { /// Enables/disables the inlay-hints feature. - llvm::Optional> Enabled; + std::optional> Enabled; /// Show parameter names before function arguments. - llvm::Optional> ParameterNames; + std::optional> ParameterNames; /// Show deduced types for `auto`. - llvm::Optional> DeducedTypes; + std::optional> DeducedTypes; /// Show designators in aggregate initialization. - llvm::Optional> Designators; + std::optional> Designators; }; InlayHintsBlock InlayHints; }; diff --git a/clang-tools-extra/clangd/ConfigProvider.cpp b/clang-tools-extra/clangd/ConfigProvider.cpp index c3f48ac44d14cd..ac437ee8b6eb16 100644 --- a/clang-tools-extra/clangd/ConfigProvider.cpp +++ b/clang-tools-extra/clangd/ConfigProvider.cpp @@ -19,6 +19,7 @@ #include "llvm/Support/Path.h" #include #include +#include #include namespace clang { @@ -39,7 +40,7 @@ class FileConfigCache : public FileCache { std::vector &Out) const { read( TFS, FreshTime, - [&](llvm::Optional Data) { + [&](std::optional Data) { CachedValue.clear(); if (Data) for (auto &Fragment : Fragment::parseYAML(*Data, path(), DC)) { diff --git a/clang-tools-extra/clangd/ConfigYAML.cpp b/clang-tools-extra/clangd/ConfigYAML.cpp index 320f15846e8542..ee91753dd88dd0 100644 --- a/clang-tools-extra/clangd/ConfigYAML.cpp +++ b/clang-tools-extra/clangd/ConfigYAML.cpp @@ -6,13 +6,13 @@ // //===----------------------------------------------------------------------===// #include "ConfigFragment.h" -#include "llvm/ADT/Optional.h" #include "llvm/ADT/SmallSet.h" #include "llvm/ADT/SmallString.h" #include "llvm/ADT/StringRef.h" #include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/SourceMgr.h" #include "llvm/Support/YAMLParser.h" +#include #include #include @@ -26,13 +26,13 @@ using llvm::yaml::Node; using llvm::yaml::ScalarNode; using llvm::yaml::SequenceNode; -llvm::Optional +std::optional bestGuess(llvm::StringRef Search, llvm::ArrayRef AllowedValues) { unsigned MaxEdit = (Search.size() + 1) / 3; if (!MaxEdit) return std::nullopt; - llvm::Optional Result; + std::optional Result; for (const auto &AllowedValue : AllowedValues) { unsigned EditDistance = Search.edit_distance(AllowedValue, true, MaxEdit); // We can't do better than an edit distance of 1, so just return this and @@ -349,8 +349,8 @@ class Parser { }; // Try to parse a single scalar value from the node, warn on failure. - llvm::Optional> scalarValue(Node &N, - llvm::StringRef Desc) { + std::optional> scalarValue(Node &N, + llvm::StringRef Desc) { llvm::SmallString<256> Buf; if (auto *S = llvm::dyn_cast(&N)) return Located(S->getValue(Buf).str(), N.getSourceRange()); @@ -360,7 +360,7 @@ class Parser { return std::nullopt; } - llvm::Optional> boolValue(Node &N, llvm::StringRef Desc) { + std::optional> boolValue(Node &N, llvm::StringRef Desc) { if (auto Scalar = scalarValue(N, Desc)) { if (auto Bool = llvm::yaml::parseBool(**Scalar)) return Located(*Bool, Scalar->Range); @@ -370,7 +370,7 @@ class Parser { } // Try to parse a list of single scalar values, or just a single value. - llvm::Optional>> scalarValues(Node &N) { + std::optional>> scalarValues(Node &N) { std::vector> Result; if (auto *S = llvm::dyn_cast(&N)) { llvm::SmallString<256> Buf; diff --git a/clang-tools-extra/clangd/FuzzyMatch.cpp b/clang-tools-extra/clangd/FuzzyMatch.cpp index 0e57de7219b03b..82b8ad0f9527db 100644 --- a/clang-tools-extra/clangd/FuzzyMatch.cpp +++ b/clang-tools-extra/clangd/FuzzyMatch.cpp @@ -56,8 +56,8 @@ //===----------------------------------------------------------------------===// #include "FuzzyMatch.h" -#include "llvm/ADT/Optional.h" #include "llvm/Support/Format.h" +#include namespace clang { namespace clangd { @@ -89,7 +89,7 @@ FuzzyMatcher::FuzzyMatcher(llvm::StringRef Pattern) llvm::makeMutableArrayRef(PatRole, PatN)); } -llvm::Optional FuzzyMatcher::match(llvm::StringRef Word) { +std::optional FuzzyMatcher::match(llvm::StringRef Word) { if (!(WordContainsPattern = init(Word))) return std::nullopt; if (!PatN) diff --git a/clang-tools-extra/clangd/FuzzyMatch.h b/clang-tools-extra/clangd/FuzzyMatch.h index 81c2edb820eb86..a8621d6ec65454 100644 --- a/clang-tools-extra/clangd/FuzzyMatch.h +++ b/clang-tools-extra/clangd/FuzzyMatch.h @@ -16,10 +16,10 @@ #define LLVM_CLANG_TOOLS_EXTRA_CLANGD_FUZZYMATCH_H #include "llvm/ADT/ArrayRef.h" -#include "llvm/ADT/Optional.h" #include "llvm/ADT/SmallString.h" #include "llvm/ADT/StringRef.h" #include "llvm/Support/raw_ostream.h" +#include namespace clang { namespace clangd { @@ -77,7 +77,7 @@ class FuzzyMatcher { // Scores usually fall in a [0,1] range, with 1 being a very good score. // "Super" scores in (1,2] are possible if the pattern is the full word. // Characters beyond MaxWord are ignored. - llvm::Optional match(llvm::StringRef Word); + std::optional match(llvm::StringRef Word); llvm::StringRef pattern() const { return llvm::StringRef(Pat, PatN); } bool empty() const { return PatN == 0; } diff --git a/clang-tools-extra/clangd/PathMapping.cpp b/clang-tools-extra/clangd/PathMapping.cpp index 01d3fab5ad33e1..2554d34d96b9df 100644 --- a/clang-tools-extra/clangd/PathMapping.cpp +++ b/clang-tools-extra/clangd/PathMapping.cpp @@ -12,13 +12,14 @@ #include "llvm/Support/Error.h" #include "llvm/Support/Path.h" #include +#include #include namespace clang { namespace clangd { -llvm::Optional doPathMapping(llvm::StringRef S, - PathMapping::Direction Dir, - const PathMappings &Mappings) { +std::optional doPathMapping(llvm::StringRef S, + PathMapping::Direction Dir, + const PathMappings &Mappings) { // Return early to optimize for the common case, wherein S is not a file URI if (!S.startswith("file://")) return std::nullopt; @@ -53,7 +54,7 @@ void applyPathMappings(llvm::json::Value &V, PathMapping::Direction Dir, llvm::json::Object MappedObj; // 1. Map all the Keys for (auto &KV : *Obj) { - if (llvm::Optional MappedKey = + if (std::optional MappedKey = doPathMapping(KV.first.str(), Dir, Mappings)) { MappedObj.try_emplace(std::move(*MappedKey), std::move(KV.second)); } else { @@ -68,7 +69,7 @@ void applyPathMappings(llvm::json::Value &V, PathMapping::Direction Dir, for (llvm::json::Value &Val : *V.getAsArray()) applyPathMappings(Val, Dir, Mappings); } else if (K == Kind::String) { - if (llvm::Optional Mapped = + if (std::optional Mapped = doPathMapping(*V.getAsString(), Dir, Mappings)) V = std::move(*Mapped); } diff --git a/clang-tools-extra/clangd/PathMapping.h b/clang-tools-extra/clangd/PathMapping.h index 58e42261732ed5..1893753392fc39 100644 --- a/clang-tools-extra/clangd/PathMapping.h +++ b/clang-tools-extra/clangd/PathMapping.h @@ -9,12 +9,12 @@ #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_PATHMAPPING_H #define LLVM_CLANG_TOOLS_EXTRA_CLANGD_PATHMAPPING_H -#include "llvm/ADT/Optional.h" #include "llvm/ADT/StringRef.h" #include "llvm/Support/Error.h" #include "llvm/Support/JSON.h" #include "llvm/Support/raw_ostream.h" #include +#include #include #include @@ -50,9 +50,9 @@ llvm::Expected parsePathMappings(llvm::StringRef RawPathMappings); /// Returns a modified \p S with the first matching path in \p Mappings /// substituted, if applicable -llvm::Optional doPathMapping(llvm::StringRef S, - PathMapping::Direction Dir, - const PathMappings &Mappings); +std::optional doPathMapping(llvm::StringRef S, + PathMapping::Direction Dir, + const PathMappings &Mappings); /// Applies the \p Mappings to all the file:// URIs in \p Params. /// NOTE: The first matching mapping will be applied, otherwise \p Params will diff --git a/clang-tools-extra/clangd/TidyProvider.cpp b/clang-tools-extra/clangd/TidyProvider.cpp index 936b1ce3edabaa..4adc5345c6d9f5 100644 --- a/clang-tools-extra/clangd/TidyProvider.cpp +++ b/clang-tools-extra/clangd/TidyProvider.cpp @@ -42,7 +42,7 @@ class DotClangTidyCache : private FileCache { std::shared_ptr Result; read( TFS, FreshTime, - [this](llvm::Optional Data) { + [this](std::optional Data) { Value.reset(); if (Data && !Data->empty()) { tidy::DiagCallback Diagnostics = [](const llvm::SMDiagnostic &D) { diff --git a/clang-tools-extra/clangd/index/dex/PostingList.cpp b/clang-tools-extra/clangd/index/dex/PostingList.cpp index 06511cfb43bd53..c02d52734972b5 100644 --- a/clang-tools-extra/clangd/index/dex/PostingList.cpp +++ b/clang-tools-extra/clangd/index/dex/PostingList.cpp @@ -10,6 +10,7 @@ #include "index/dex/Iterator.h" #include "index/dex/Token.h" #include "llvm/Support/MathExtras.h" +#include namespace clang { namespace clangd { @@ -182,7 +183,7 @@ std::vector encodeStream(llvm::ArrayRef Documents) { /// Reads variable length DocID from the buffer and updates the buffer size. If /// the stream is terminated, return std::nullopt. -llvm::Optional readVByte(llvm::ArrayRef &Bytes) { +std::optional readVByte(llvm::ArrayRef &Bytes) { if (Bytes.front() == 0 || Bytes.empty()) return std::nullopt; DocID Result = 0; diff --git a/clang-tools-extra/clangd/support/FileCache.cpp b/clang-tools-extra/clangd/support/FileCache.cpp index 36804113a9bbe7..cc59c648b062a1 100644 --- a/clang-tools-extra/clangd/support/FileCache.cpp +++ b/clang-tools-extra/clangd/support/FileCache.cpp @@ -8,6 +8,7 @@ #include "support/FileCache.h" #include "llvm/ADT/ScopeExit.h" +#include namespace clang { namespace clangd { @@ -29,7 +30,7 @@ FileCache::FileCache(llvm::StringRef Path) void FileCache::read( const ThreadsafeFS &TFS, std::chrono::steady_clock::time_point FreshTime, - llvm::function_ref)> Parse, + llvm::function_ref)> Parse, llvm::function_ref Read) const { std::lock_guard Lock(Mu); diff --git a/clang-tools-extra/clangd/support/FileCache.h b/clang-tools-extra/clangd/support/FileCache.h index 7e28f5b3e46327..edb34985283224 100644 --- a/clang-tools-extra/clangd/support/FileCache.h +++ b/clang-tools-extra/clangd/support/FileCache.h @@ -13,6 +13,7 @@ #include "ThreadsafeFS.h" #include "llvm/Support/Chrono.h" #include +#include namespace clang { namespace clangd { @@ -56,7 +57,7 @@ class FileCache { // - steady_clock::now() + seconds(1) means we accept 1 second of staleness void read(const ThreadsafeFS &TFS, std::chrono::steady_clock::time_point FreshTime, - llvm::function_ref)> Parse, + llvm::function_ref)> Parse, llvm::function_ref Read) const; PathRef path() const { return Path; } diff --git a/clang-tools-extra/clangd/support/Threading.cpp b/clang-tools-extra/clangd/support/Threading.cpp index be0d84cae3debd..f42db89b483c0a 100644 --- a/clang-tools-extra/clangd/support/Threading.cpp +++ b/clang-tools-extra/clangd/support/Threading.cpp @@ -12,6 +12,7 @@ #include "llvm/Support/Threading.h" #include "llvm/Support/thread.h" #include +#include #include #ifdef __USE_POSIX #include @@ -109,7 +110,7 @@ void AsyncTaskRunner::runAsync(const llvm::Twine &Name, Thread.detach(); } -Deadline timeoutSeconds(llvm::Optional Seconds) { +Deadline timeoutSeconds(std::optional Seconds) { using namespace std::chrono; if (!Seconds) return Deadline::infinity(); diff --git a/clang-tools-extra/clangd/support/Threading.h b/clang-tools-extra/clangd/support/Threading.h index fb9f6202b07130..1be27820513e5f 100644 --- a/clang-tools-extra/clangd/support/Threading.h +++ b/clang-tools-extra/clangd/support/Threading.h @@ -18,6 +18,7 @@ #include #include #include +#include #include #include @@ -70,7 +71,7 @@ class Deadline { }; /// Makes a deadline from a timeout in seconds. None means wait forever. -Deadline timeoutSeconds(llvm::Optional Seconds); +Deadline timeoutSeconds(std::optional Seconds); /// Wait once on CV for the specified duration. void wait(std::unique_lock &Lock, std::condition_variable &CV, Deadline D); diff --git a/clang-tools-extra/clangd/support/Trace.cpp b/clang-tools-extra/clangd/support/Trace.cpp index a2bf2dc5103dea..419c2eee99ec84 100644 --- a/clang-tools-extra/clangd/support/Trace.cpp +++ b/clang-tools-extra/clangd/support/Trace.cpp @@ -9,7 +9,6 @@ #include "support/Trace.h" #include "support/Context.h" #include "llvm/ADT/DenseSet.h" -#include "llvm/ADT/Optional.h" #include "llvm/ADT/ScopeExit.h" #include "llvm/ADT/StringRef.h" #include "llvm/Support/Chrono.h" @@ -19,6 +18,7 @@ #include #include #include +#include namespace clang { namespace clangd { @@ -287,7 +287,7 @@ static std::pair makeSpanContext(llvm::Twine Name, const Metric &LatencyMetric) { if (!T) return std::make_pair(Context::current().clone(), nullptr); - llvm::Optional WithLatency; + std::optional WithLatency; using Clock = std::chrono::high_resolution_clock; WithLatency.emplace(llvm::make_scope_exit( [StartTime = Clock::now(), Name = Name.str(), &LatencyMetric] { diff --git a/clang-tools-extra/clangd/unittests/FuzzyMatchTests.cpp b/clang-tools-extra/clangd/unittests/FuzzyMatchTests.cpp index 683b9a30e9f9eb..9cb668cb7cb166 100644 --- a/clang-tools-extra/clangd/unittests/FuzzyMatchTests.cpp +++ b/clang-tools-extra/clangd/unittests/FuzzyMatchTests.cpp @@ -10,6 +10,7 @@ #include "gmock/gmock.h" #include "gtest/gtest.h" +#include namespace clang { namespace clangd { @@ -39,13 +40,13 @@ struct ExpectedMatch { std::string Word; private: - llvm::Optional Annotated; + std::optional Annotated; }; struct MatchesMatcher : public ::testing::MatcherInterface { ExpectedMatch Candidate; - llvm::Optional Score; - MatchesMatcher(ExpectedMatch Candidate, llvm::Optional Score) + std::optional Score; + MatchesMatcher(ExpectedMatch Candidate, std::optional Score) : Candidate(std::move(Candidate)), Score(Score) {} void DescribeTo(::std::ostream *OS) const override { @@ -71,7 +72,7 @@ struct MatchesMatcher : public ::testing::MatcherInterface { // Accepts patterns that match a given word, optionally requiring a score. // Dumps the debug tables on match failure. ::testing::Matcher matches(llvm::StringRef M, - llvm::Optional Score = {}) { + std::optional Score = {}) { return ::testing::MakeMatcher(new MatchesMatcher(M, Score)); } @@ -199,7 +200,7 @@ struct RankMatcher : public ::testing::MatcherInterface { : new llvm::raw_null_ostream()); FuzzyMatcher Matcher(Pattern); const ExpectedMatch *LastMatch; - llvm::Optional LastScore; + std::optional LastScore; bool Ok = true; for (const auto &Str : RankedStrings) { auto Score = Matcher.match(Str.Word); diff --git a/clang-tools-extra/clangd/unittests/LSPClient.h b/clang-tools-extra/clangd/unittests/LSPClient.h index a0f3a31144fb49..be8bd42b84df13 100644 --- a/clang-tools-extra/clangd/unittests/LSPClient.h +++ b/clang-tools-extra/clangd/unittests/LSPClient.h @@ -9,12 +9,12 @@ #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_UNITTESTS_LSPCLIENT_H #define LLVM_CLANG_TOOLS_EXTRA_CLANGD_UNITTESTS_LSPCLIENT_H -#include #include #include #include #include #include +#include namespace clang { namespace clangd { @@ -42,7 +42,7 @@ class LSPClient { // Should be called once to provide the value. void set(llvm::Expected V); - llvm::Optional> Value; + std::optional> Value; std::mutex Mu; std::condition_variable CV; @@ -72,7 +72,7 @@ class LSPClient { // Blocks until the server is idle (using the 'sync' protocol extension). void sync(); // sync()s to ensure pending diagnostics arrive, and returns the newest set. - llvm::Optional> + std::optional> diagnostics(llvm::StringRef Path); // Get the transport used to connect this client to a ClangdLSPServer. diff --git a/clang-tools-extra/clangd/unittests/LoggerTests.cpp b/clang-tools-extra/clangd/unittests/LoggerTests.cpp index 3d2194d79090d9..1e28a1499071bf 100644 --- a/clang-tools-extra/clangd/unittests/LoggerTests.cpp +++ b/clang-tools-extra/clangd/unittests/LoggerTests.cpp @@ -10,6 +10,7 @@ #include "llvm/Support/Error.h" #include "gmock/gmock.h" #include "gtest/gtest.h" +#include namespace clang { namespace clangd { @@ -40,7 +41,7 @@ TEST(ErrorTest, Overloads) { } TEST(ErrorTest, Lifetimes) { - llvm::Optional Err; + std::optional Err; { // Check the error contains the value when error() was called. std::string S = "hello, world"; diff --git a/clang-tools-extra/clangd/unittests/PathMappingTests.cpp b/clang-tools-extra/clangd/unittests/PathMappingTests.cpp index 2da38de102767a..2e26148495a017 100644 --- a/clang-tools-extra/clangd/unittests/PathMappingTests.cpp +++ b/clang-tools-extra/clangd/unittests/PathMappingTests.cpp @@ -10,6 +10,7 @@ #include "llvm/Support/JSON.h" #include "gmock/gmock.h" #include "gtest/gtest.h" +#include #include namespace clang { namespace clangd { @@ -86,7 +87,7 @@ bool mapsProperly(llvm::StringRef Orig, llvm::StringRef Expected, llvm::Expected Mappings = parsePathMappings(RawMappings); if (!Mappings) return false; - llvm::Optional MappedPath = doPathMapping(Orig, Dir, *Mappings); + std::optional MappedPath = doPathMapping(Orig, Dir, *Mappings); std::string Actual = MappedPath ? *MappedPath : Orig.str(); EXPECT_STREQ(Expected.str().c_str(), Actual.c_str()); return Expected == Actual; diff --git a/clang-tools-extra/clangd/unittests/support/CancellationTests.cpp b/clang-tools-extra/clangd/unittests/support/CancellationTests.cpp index 074b01b996ae9b..ed98d8f3074876 100644 --- a/clang-tools-extra/clangd/unittests/support/CancellationTests.cpp +++ b/clang-tools-extra/clangd/unittests/support/CancellationTests.cpp @@ -5,6 +5,7 @@ #include "gtest/gtest.h" #include #include +#include #include namespace clang { @@ -20,7 +21,7 @@ TEST(CancellationTest, CancellationTest) { } TEST(CancellationTest, CancelerDiesContextLives) { - llvm::Optional ContextWithCancellation; + std::optional ContextWithCancellation; { auto Task = cancelableTask(); ContextWithCancellation.emplace(std::move(Task.first)); diff --git a/clang-tools-extra/pseudo/include/clang-pseudo/grammar/Grammar.h b/clang-tools-extra/pseudo/include/clang-pseudo/grammar/Grammar.h index e13ae0e4ee5a1a..a1c779a02d8640 100644 --- a/clang-tools-extra/pseudo/include/clang-pseudo/grammar/Grammar.h +++ b/clang-tools-extra/pseudo/include/clang-pseudo/grammar/Grammar.h @@ -55,10 +55,10 @@ #include "clang/Basic/TokenKinds.h" #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/DenseSet.h" -#include "llvm/ADT/Optional.h" #include "llvm/ADT/StringRef.h" #include "llvm/Support/raw_ostream.h" #include +#include #include namespace clang { @@ -163,7 +163,7 @@ class Grammar { llvm::StringRef symbolName(SymbolID) const; // Lookup the SymbolID of the nonterminal symbol by Name. - llvm::Optional findNonterminal(llvm::StringRef Name) const; + std::optional findNonterminal(llvm::StringRef Name) const; // Dumps the whole grammar. std::string dump() const; diff --git a/clang-tools-extra/pseudo/lib/grammar/Grammar.cpp b/clang-tools-extra/pseudo/lib/grammar/Grammar.cpp index 8c1338cff03797..6df5565081fa88 100644 --- a/clang-tools-extra/pseudo/lib/grammar/Grammar.cpp +++ b/clang-tools-extra/pseudo/lib/grammar/Grammar.cpp @@ -13,6 +13,7 @@ #include "llvm/ADT/StringRef.h" #include "llvm/Support/FormatVariadic.h" #include "llvm/Support/raw_ostream.h" +#include namespace clang { namespace pseudo { @@ -45,7 +46,7 @@ llvm::StringRef Grammar::symbolName(SymbolID SID) const { return T->Nonterminals[SID].Name; } -llvm::Optional Grammar::findNonterminal(llvm::StringRef Name) const { +std::optional Grammar::findNonterminal(llvm::StringRef Name) const { auto It = llvm::partition_point( T->Nonterminals, [&](const GrammarTable::Nonterminal &X) { return X.Name < Name; });