[clang-tools-extra] Use std::optional instead of llvm::Optional (NFC)
This is part of an effort to migrate from llvm::Optional to std::optional: https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
This commit is contained in:
parent
9cf4419e24
commit
2c675be9b2
@ -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 @@ protected:
|
||||
|
||||
/// Try to read configuration files from \p Directory using registered
|
||||
/// \c ConfigHandlers.
|
||||
llvm::Optional<OptionsSource> tryReadConfigFile(llvm::StringRef Directory);
|
||||
std::optional<OptionsSource> tryReadConfigFile(llvm::StringRef Directory);
|
||||
|
||||
llvm::StringMap<OptionsSource> CachedOptions;
|
||||
ClangTidyOptions OverrideOptions;
|
||||
|
||||
@ -11,6 +11,7 @@
|
||||
#include "llvm/Support/FileSystem.h"
|
||||
#include "llvm/Support/Path.h"
|
||||
#include "llvm/Support/raw_ostream.h"
|
||||
#include <optional>
|
||||
#include <system_error>
|
||||
#include <utility>
|
||||
|
||||
@ -74,7 +75,7 @@ void ClangTidyProfiling::storeProfileData() {
|
||||
printAsJSON(OS);
|
||||
}
|
||||
|
||||
ClangTidyProfiling::ClangTidyProfiling(llvm::Optional<StorageParams> Storage)
|
||||
ClangTidyProfiling::ClangTidyProfiling(std::optional<StorageParams> Storage)
|
||||
: Storage(std::move(Storage)) {}
|
||||
|
||||
ClangTidyProfiling::~ClangTidyProfiling() {
|
||||
|
||||
@ -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 <optional>
|
||||
#include <string>
|
||||
|
||||
namespace llvm {
|
||||
@ -35,9 +35,9 @@ public:
|
||||
};
|
||||
|
||||
private:
|
||||
llvm::Optional<llvm::TimerGroup> TG;
|
||||
std::optional<llvm::TimerGroup> TG;
|
||||
|
||||
llvm::Optional<StorageParams> Storage;
|
||||
std::optional<StorageParams> Storage;
|
||||
|
||||
void printUserFriendlyTable(llvm::raw_ostream &OS);
|
||||
void printAsJSON(llvm::raw_ostream &OS);
|
||||
@ -49,7 +49,7 @@ public:
|
||||
|
||||
ClangTidyProfiling() = default;
|
||||
|
||||
ClangTidyProfiling(llvm::Optional<StorageParams> Storage);
|
||||
ClangTidyProfiling(std::optional<StorageParams> Storage);
|
||||
|
||||
~ClangTidyProfiling();
|
||||
};
|
||||
|
||||
@ -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 <optional>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
@ -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<Located<std::string>> Compiler;
|
||||
std::optional<Located<std::string>> Compiler;
|
||||
|
||||
/// List of flags to append to the compile command.
|
||||
std::vector<Located<std::string>> 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<Located<std::string>> CompilationDatabase;
|
||||
std::optional<Located<std::string>> 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<Located<std::string>> Background;
|
||||
std::optional<Located<std::string>> 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<bool> 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<Located<std::string>> File;
|
||||
std::optional<Located<std::string>> File;
|
||||
/// Address and port number for a clangd-index-server. e.g.
|
||||
/// `123.1.1.1:13337`.
|
||||
llvm::Optional<Located<std::string>> Server;
|
||||
std::optional<Located<std::string>> 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<Located<std::string>> MountPoint;
|
||||
std::optional<Located<std::string>> MountPoint;
|
||||
};
|
||||
llvm::Optional<Located<ExternalBlock>> External;
|
||||
std::optional<Located<ExternalBlock>> External;
|
||||
// Whether the standard library visible from this file should be indexed.
|
||||
// This makes all standard library symbols available, included or not.
|
||||
llvm::Optional<Located<bool>> StandardLibrary;
|
||||
std::optional<Located<bool>> StandardLibrary;
|
||||
};
|
||||
IndexBlock Index;
|
||||
|
||||
@ -233,7 +233,7 @@ struct Fragment {
|
||||
/// Valid values are:
|
||||
/// - Strict
|
||||
/// - None
|
||||
llvm::Optional<Located<std::string>> UnusedIncludes;
|
||||
std::optional<Located<std::string>> 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<Located<bool>> AllScopes;
|
||||
std::optional<Located<bool>> AllScopes;
|
||||
};
|
||||
CompletionBlock Completion;
|
||||
|
||||
/// Describes hover preferences.
|
||||
struct HoverBlock {
|
||||
/// Whether hover show a.k.a type.
|
||||
llvm::Optional<Located<bool>> ShowAKA;
|
||||
std::optional<Located<bool>> ShowAKA;
|
||||
};
|
||||
HoverBlock Hover;
|
||||
|
||||
/// Configures labels shown inline with the code.
|
||||
struct InlayHintsBlock {
|
||||
/// Enables/disables the inlay-hints feature.
|
||||
llvm::Optional<Located<bool>> Enabled;
|
||||
std::optional<Located<bool>> Enabled;
|
||||
|
||||
/// Show parameter names before function arguments.
|
||||
llvm::Optional<Located<bool>> ParameterNames;
|
||||
std::optional<Located<bool>> ParameterNames;
|
||||
/// Show deduced types for `auto`.
|
||||
llvm::Optional<Located<bool>> DeducedTypes;
|
||||
std::optional<Located<bool>> DeducedTypes;
|
||||
/// Show designators in aggregate initialization.
|
||||
llvm::Optional<Located<bool>> Designators;
|
||||
std::optional<Located<bool>> Designators;
|
||||
};
|
||||
InlayHintsBlock InlayHints;
|
||||
};
|
||||
|
||||
@ -19,6 +19,7 @@
|
||||
#include "llvm/Support/Path.h"
|
||||
#include <chrono>
|
||||
#include <mutex>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
|
||||
namespace clang {
|
||||
@ -39,7 +40,7 @@ public:
|
||||
std::vector<CompiledFragment> &Out) const {
|
||||
read(
|
||||
TFS, FreshTime,
|
||||
[&](llvm::Optional<llvm::StringRef> Data) {
|
||||
[&](std::optional<llvm::StringRef> Data) {
|
||||
CachedValue.clear();
|
||||
if (Data)
|
||||
for (auto &Fragment : Fragment::parseYAML(*Data, path(), DC)) {
|
||||
|
||||
@ -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 <optional>
|
||||
#include <string>
|
||||
#include <system_error>
|
||||
|
||||
@ -26,13 +26,13 @@ using llvm::yaml::Node;
|
||||
using llvm::yaml::ScalarNode;
|
||||
using llvm::yaml::SequenceNode;
|
||||
|
||||
llvm::Optional<llvm::StringRef>
|
||||
std::optional<llvm::StringRef>
|
||||
bestGuess(llvm::StringRef Search,
|
||||
llvm::ArrayRef<llvm::StringRef> AllowedValues) {
|
||||
unsigned MaxEdit = (Search.size() + 1) / 3;
|
||||
if (!MaxEdit)
|
||||
return std::nullopt;
|
||||
llvm::Optional<llvm::StringRef> Result;
|
||||
std::optional<llvm::StringRef> 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 @@ private:
|
||||
};
|
||||
|
||||
// Try to parse a single scalar value from the node, warn on failure.
|
||||
llvm::Optional<Located<std::string>> scalarValue(Node &N,
|
||||
llvm::StringRef Desc) {
|
||||
std::optional<Located<std::string>> scalarValue(Node &N,
|
||||
llvm::StringRef Desc) {
|
||||
llvm::SmallString<256> Buf;
|
||||
if (auto *S = llvm::dyn_cast<ScalarNode>(&N))
|
||||
return Located<std::string>(S->getValue(Buf).str(), N.getSourceRange());
|
||||
@ -360,7 +360,7 @@ private:
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
llvm::Optional<Located<bool>> boolValue(Node &N, llvm::StringRef Desc) {
|
||||
std::optional<Located<bool>> boolValue(Node &N, llvm::StringRef Desc) {
|
||||
if (auto Scalar = scalarValue(N, Desc)) {
|
||||
if (auto Bool = llvm::yaml::parseBool(**Scalar))
|
||||
return Located<bool>(*Bool, Scalar->Range);
|
||||
@ -370,7 +370,7 @@ private:
|
||||
}
|
||||
|
||||
// Try to parse a list of single scalar values, or just a single value.
|
||||
llvm::Optional<std::vector<Located<std::string>>> scalarValues(Node &N) {
|
||||
std::optional<std::vector<Located<std::string>>> scalarValues(Node &N) {
|
||||
std::vector<Located<std::string>> Result;
|
||||
if (auto *S = llvm::dyn_cast<ScalarNode>(&N)) {
|
||||
llvm::SmallString<256> Buf;
|
||||
|
||||
@ -56,8 +56,8 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "FuzzyMatch.h"
|
||||
#include "llvm/ADT/Optional.h"
|
||||
#include "llvm/Support/Format.h"
|
||||
#include <optional>
|
||||
|
||||
namespace clang {
|
||||
namespace clangd {
|
||||
@ -89,7 +89,7 @@ FuzzyMatcher::FuzzyMatcher(llvm::StringRef Pattern)
|
||||
llvm::makeMutableArrayRef(PatRole, PatN));
|
||||
}
|
||||
|
||||
llvm::Optional<float> FuzzyMatcher::match(llvm::StringRef Word) {
|
||||
std::optional<float> FuzzyMatcher::match(llvm::StringRef Word) {
|
||||
if (!(WordContainsPattern = init(Word)))
|
||||
return std::nullopt;
|
||||
if (!PatN)
|
||||
|
||||
@ -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 <optional>
|
||||
|
||||
namespace clang {
|
||||
namespace clangd {
|
||||
@ -77,7 +77,7 @@ public:
|
||||
// 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<float> match(llvm::StringRef Word);
|
||||
std::optional<float> match(llvm::StringRef Word);
|
||||
|
||||
llvm::StringRef pattern() const { return llvm::StringRef(Pat, PatN); }
|
||||
bool empty() const { return PatN == 0; }
|
||||
|
||||
@ -12,13 +12,14 @@
|
||||
#include "llvm/Support/Error.h"
|
||||
#include "llvm/Support/Path.h"
|
||||
#include <algorithm>
|
||||
#include <optional>
|
||||
#include <tuple>
|
||||
|
||||
namespace clang {
|
||||
namespace clangd {
|
||||
llvm::Optional<std::string> doPathMapping(llvm::StringRef S,
|
||||
PathMapping::Direction Dir,
|
||||
const PathMappings &Mappings) {
|
||||
std::optional<std::string> 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<std::string> MappedKey =
|
||||
if (std::optional<std::string> 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<std::string> Mapped =
|
||||
if (std::optional<std::string> Mapped =
|
||||
doPathMapping(*V.getAsString(), Dir, Mappings))
|
||||
V = std::move(*Mapped);
|
||||
}
|
||||
|
||||
@ -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 <memory>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
@ -50,9 +50,9 @@ llvm::Expected<PathMappings> parsePathMappings(llvm::StringRef RawPathMappings);
|
||||
|
||||
/// Returns a modified \p S with the first matching path in \p Mappings
|
||||
/// substituted, if applicable
|
||||
llvm::Optional<std::string> doPathMapping(llvm::StringRef S,
|
||||
PathMapping::Direction Dir,
|
||||
const PathMappings &Mappings);
|
||||
std::optional<std::string> 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
|
||||
|
||||
@ -42,7 +42,7 @@ public:
|
||||
std::shared_ptr<const tidy::ClangTidyOptions> Result;
|
||||
read(
|
||||
TFS, FreshTime,
|
||||
[this](llvm::Optional<llvm::StringRef> Data) {
|
||||
[this](std::optional<llvm::StringRef> Data) {
|
||||
Value.reset();
|
||||
if (Data && !Data->empty()) {
|
||||
tidy::DiagCallback Diagnostics = [](const llvm::SMDiagnostic &D) {
|
||||
|
||||
@ -10,6 +10,7 @@
|
||||
#include "index/dex/Iterator.h"
|
||||
#include "index/dex/Token.h"
|
||||
#include "llvm/Support/MathExtras.h"
|
||||
#include <optional>
|
||||
|
||||
namespace clang {
|
||||
namespace clangd {
|
||||
@ -182,7 +183,7 @@ std::vector<Chunk> encodeStream(llvm::ArrayRef<DocID> Documents) {
|
||||
|
||||
/// Reads variable length DocID from the buffer and updates the buffer size. If
|
||||
/// the stream is terminated, return std::nullopt.
|
||||
llvm::Optional<DocID> readVByte(llvm::ArrayRef<uint8_t> &Bytes) {
|
||||
std::optional<DocID> readVByte(llvm::ArrayRef<uint8_t> &Bytes) {
|
||||
if (Bytes.front() == 0 || Bytes.empty())
|
||||
return std::nullopt;
|
||||
DocID Result = 0;
|
||||
|
||||
@ -8,6 +8,7 @@
|
||||
|
||||
#include "support/FileCache.h"
|
||||
#include "llvm/ADT/ScopeExit.h"
|
||||
#include <optional>
|
||||
|
||||
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<void(llvm::Optional<llvm::StringRef>)> Parse,
|
||||
llvm::function_ref<void(std::optional<llvm::StringRef>)> Parse,
|
||||
llvm::function_ref<void()> Read) const {
|
||||
|
||||
std::lock_guard<std::mutex> Lock(Mu);
|
||||
|
||||
@ -13,6 +13,7 @@
|
||||
#include "ThreadsafeFS.h"
|
||||
#include "llvm/Support/Chrono.h"
|
||||
#include <mutex>
|
||||
#include <optional>
|
||||
|
||||
namespace clang {
|
||||
namespace clangd {
|
||||
@ -56,7 +57,7 @@ protected:
|
||||
// - 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<void(llvm::Optional<llvm::StringRef>)> Parse,
|
||||
llvm::function_ref<void(std::optional<llvm::StringRef>)> Parse,
|
||||
llvm::function_ref<void()> Read) const;
|
||||
|
||||
PathRef path() const { return Path; }
|
||||
|
||||
@ -12,6 +12,7 @@
|
||||
#include "llvm/Support/Threading.h"
|
||||
#include "llvm/Support/thread.h"
|
||||
#include <atomic>
|
||||
#include <optional>
|
||||
#include <thread>
|
||||
#ifdef __USE_POSIX
|
||||
#include <pthread.h>
|
||||
@ -109,7 +110,7 @@ void AsyncTaskRunner::runAsync(const llvm::Twine &Name,
|
||||
Thread.detach();
|
||||
}
|
||||
|
||||
Deadline timeoutSeconds(llvm::Optional<double> Seconds) {
|
||||
Deadline timeoutSeconds(std::optional<double> Seconds) {
|
||||
using namespace std::chrono;
|
||||
if (!Seconds)
|
||||
return Deadline::infinity();
|
||||
|
||||
@ -18,6 +18,7 @@
|
||||
#include <future>
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <optional>
|
||||
#include <thread>
|
||||
#include <vector>
|
||||
|
||||
@ -70,7 +71,7 @@ private:
|
||||
};
|
||||
|
||||
/// Makes a deadline from a timeout in seconds. None means wait forever.
|
||||
Deadline timeoutSeconds(llvm::Optional<double> Seconds);
|
||||
Deadline timeoutSeconds(std::optional<double> Seconds);
|
||||
/// Wait once on CV for the specified duration.
|
||||
void wait(std::unique_lock<std::mutex> &Lock, std::condition_variable &CV,
|
||||
Deadline D);
|
||||
|
||||
@ -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 <chrono>
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <optional>
|
||||
|
||||
namespace clang {
|
||||
namespace clangd {
|
||||
@ -287,7 +287,7 @@ static std::pair<Context, llvm::json::Object *>
|
||||
makeSpanContext(llvm::Twine Name, const Metric &LatencyMetric) {
|
||||
if (!T)
|
||||
return std::make_pair(Context::current().clone(), nullptr);
|
||||
llvm::Optional<WithContextValue> WithLatency;
|
||||
std::optional<WithContextValue> WithLatency;
|
||||
using Clock = std::chrono::high_resolution_clock;
|
||||
WithLatency.emplace(llvm::make_scope_exit(
|
||||
[StartTime = Clock::now(), Name = Name.str(), &LatencyMetric] {
|
||||
|
||||
@ -10,6 +10,7 @@
|
||||
|
||||
#include "gmock/gmock.h"
|
||||
#include "gtest/gtest.h"
|
||||
#include <optional>
|
||||
|
||||
namespace clang {
|
||||
namespace clangd {
|
||||
@ -39,13 +40,13 @@ struct ExpectedMatch {
|
||||
std::string Word;
|
||||
|
||||
private:
|
||||
llvm::Optional<llvm::StringRef> Annotated;
|
||||
std::optional<llvm::StringRef> Annotated;
|
||||
};
|
||||
|
||||
struct MatchesMatcher : public ::testing::MatcherInterface<llvm::StringRef> {
|
||||
ExpectedMatch Candidate;
|
||||
llvm::Optional<float> Score;
|
||||
MatchesMatcher(ExpectedMatch Candidate, llvm::Optional<float> Score)
|
||||
std::optional<float> Score;
|
||||
MatchesMatcher(ExpectedMatch Candidate, std::optional<float> Score)
|
||||
: Candidate(std::move(Candidate)), Score(Score) {}
|
||||
|
||||
void DescribeTo(::std::ostream *OS) const override {
|
||||
@ -71,7 +72,7 @@ struct MatchesMatcher : public ::testing::MatcherInterface<llvm::StringRef> {
|
||||
// Accepts patterns that match a given word, optionally requiring a score.
|
||||
// Dumps the debug tables on match failure.
|
||||
::testing::Matcher<llvm::StringRef> matches(llvm::StringRef M,
|
||||
llvm::Optional<float> Score = {}) {
|
||||
std::optional<float> Score = {}) {
|
||||
return ::testing::MakeMatcher<llvm::StringRef>(new MatchesMatcher(M, Score));
|
||||
}
|
||||
|
||||
@ -199,7 +200,7 @@ struct RankMatcher : public ::testing::MatcherInterface<llvm::StringRef> {
|
||||
: new llvm::raw_null_ostream());
|
||||
FuzzyMatcher Matcher(Pattern);
|
||||
const ExpectedMatch *LastMatch;
|
||||
llvm::Optional<float> LastScore;
|
||||
std::optional<float> LastScore;
|
||||
bool Ok = true;
|
||||
for (const auto &Str : RankedStrings) {
|
||||
auto Score = Matcher.match(Str.Word);
|
||||
|
||||
@ -9,12 +9,12 @@
|
||||
#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_UNITTESTS_LSPCLIENT_H
|
||||
#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_UNITTESTS_LSPCLIENT_H
|
||||
|
||||
#include <llvm/ADT/Optional.h>
|
||||
#include <llvm/Support/Error.h>
|
||||
#include <llvm/Support/JSON.h>
|
||||
#include <condition_variable>
|
||||
#include <deque>
|
||||
#include <mutex>
|
||||
#include <optional>
|
||||
|
||||
namespace clang {
|
||||
namespace clangd {
|
||||
@ -42,7 +42,7 @@ public:
|
||||
// Should be called once to provide the value.
|
||||
void set(llvm::Expected<llvm::json::Value> V);
|
||||
|
||||
llvm::Optional<llvm::Expected<llvm::json::Value>> Value;
|
||||
std::optional<llvm::Expected<llvm::json::Value>> Value;
|
||||
std::mutex Mu;
|
||||
std::condition_variable CV;
|
||||
|
||||
@ -72,7 +72,7 @@ public:
|
||||
// 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::vector<llvm::json::Value>>
|
||||
std::optional<std::vector<llvm::json::Value>>
|
||||
diagnostics(llvm::StringRef Path);
|
||||
|
||||
// Get the transport used to connect this client to a ClangdLSPServer.
|
||||
|
||||
@ -10,6 +10,7 @@
|
||||
#include "llvm/Support/Error.h"
|
||||
#include "gmock/gmock.h"
|
||||
#include "gtest/gtest.h"
|
||||
#include <optional>
|
||||
|
||||
namespace clang {
|
||||
namespace clangd {
|
||||
@ -40,7 +41,7 @@ TEST(ErrorTest, Overloads) {
|
||||
}
|
||||
|
||||
TEST(ErrorTest, Lifetimes) {
|
||||
llvm::Optional<llvm::Error> Err;
|
||||
std::optional<llvm::Error> Err;
|
||||
{
|
||||
// Check the error contains the value when error() was called.
|
||||
std::string S = "hello, world";
|
||||
|
||||
@ -10,6 +10,7 @@
|
||||
#include "llvm/Support/JSON.h"
|
||||
#include "gmock/gmock.h"
|
||||
#include "gtest/gtest.h"
|
||||
#include <optional>
|
||||
#include <string>
|
||||
namespace clang {
|
||||
namespace clangd {
|
||||
@ -86,7 +87,7 @@ bool mapsProperly(llvm::StringRef Orig, llvm::StringRef Expected,
|
||||
llvm::Expected<PathMappings> Mappings = parsePathMappings(RawMappings);
|
||||
if (!Mappings)
|
||||
return false;
|
||||
llvm::Optional<std::string> MappedPath = doPathMapping(Orig, Dir, *Mappings);
|
||||
std::optional<std::string> MappedPath = doPathMapping(Orig, Dir, *Mappings);
|
||||
std::string Actual = MappedPath ? *MappedPath : Orig.str();
|
||||
EXPECT_STREQ(Expected.str().c_str(), Actual.c_str());
|
||||
return Expected == Actual;
|
||||
|
||||
@ -5,6 +5,7 @@
|
||||
#include "gtest/gtest.h"
|
||||
#include <atomic>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <thread>
|
||||
|
||||
namespace clang {
|
||||
@ -20,7 +21,7 @@ TEST(CancellationTest, CancellationTest) {
|
||||
}
|
||||
|
||||
TEST(CancellationTest, CancelerDiesContextLives) {
|
||||
llvm::Optional<WithContext> ContextWithCancellation;
|
||||
std::optional<WithContext> ContextWithCancellation;
|
||||
{
|
||||
auto Task = cancelableTask();
|
||||
ContextWithCancellation.emplace(std::move(Task.first));
|
||||
|
||||
@ -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 <cstdint>
|
||||
#include <optional>
|
||||
#include <vector>
|
||||
|
||||
namespace clang {
|
||||
@ -163,7 +163,7 @@ public:
|
||||
llvm::StringRef symbolName(SymbolID) const;
|
||||
|
||||
// Lookup the SymbolID of the nonterminal symbol by Name.
|
||||
llvm::Optional<SymbolID> findNonterminal(llvm::StringRef Name) const;
|
||||
std::optional<SymbolID> findNonterminal(llvm::StringRef Name) const;
|
||||
|
||||
// Dumps the whole grammar.
|
||||
std::string dump() const;
|
||||
|
||||
@ -13,6 +13,7 @@
|
||||
#include "llvm/ADT/StringRef.h"
|
||||
#include "llvm/Support/FormatVariadic.h"
|
||||
#include "llvm/Support/raw_ostream.h"
|
||||
#include <optional>
|
||||
|
||||
namespace clang {
|
||||
namespace pseudo {
|
||||
@ -45,7 +46,7 @@ llvm::StringRef Grammar::symbolName(SymbolID SID) const {
|
||||
return T->Nonterminals[SID].Name;
|
||||
}
|
||||
|
||||
llvm::Optional<SymbolID> Grammar::findNonterminal(llvm::StringRef Name) const {
|
||||
std::optional<SymbolID> Grammar::findNonterminal(llvm::StringRef Name) const {
|
||||
auto It = llvm::partition_point(
|
||||
T->Nonterminals,
|
||||
[&](const GrammarTable::Nonterminal &X) { return X.Name < Name; });
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user