forked from OSchip/llvm-project
Remove deprecated methods ast_matchers::BoundNodes::{getStmtAs,getDeclAs}
llvm-svn: 289542
This commit is contained in:
parent
dc4edba576
commit
9f58fe08bf
|
@ -32,8 +32,8 @@ void BoolPointerImplicitConversionCheck::registerMatchers(MatchFinder *Finder) {
|
|||
|
||||
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())
|
||||
|
|
|
@ -60,7 +60,7 @@ void IncorrectRoundings::registerMatchers(MatchFinder *MatchFinder) {
|
|||
}
|
||||
|
||||
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");
|
||||
|
|
|
@ -49,7 +49,7 @@ static bool isImplicitCastCandidate(const CastExpr *Cast) {
|
|||
|
||||
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) {
|
||||
|
|
|
@ -74,7 +74,7 @@ void UndelegatedConstructorCheck::registerMatchers(MatchFinder *Finder) {
|
|||
|
||||
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");
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ void UnusedRAIICheck::registerMatchers(MatchFinder *Finder) {
|
|||
}
|
||||
|
||||
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 @@ void UnusedRAIICheck::check(const MatchFinder::MatchResult &Result) {
|
|||
|
||||
// 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 @@ void UnusedRAIICheck::check(const MatchFinder::MatchResult &Result) {
|
|||
|
||||
// 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(
|
||||
|
|
|
@ -703,7 +703,7 @@ void LoopConvertCheck::getIteratorLoopQualifiers(ASTContext *Context,
|
|||
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 @@ bool LoopConvertCheck::isConvertible(ASTContext *Context,
|
|||
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 @@ bool LoopConvertCheck::isConvertible(ASTContext *Context,
|
|||
}
|
||||
} 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 @@ void LoopConvertCheck::check(const MatchFinder::MatchResult &Result) {
|
|||
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 @@ void LoopConvertCheck::check(const MatchFinder::MatchResult &Result) {
|
|||
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 @@ void LoopConvertCheck::check(const MatchFinder::MatchResult &Result) {
|
|||
|
||||
// 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.
|
||||
|
|
|
@ -60,7 +60,7 @@ static StringRef GetText(const Token &Tok, const SourceManager &Sources) {
|
|||
}
|
||||
|
||||
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);
|
||||
|
|
|
@ -177,9 +177,9 @@ void RedundantStringCStrCheck::registerMatchers(
|
|||
}
|
||||
|
||||
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 '.'.
|
||||
|
|
|
@ -45,7 +45,7 @@ public:
|
|||
}
|
||||
|
||||
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(
|
||||
|
|
Loading…
Reference in New Issue