steveire updated this revision to Diff 275248. steveire added a comment. Update
Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83076/new/ https://reviews.llvm.org/D83076 Files: clang-tools-extra/clang-query/Query.cpp clang-tools-extra/clang-query/QuerySession.h clang/include/clang/AST/ParentMapContext.h clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp Index: clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp =================================================================== --- clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp +++ clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp @@ -1207,7 +1207,12 @@ } TEST_P(ASTMatchersTest, CastExpr_DoesNotMatchNonCasts) { - EXPECT_TRUE(notMatches("char c = '0';", castExpr())); + if (GetParam().Language == Lang_C89 || GetParam().Language == Lang_C99) { + // This does have a cast in C + EXPECT_TRUE(matches("char c = '0';", implicitCastExpr())); + } else { + EXPECT_TRUE(notMatches("char c = '0';", castExpr())); + } EXPECT_TRUE(notMatches("int i = (0);", castExpr())); EXPECT_TRUE(notMatches("int i = 0;", castExpr())); } Index: clang/include/clang/AST/ParentMapContext.h =================================================================== --- clang/include/clang/AST/ParentMapContext.h +++ clang/include/clang/AST/ParentMapContext.h @@ -67,7 +67,7 @@ private: ASTContext &ASTCtx; class ParentMap; - TraversalKind Traversal = TK_IgnoreUnlessSpelledInSource; + TraversalKind Traversal = TK_AsIs; std::unique_ptr<ParentMap> Parents; }; Index: clang-tools-extra/clang-query/QuerySession.h =================================================================== --- clang-tools-extra/clang-query/QuerySession.h +++ clang-tools-extra/clang-query/QuerySession.h @@ -26,7 +26,7 @@ QuerySession(llvm::ArrayRef<std::unique_ptr<ASTUnit>> ASTs) : ASTs(ASTs), PrintOutput(false), DiagOutput(true), DetailedASTOutput(false), BindRoot(true), PrintMatcher(false), - Terminate(false), TK(ast_type_traits::TK_IgnoreUnlessSpelledInSource) {} + Terminate(false), TK(ast_type_traits::TK_AsIs) {} llvm::ArrayRef<std::unique_ptr<ASTUnit>> ASTs; Index: clang-tools-extra/clang-query/Query.cpp =================================================================== --- clang-tools-extra/clang-query/Query.cpp +++ clang-tools-extra/clang-query/Query.cpp @@ -46,12 +46,12 @@ " set traversal <kind> " "Set traversal kind of clang-query session. Available kinds are:\n" " AsIs " - "Print and match the AST as clang sees it.\n" + "Print and match the AST as clang sees it. This mode is the " + "default.\n" " IgnoreImplicitCastsAndParentheses " "Omit implicit casts and parens in matching and dumping.\n" " IgnoreUnlessSpelledInSource " - "Omit AST nodes unless spelled in the source. This mode is the " - "default.\n" + "Omit AST nodes unless spelled in the source.\n" " set output <feature> " "Set whether to output only <feature> content.\n" " enable output <feature> "
Index: clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp =================================================================== --- clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp +++ clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp @@ -1207,7 +1207,12 @@ } TEST_P(ASTMatchersTest, CastExpr_DoesNotMatchNonCasts) { - EXPECT_TRUE(notMatches("char c = '0';", castExpr())); + if (GetParam().Language == Lang_C89 || GetParam().Language == Lang_C99) { + // This does have a cast in C + EXPECT_TRUE(matches("char c = '0';", implicitCastExpr())); + } else { + EXPECT_TRUE(notMatches("char c = '0';", castExpr())); + } EXPECT_TRUE(notMatches("int i = (0);", castExpr())); EXPECT_TRUE(notMatches("int i = 0;", castExpr())); } Index: clang/include/clang/AST/ParentMapContext.h =================================================================== --- clang/include/clang/AST/ParentMapContext.h +++ clang/include/clang/AST/ParentMapContext.h @@ -67,7 +67,7 @@ private: ASTContext &ASTCtx; class ParentMap; - TraversalKind Traversal = TK_IgnoreUnlessSpelledInSource; + TraversalKind Traversal = TK_AsIs; std::unique_ptr<ParentMap> Parents; }; Index: clang-tools-extra/clang-query/QuerySession.h =================================================================== --- clang-tools-extra/clang-query/QuerySession.h +++ clang-tools-extra/clang-query/QuerySession.h @@ -26,7 +26,7 @@ QuerySession(llvm::ArrayRef<std::unique_ptr<ASTUnit>> ASTs) : ASTs(ASTs), PrintOutput(false), DiagOutput(true), DetailedASTOutput(false), BindRoot(true), PrintMatcher(false), - Terminate(false), TK(ast_type_traits::TK_IgnoreUnlessSpelledInSource) {} + Terminate(false), TK(ast_type_traits::TK_AsIs) {} llvm::ArrayRef<std::unique_ptr<ASTUnit>> ASTs; Index: clang-tools-extra/clang-query/Query.cpp =================================================================== --- clang-tools-extra/clang-query/Query.cpp +++ clang-tools-extra/clang-query/Query.cpp @@ -46,12 +46,12 @@ " set traversal <kind> " "Set traversal kind of clang-query session. Available kinds are:\n" " AsIs " - "Print and match the AST as clang sees it.\n" + "Print and match the AST as clang sees it. This mode is the " + "default.\n" " IgnoreImplicitCastsAndParentheses " "Omit implicit casts and parens in matching and dumping.\n" " IgnoreUnlessSpelledInSource " - "Omit AST nodes unless spelled in the source. This mode is the " - "default.\n" + "Omit AST nodes unless spelled in the source.\n" " set output <feature> " "Set whether to output only <feature> content.\n" " enable output <feature> "
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits