Add some explicit use of TK_AsIs

This commit is contained in:
Stephen Kelly 2020-05-22 22:48:54 +01:00
parent 26ac5a34ba
commit 8d62eba105
4 changed files with 10 additions and 7 deletions

View File

@ -104,9 +104,11 @@ findMembersUsedInInitExpr(const CXXCtorInitializer *Initializer,
// for those accesses Sema::PerformObjectMemberConversion always inserts an
// UncheckedDerivedToBase ImplicitCastExpr between the this expr and the
// object expression
auto FoundExprs =
match(findAll(memberExpr(hasObjectExpression(cxxThisExpr())).bind("ME")),
*Initializer->getInit(), Context);
auto FoundExprs = match(
traverse(
TK_AsIs,
findAll(memberExpr(hasObjectExpression(cxxThisExpr())).bind("ME"))),
*Initializer->getInit(), Context);
for (BoundNodes &BN : FoundExprs)
if (auto *MemExpr = BN.getNodeAs<MemberExpr>("ME"))
if (auto *FD = dyn_cast<FieldDecl>(MemExpr->getMemberDecl()))

View File

@ -338,7 +338,7 @@ void NumberObjectConversionChecker::checkASTCodeBody(const Decl *D,
MatchFinder F;
Callback CB(this, BR, AM.getAnalysisDeclContext(D));
F.addMatcher(stmt(forEachDescendant(FinalM)), &CB);
F.addMatcher(traverse(TK_AsIs, stmt(forEachDescendant(FinalM))), &CB);
F.match(*D->getBody(), AM.getASTContext());
}

View File

@ -86,8 +86,9 @@ auto matchSortWithPointers() -> decltype(decl()) {
)))
))));
auto PointerSortM = stmt(callExpr(allOf(SortFuncM, IteratesPointerEltsM))
).bind(WarnAtNode);
auto PointerSortM = traverse(
TK_AsIs,
stmt(callExpr(allOf(SortFuncM, IteratesPointerEltsM))).bind(WarnAtNode));
return decl(forEachDescendant(PointerSortM));
}

View File

@ -226,7 +226,7 @@ TEST(ParserTest, FullParserTest) {
Parser::parseMatcherExpression(Code, nullptr, nullptr, &Error));
EXPECT_EQ("", Error.toStringFull());
Matcher<Stmt> MCastStmt =
implicitIntBooleanCast->unconditionalConvertTo<Stmt>();
traverse(TK_AsIs, implicitIntBooleanCast->unconditionalConvertTo<Stmt>());
EXPECT_TRUE(matches("bool X = 1;", MCastStmt));
EXPECT_FALSE(matches("bool X = true;", MCastStmt));