[clang] 8d62eba - Add some explicit use of TK_AsIs

Stephen Kelly via cfe-commits cfe-commits at lists.llvm.org
Fri May 22 17:06:12 PDT 2020


Author: Stephen Kelly
Date: 2020-05-23T01:04:44+01:00
New Revision: 8d62eba1053a4156032e5333ce0b1c6d33ca8ec5

URL: https://github.com/llvm/llvm-project/commit/8d62eba1053a4156032e5333ce0b1c6d33ca8ec5
DIFF: https://github.com/llvm/llvm-project/commit/8d62eba1053a4156032e5333ce0b1c6d33ca8ec5.diff

LOG: Add some explicit use of TK_AsIs

Added: 
    

Modified: 
    clang-tools-extra/clang-reorder-fields/ReorderFieldsAction.cpp
    clang/lib/StaticAnalyzer/Checkers/NumberObjectConversionChecker.cpp
    clang/lib/StaticAnalyzer/Checkers/PointerSortingChecker.cpp
    clang/unittests/ASTMatchers/Dynamic/ParserTest.cpp

Removed: 
    


################################################################################
diff  --git a/clang-tools-extra/clang-reorder-fields/ReorderFieldsAction.cpp b/clang-tools-extra/clang-reorder-fields/ReorderFieldsAction.cpp
index c17a43c73f95..d179e6cb7c75 100644
--- a/clang-tools-extra/clang-reorder-fields/ReorderFieldsAction.cpp
+++ b/clang-tools-extra/clang-reorder-fields/ReorderFieldsAction.cpp
@@ -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()))

diff  --git a/clang/lib/StaticAnalyzer/Checkers/NumberObjectConversionChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/NumberObjectConversionChecker.cpp
index df69254ead26..abeca596d056 100644
--- a/clang/lib/StaticAnalyzer/Checkers/NumberObjectConversionChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/NumberObjectConversionChecker.cpp
@@ -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());
 }
 

diff  --git a/clang/lib/StaticAnalyzer/Checkers/PointerSortingChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/PointerSortingChecker.cpp
index 8eee4df473e8..25d87f4acfc9 100644
--- a/clang/lib/StaticAnalyzer/Checkers/PointerSortingChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/PointerSortingChecker.cpp
@@ -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));
 }

diff  --git a/clang/unittests/ASTMatchers/Dynamic/ParserTest.cpp b/clang/unittests/ASTMatchers/Dynamic/ParserTest.cpp
index 0d3a2d4ce776..f5e324a3b158 100644
--- a/clang/unittests/ASTMatchers/Dynamic/ParserTest.cpp
+++ b/clang/unittests/ASTMatchers/Dynamic/ParserTest.cpp
@@ -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));
 


        


More information about the cfe-commits mailing list