Skip to content

Commit

Permalink
[clangd] Replace None with std::nullopt in comments (NFC)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
kazutakahirata committed May 6, 2023
1 parent 5326c9e commit 38d8b1f
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 14 deletions.
5 changes: 3 additions & 2 deletions clang-tools-extra/clangd/ClangdServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,9 @@ class ClangdServer {

/// The resource directory is used to find internal headers, overriding
/// defaults and -resource-dir compiler flag).
/// If None, ClangdServer calls CompilerInvocation::GetResourcePath() to
/// obtain the standard resource directory.
/// If std::nullopt, ClangdServer calls
/// CompilerInvocation::GetResourcePath() to obtain the standard resource
/// directory.
std::optional<std::string> ResourceDir;

/// Time to wait after a new file version before computing diagnostics.
Expand Down
6 changes: 3 additions & 3 deletions clang-tools-extra/clangd/ConfigFragment.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ struct Fragment {
/// etc). Valid values are:
/// - 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.
/// - std::nullopt: do not use a compilation database, just default flags.
std::optional<Located<std::string>> CompilationDatabase;
};
CompileFlagsBlock CompileFlags;
Expand Down Expand Up @@ -232,7 +232,7 @@ struct Fragment {
///
/// Valid values are:
/// - Strict
/// - None
/// - std::nullopt
std::optional<Located<std::string>> UnusedIncludes;


Expand All @@ -249,7 +249,7 @@ struct Fragment {
///
/// Valid values are:
/// - Strict
/// - None
/// - std::nullopt
std::optional<Located<std::string>> MissingIncludes;

/// Controls IncludeCleaner diagnostics.
Expand Down
6 changes: 3 additions & 3 deletions clang-tools-extra/clangd/Protocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -1492,7 +1492,7 @@ struct TypeHierarchyItem {
/// Used to resolve a client provided item back.
struct ResolveParams {
SymbolID symbolID;
/// None means parents aren't resolved and empty is no parents.
/// std::nullopt means parents aren't resolved and empty is no parents.
std::optional<std::vector<ResolveParams>> parents;
};
/// A data entry field that is preserved between a type hierarchy prepare and
Expand Down Expand Up @@ -1618,8 +1618,8 @@ struct InlayHintsParams {

/// The visible document range for which inlay hints should be computed.
///
/// None is a clangd extension, which hints for computing hints on the whole
/// file.
/// std::nullopt is a clangd extension, which hints for computing hints on the
/// whole file.
std::optional<Range> range;
};
bool fromJSON(const llvm::json::Value &, InlayHintsParams &, llvm::json::Path);
Expand Down
4 changes: 2 additions & 2 deletions clang-tools-extra/clangd/TUScheduler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -740,8 +740,8 @@ class ASTWorker {
mutable std::condition_variable RequestsCV;
std::shared_ptr<const ASTSignals> LatestASTSignals; /* GUARDED_BY(Mutex) */
/// Latest build preamble for current TU.
/// None means no builds yet, null means there was an error while building.
/// Only written by ASTWorker's thread.
/// std::nullopt means no builds yet, null means there was an error while
/// building. Only written by ASTWorker's thread.
std::optional<std::shared_ptr<const PreambleData>> LatestPreamble;
std::deque<Request> PreambleRequests; /* GUARDED_BY(Mutex) */
/// Signaled whenever LatestPreamble changes state or there's a new
Expand Down
4 changes: 2 additions & 2 deletions clang-tools-extra/clangd/TUScheduler.h
Original file line number Diff line number Diff line change
Expand Up @@ -368,8 +368,8 @@ class TUScheduler {
llvm::StringMap<std::unique_ptr<FileData>> Files;
std::unique_ptr<ASTCache> IdleASTs;
std::unique_ptr<HeaderIncluderCache> HeaderIncluders;
// None when running tasks synchronously and non-None when running tasks
// asynchronously.
// std::nullopt when running tasks synchronously and non-std::nullopt when
// running tasks asynchronously.
std::optional<AsyncTaskRunner> PreambleTasks;
std::optional<AsyncTaskRunner> WorkerThreads;
// Used to create contexts for operations that are not bound to a particular
Expand Down
2 changes: 1 addition & 1 deletion clang-tools-extra/clangd/refactor/InsertionPoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ namespace {

// Choose the decl to insert before, according to an anchor.
// Nullptr means insert at end of DC.
// None means no valid place to insert.
// std::nullopt means no valid place to insert.
std::optional<const Decl *> insertionDecl(const DeclContext &DC,
const Anchor &A) {
bool LastMatched = false;
Expand Down
2 changes: 1 addition & 1 deletion clang-tools-extra/clangd/support/Threading.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class Deadline {
std::chrono::steady_clock::time_point Time;
};

/// Makes a deadline from a timeout in seconds. None means wait forever.
/// Makes a deadline from a timeout in seconds. std::nullopt means wait forever.
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,
Expand Down

0 comments on commit 38d8b1f

Please sign in to comment.