[clang-tools-extra] Use std::optional instead of llvm::Optional (NFC)
This patch replaces (llvm::|)Optional< with std::optional<. I'll post
a separate patch to clean up the "using" declarations, #include
"llvm/ADT/Optional.h", etc.
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
diff --git a/clang-tools-extra/clangd/Selection.cpp b/clang-tools-extra/clangd/Selection.cpp
index 56836fd..f46da8e 100644
--- a/clang-tools-extra/clangd/Selection.cpp
+++ b/clang-tools-extra/clangd/Selection.cpp
@@ -513,7 +513,7 @@
}
// Decomposes Loc and returns the offset if the file ID is SelFile.
- llvm::Optional<unsigned> offsetInSelFile(SourceLocation Loc) const {
+ std::optional<unsigned> offsetInSelFile(SourceLocation Loc) const {
// Decoding Loc with SM.getDecomposedLoc is relatively expensive.
// But SourceLocations for a file are numerically contiguous, so we
// can use cheap integer operations instead.
@@ -1060,7 +1060,7 @@
SelectionTree SelectionTree::createRight(ASTContext &AST,
const syntax::TokenBuffer &Tokens,
unsigned int Begin, unsigned int End) {
- llvm::Optional<SelectionTree> Result;
+ std::optional<SelectionTree> Result;
createEach(AST, Tokens, Begin, End, [&](SelectionTree T) {
Result = std::move(T);
return true;