Remove deprecated methods ast_matchers::BoundNodes::{getStmtAs,getDeclAs}
llvm-svn: 289542
GitOrigin-RevId: 9f58fe08bf08cf5b7dd2815eb9fe19158eb2f2c1
diff --git a/clang-tidy/misc/BoolPointerImplicitConversionCheck.cpp b/clang-tidy/misc/BoolPointerImplicitConversionCheck.cpp
index 4dc459a..f831125 100644
--- a/clang-tidy/misc/BoolPointerImplicitConversionCheck.cpp
+++ b/clang-tidy/misc/BoolPointerImplicitConversionCheck.cpp
@@ -32,8 +32,8 @@
void BoolPointerImplicitConversionCheck::check(
const MatchFinder::MatchResult &Result) {
- auto *If = Result.Nodes.getStmtAs<IfStmt>("if");
- auto *Var = Result.Nodes.getStmtAs<DeclRefExpr>("expr");
+ auto *If = Result.Nodes.getNodeAs<IfStmt>("if");
+ auto *Var = Result.Nodes.getNodeAs<DeclRefExpr>("expr");
// Ignore macros.
if (Var->getLocStart().isMacroID())
diff --git a/clang-tidy/misc/IncorrectRoundings.cpp b/clang-tidy/misc/IncorrectRoundings.cpp
index 88365ef..b7c8e0a 100644
--- a/clang-tidy/misc/IncorrectRoundings.cpp
+++ b/clang-tidy/misc/IncorrectRoundings.cpp
@@ -60,7 +60,7 @@
}
void IncorrectRoundings::check(const MatchFinder::MatchResult &Result) {
- const auto *CastExpr = Result.Nodes.getStmtAs<ImplicitCastExpr>("CastExpr");
+ const auto *CastExpr = Result.Nodes.getNodeAs<ImplicitCastExpr>("CastExpr");
diag(CastExpr->getLocStart(),
"casting (double + 0.5) to integer leads to incorrect rounding; "
"consider using lround (#include <cmath>) instead");
diff --git a/clang-tidy/misc/SwappedArgumentsCheck.cpp b/clang-tidy/misc/SwappedArgumentsCheck.cpp
index 389be35..e4dc5ca 100644
--- a/clang-tidy/misc/SwappedArgumentsCheck.cpp
+++ b/clang-tidy/misc/SwappedArgumentsCheck.cpp
@@ -49,7 +49,7 @@
void SwappedArgumentsCheck::check(const MatchFinder::MatchResult &Result) {
const ASTContext &Ctx = *Result.Context;
- const auto *Call = Result.Nodes.getStmtAs<CallExpr>("call");
+ const auto *Call = Result.Nodes.getNodeAs<CallExpr>("call");
llvm::SmallPtrSet<const Expr *, 4> UsedArgs;
for (unsigned I = 1, E = Call->getNumArgs(); I < E; ++I) {
diff --git a/clang-tidy/misc/UndelegatedConstructor.cpp b/clang-tidy/misc/UndelegatedConstructor.cpp
index 003290e..f42f1c5 100644
--- a/clang-tidy/misc/UndelegatedConstructor.cpp
+++ b/clang-tidy/misc/UndelegatedConstructor.cpp
@@ -74,7 +74,7 @@
void UndelegatedConstructorCheck::check(
const MatchFinder::MatchResult &Result) {
- const auto *E = Result.Nodes.getStmtAs<CXXConstructExpr>("construct");
+ const auto *E = Result.Nodes.getNodeAs<CXXConstructExpr>("construct");
diag(E->getLocStart(), "did you intend to call a delegated constructor? "
"A temporary object is created here instead");
}
diff --git a/clang-tidy/misc/UnusedRAIICheck.cpp b/clang-tidy/misc/UnusedRAIICheck.cpp
index 8350d53..e1acfe9 100644
--- a/clang-tidy/misc/UnusedRAIICheck.cpp
+++ b/clang-tidy/misc/UnusedRAIICheck.cpp
@@ -48,7 +48,7 @@
}
void UnusedRAIICheck::check(const MatchFinder::MatchResult &Result) {
- const auto *E = Result.Nodes.getStmtAs<Expr>("expr");
+ const auto *E = Result.Nodes.getNodeAs<Expr>("expr");
// We ignore code expanded from macros to reduce the number of false
// positives.
@@ -57,7 +57,7 @@
// Don't emit a warning for the last statement in the surrounding compund
// statement.
- const auto *CS = Result.Nodes.getStmtAs<CompoundStmt>("compound");
+ const auto *CS = Result.Nodes.getNodeAs<CompoundStmt>("compound");
if (E == CS->body_back())
return;
@@ -68,7 +68,7 @@
// If this is a default ctor we have to remove the parens or we'll introduce a
// most vexing parse.
- const auto *BTE = Result.Nodes.getStmtAs<CXXBindTemporaryExpr>("temp");
+ const auto *BTE = Result.Nodes.getNodeAs<CXXBindTemporaryExpr>("temp");
if (const auto *TOE = dyn_cast<CXXTemporaryObjectExpr>(BTE->getSubExpr()))
if (TOE->getNumArgs() == 0) {
D << FixItHint::CreateReplacement(
diff --git a/clang-tidy/modernize/LoopConvertCheck.cpp b/clang-tidy/modernize/LoopConvertCheck.cpp
index 3754768..d86a97c 100644
--- a/clang-tidy/modernize/LoopConvertCheck.cpp
+++ b/clang-tidy/modernize/LoopConvertCheck.cpp
@@ -703,7 +703,7 @@
RangeDescriptor &Descriptor) {
// The matchers for iterator loops provide bound nodes to obtain this
// information.
- const auto *InitVar = Nodes.getDeclAs<VarDecl>(InitVarName);
+ const auto *InitVar = Nodes.getNodeAs<VarDecl>(InitVarName);
QualType CanonicalInitVarType = InitVar->getType().getCanonicalType();
const auto *DerefByValueType =
Nodes.getNodeAs<QualType>(DerefByValueResultName);
@@ -763,13 +763,13 @@
return false;
// Check that we have exactly one index variable and at most one end variable.
- const auto *LoopVar = Nodes.getDeclAs<VarDecl>(IncrementVarName);
- const auto *CondVar = Nodes.getDeclAs<VarDecl>(ConditionVarName);
- const auto *InitVar = Nodes.getDeclAs<VarDecl>(InitVarName);
+ const auto *LoopVar = Nodes.getNodeAs<VarDecl>(IncrementVarName);
+ const auto *CondVar = Nodes.getNodeAs<VarDecl>(ConditionVarName);
+ const auto *InitVar = Nodes.getNodeAs<VarDecl>(InitVarName);
if (!areSameVariable(LoopVar, CondVar) || !areSameVariable(LoopVar, InitVar))
return false;
- const auto *EndVar = Nodes.getDeclAs<VarDecl>(EndVarName);
- const auto *ConditionEndVar = Nodes.getDeclAs<VarDecl>(ConditionEndVarName);
+ const auto *EndVar = Nodes.getNodeAs<VarDecl>(EndVarName);
+ const auto *ConditionEndVar = Nodes.getNodeAs<VarDecl>(ConditionEndVarName);
if (EndVar && !areSameVariable(EndVar, ConditionEndVar))
return false;
@@ -798,7 +798,7 @@
}
} else if (FixerKind == LFK_PseudoArray) {
// This call is required to obtain the container.
- const auto *EndCall = Nodes.getStmtAs<CXXMemberCallExpr>(EndCallName);
+ const auto *EndCall = Nodes.getNodeAs<CXXMemberCallExpr>(EndCallName);
if (!EndCall || !dyn_cast<MemberExpr>(EndCall->getCallee()))
return false;
}
@@ -814,12 +814,12 @@
LoopFixerKind FixerKind;
RangeDescriptor Descriptor;
- if ((Loop = Nodes.getStmtAs<ForStmt>(LoopNameArray))) {
+ if ((Loop = Nodes.getNodeAs<ForStmt>(LoopNameArray))) {
FixerKind = LFK_Array;
- } else if ((Loop = Nodes.getStmtAs<ForStmt>(LoopNameIterator))) {
+ } else if ((Loop = Nodes.getNodeAs<ForStmt>(LoopNameIterator))) {
FixerKind = LFK_Iterator;
} else {
- Loop = Nodes.getStmtAs<ForStmt>(LoopNamePseudoArray);
+ Loop = Nodes.getNodeAs<ForStmt>(LoopNamePseudoArray);
assert(Loop && "Bad Callback. No for statement");
FixerKind = LFK_PseudoArray;
}
@@ -827,8 +827,8 @@
if (!isConvertible(Context, Nodes, Loop, FixerKind))
return;
- const auto *LoopVar = Nodes.getDeclAs<VarDecl>(IncrementVarName);
- const auto *EndVar = Nodes.getDeclAs<VarDecl>(EndVarName);
+ const auto *LoopVar = Nodes.getNodeAs<VarDecl>(IncrementVarName);
+ const auto *EndVar = Nodes.getNodeAs<VarDecl>(EndVarName);
// If the loop calls end()/size() after each iteration, lower our confidence
// level.
@@ -837,8 +837,8 @@
// If the end comparison isn't a variable, we can try to work with the
// expression the loop variable is being tested against instead.
- const auto *EndCall = Nodes.getStmtAs<CXXMemberCallExpr>(EndCallName);
- const auto *BoundExpr = Nodes.getStmtAs<Expr>(ConditionBoundName);
+ const auto *EndCall = Nodes.getNodeAs<CXXMemberCallExpr>(EndCallName);
+ const auto *BoundExpr = Nodes.getNodeAs<Expr>(ConditionBoundName);
// Find container expression of iterators and pseudoarrays, and determine if
// this expression needs to be dereferenced to obtain the container.
diff --git a/clang-tidy/modernize/UseOverrideCheck.cpp b/clang-tidy/modernize/UseOverrideCheck.cpp
index 3b91c6e..574d1a7 100644
--- a/clang-tidy/modernize/UseOverrideCheck.cpp
+++ b/clang-tidy/modernize/UseOverrideCheck.cpp
@@ -60,7 +60,7 @@
}
void UseOverrideCheck::check(const MatchFinder::MatchResult &Result) {
- const FunctionDecl *Method = Result.Nodes.getStmtAs<FunctionDecl>("method");
+ const FunctionDecl *Method = Result.Nodes.getNodeAs<FunctionDecl>("method");
const SourceManager &Sources = *Result.SourceManager;
assert(Method != nullptr);
diff --git a/clang-tidy/readability/RedundantStringCStrCheck.cpp b/clang-tidy/readability/RedundantStringCStrCheck.cpp
index 8f086b8..c6b384b 100644
--- a/clang-tidy/readability/RedundantStringCStrCheck.cpp
+++ b/clang-tidy/readability/RedundantStringCStrCheck.cpp
@@ -177,9 +177,9 @@
}
void RedundantStringCStrCheck::check(const MatchFinder::MatchResult &Result) {
- const auto *Call = Result.Nodes.getStmtAs<CallExpr>("call");
- const auto *Arg = Result.Nodes.getStmtAs<Expr>("arg");
- const auto *Member = Result.Nodes.getStmtAs<MemberExpr>("member");
+ const auto *Call = Result.Nodes.getNodeAs<CallExpr>("call");
+ const auto *Arg = Result.Nodes.getNodeAs<Expr>("arg");
+ const auto *Member = Result.Nodes.getNodeAs<MemberExpr>("member");
bool Arrow = Member->isArrow();
// Replace the "call" node with the "arg" node, prefixed with '*'
// if the call was using '->' rather than '.'.
diff --git a/unittests/clang-tidy/IncludeInserterTest.cpp b/unittests/clang-tidy/IncludeInserterTest.cpp
index 928d1ce..1d46f2a 100644
--- a/unittests/clang-tidy/IncludeInserterTest.cpp
+++ b/unittests/clang-tidy/IncludeInserterTest.cpp
@@ -45,7 +45,7 @@
}
void check(const ast_matchers::MatchFinder::MatchResult &Result) override {
- auto Diag = diag(Result.Nodes.getStmtAs<DeclStmt>("stmt")->getLocStart(),
+ auto Diag = diag(Result.Nodes.getNodeAs<DeclStmt>("stmt")->getLocStart(),
"foo, bar");
for (StringRef header : HeadersToInclude()) {
auto Fixit = Inserter->CreateIncludeInsertion(