aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Tooling/Refactoring/ASTSelection.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib/Tooling/Refactoring/ASTSelection.cpp')
-rw-r--r--clang/lib/Tooling/Refactoring/ASTSelection.cpp19
1 files changed, 10 insertions, 9 deletions
diff --git a/clang/lib/Tooling/Refactoring/ASTSelection.cpp b/clang/lib/Tooling/Refactoring/ASTSelection.cpp
index 9485c8bc04ad..058574d8ec1a 100644
--- a/clang/lib/Tooling/Refactoring/ASTSelection.cpp
+++ b/clang/lib/Tooling/Refactoring/ASTSelection.cpp
@@ -10,6 +10,7 @@
#include "clang/AST/LexicallyOrderedRecursiveASTVisitor.h"
#include "clang/Lex/Lexer.h"
#include "llvm/Support/SaveAndRestore.h"
+#include <optional>
using namespace clang;
using namespace tooling;
@@ -50,12 +51,12 @@ public:
SourceSelectionKind::None));
}
- Optional<SelectedASTNode> getSelectedASTNode() {
+ std::optional<SelectedASTNode> getSelectedASTNode() {
assert(SelectionStack.size() == 1 && "stack was not popped");
SelectedASTNode Result = std::move(SelectionStack.back());
SelectionStack.pop_back();
if (Result.Children.empty())
- return None;
+ return std::nullopt;
return std::move(Result);
}
@@ -63,14 +64,14 @@ public:
// Avoid traversing the semantic expressions. They should be handled by
// looking through the appropriate opaque expressions in order to build
// a meaningful selection tree.
- llvm::SaveAndRestore<bool> LookThrough(LookThroughOpaqueValueExprs, true);
+ llvm::SaveAndRestore LookThrough(LookThroughOpaqueValueExprs, true);
return TraverseStmt(E->getSyntacticForm());
}
bool TraverseOpaqueValueExpr(OpaqueValueExpr *E) {
if (!LookThroughOpaqueValueExprs)
return true;
- llvm::SaveAndRestore<bool> LookThrough(LookThroughOpaqueValueExprs, false);
+ llvm::SaveAndRestore LookThrough(LookThroughOpaqueValueExprs, false);
return TraverseStmt(E->getSourceExpr());
}
@@ -178,7 +179,7 @@ private:
} // end anonymous namespace
-Optional<SelectedASTNode>
+std::optional<SelectedASTNode>
clang::tooling::findSelectedASTNodes(const ASTContext &Context,
SourceRange SelectionRange) {
assert(SelectionRange.isValid() &&
@@ -375,22 +376,22 @@ static void findDeepestWithKind(
findDeepestWithKind(ASTSelection, MatchingNodes, Kind, ParentStack);
}
-Optional<CodeRangeASTSelection>
+std::optional<CodeRangeASTSelection>
CodeRangeASTSelection::create(SourceRange SelectionRange,
const SelectedASTNode &ASTSelection) {
// Code range is selected when the selection range is not empty.
if (SelectionRange.getBegin() == SelectionRange.getEnd())
- return None;
+ return std::nullopt;
llvm::SmallVector<SelectedNodeWithParents, 4> ContainSelection;
findDeepestWithKind(ASTSelection, ContainSelection,
SourceSelectionKind::ContainsSelection);
// We are looking for a selection in one body of code, so let's focus on
// one matching result.
if (ContainSelection.size() != 1)
- return None;
+ return std::nullopt;
SelectedNodeWithParents &Selected = ContainSelection[0];
if (!Selected.Node.get().Node.get<Stmt>())
- return None;
+ return std::nullopt;
const Stmt *CodeRangeStmt = Selected.Node.get().Node.get<Stmt>();
if (!isa<CompoundStmt>(CodeRangeStmt)) {
Selected.canonicalize();