Loading clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp +46 −33 Original line number Diff line number Diff line Loading @@ -1635,10 +1635,9 @@ void foo() auto ParentMatcher = floatLiteral(hasParent(varDecl(hasName("i")))); EXPECT_TRUE( notMatches(VarDeclCode, traverse(ast_type_traits::TK_AsIs, ParentMatcher))); EXPECT_TRUE( matches(VarDeclCode, EXPECT_TRUE(notMatches(VarDeclCode, traverse(ast_type_traits::TK_AsIs, ParentMatcher))); EXPECT_TRUE(matches(VarDeclCode, traverse(ast_type_traits::TK_IgnoreUnlessSpelledInSource, ParentMatcher))); Loading Loading @@ -1723,12 +1722,13 @@ void bar() functionDecl(hasName("foo"), traverse(ast_type_traits::TK_AsIs, hasDescendant(floatLiteral()))))); EXPECT_TRUE(notMatches(Code, traverse(ast_type_traits::TK_AsIs, floatLiteral(hasParent(callExpr(callee( functionDecl(hasName("foo"))))))))); EXPECT_TRUE( notMatches(Code, traverse(ast_type_traits::TK_AsIs, floatLiteral(hasParent(callExpr(callee(functionDecl(hasName("foo"))))))))); EXPECT_TRUE( matches(Code, traverse(ast_type_traits::TK_IgnoreUnlessSpelledInSource, floatLiteral(hasParent(callExpr(callee(functionDecl(hasName("foo"))))))))); matches(Code, traverse(ast_type_traits::TK_IgnoreUnlessSpelledInSource, floatLiteral(hasParent(callExpr( callee(functionDecl(hasName("foo"))))))))); Code = R"cpp( void foo() Loading @@ -1740,8 +1740,8 @@ void foo() matches(Code, traverse(ast_type_traits::TK_IgnoreUnlessSpelledInSource, varDecl(hasInitializer(integerLiteral(equals(3))))))); EXPECT_TRUE( matches(Code, EXPECT_TRUE(matches( Code, traverse(ast_type_traits::TK_IgnoreUnlessSpelledInSource, integerLiteral(equals(3), hasParent(varDecl(hasName("i"))))))); } Loading Loading @@ -1927,8 +1927,9 @@ void func14() { EXPECT_TRUE(matches( Code, traverse(ast_type_traits::TK_IgnoreUnlessSpelledInSource, integerLiteral(equals(42), hasParent(returnStmt(forFunction(functionDecl(hasName("func1")))))) ))); integerLiteral(equals(42), hasParent(returnStmt(forFunction( functionDecl(hasName("func1"))))))))); EXPECT_TRUE(matches( Code, Loading @@ -1939,7 +1940,10 @@ void func14() { EXPECT_TRUE(matches( Code, traverse(ast_type_traits::TK_IgnoreUnlessSpelledInSource, integerLiteral(equals(42), hasParent(cxxTemporaryObjectExpr(hasParent(returnStmt(forFunction(functionDecl(hasName("func2"))))))))))); integerLiteral( equals(42), hasParent(cxxTemporaryObjectExpr(hasParent(returnStmt( forFunction(functionDecl(hasName("func2"))))))))))); EXPECT_TRUE(matches( Code, traverse(ast_type_traits::TK_IgnoreUnlessSpelledInSource, Loading @@ -1949,8 +1953,12 @@ void func14() { integerLiteral(equals(42))))))))); EXPECT_TRUE(matches( Code, traverse(ast_type_traits::TK_IgnoreUnlessSpelledInSource, integerLiteral(equals(42), hasParent(cxxFunctionalCastExpr(hasParent(returnStmt(forFunction(functionDecl(hasName("func3")))) ))))))); Code, traverse(ast_type_traits::TK_IgnoreUnlessSpelledInSource, integerLiteral( equals(42), hasParent(cxxFunctionalCastExpr(hasParent(returnStmt( forFunction(functionDecl(hasName("func3"))))))))))); EXPECT_TRUE(matches( Code, traverse(ast_type_traits::TK_IgnoreUnlessSpelledInSource, Loading Loading @@ -1992,7 +2000,9 @@ void func14() { EXPECT_TRUE(matches( Code, traverse(ast_type_traits::TK_IgnoreUnlessSpelledInSource, declRefExpr(to(varDecl(hasName("a"))), hasParent(returnStmt(forFunction(functionDecl(hasName("func10"))))))))); declRefExpr(to(varDecl(hasName("a"))), hasParent(returnStmt(forFunction( functionDecl(hasName("func10"))))))))); EXPECT_TRUE(matches( Code, traverse(ast_type_traits::TK_IgnoreUnlessSpelledInSource, Loading @@ -2002,8 +2012,9 @@ void func14() { EXPECT_TRUE(matches( Code, traverse(ast_type_traits::TK_IgnoreUnlessSpelledInSource, declRefExpr(to(varDecl(hasName("b"))), hasParent(returnStmt(forFunction(functionDecl(hasName("func11")))))) ))); declRefExpr(to(varDecl(hasName("b"))), hasParent(returnStmt(forFunction( functionDecl(hasName("func11"))))))))); EXPECT_TRUE(matches( Code, traverse(ast_type_traits::TK_IgnoreUnlessSpelledInSource, Loading @@ -2013,8 +2024,9 @@ void func14() { EXPECT_TRUE(matches( Code, traverse(ast_type_traits::TK_IgnoreUnlessSpelledInSource, declRefExpr(to(varDecl(hasName("c"))), hasParent(returnStmt(forFunction(functionDecl(hasName("func12")))))) ))); declRefExpr(to(varDecl(hasName("c"))), hasParent(returnStmt(forFunction( functionDecl(hasName("func12"))))))))); EXPECT_TRUE(matches( Code, Loading @@ -2028,17 +2040,18 @@ void func14() { has(parmVarDecl(hasName("d"))))))); EXPECT_TRUE(matches( Code, traverse( ast_type_traits::TK_IgnoreUnlessSpelledInSource, declRefExpr(to(varDecl(hasName("a"))), hasParent( lambdaExpr(forFunction(functionDecl(hasName("func13")))) ))))); Code, traverse(ast_type_traits::TK_IgnoreUnlessSpelledInSource, declRefExpr(to(varDecl(hasName("a"))), hasParent(lambdaExpr(forFunction( functionDecl(hasName("func13"))))))))); EXPECT_TRUE(matches( Code, traverse( ast_type_traits::TK_IgnoreUnlessSpelledInSource, varDecl(hasName("b"), hasInitializer(declRefExpr(to( varDecl(hasName("c"))))), hasParent( lambdaExpr(forFunction(functionDecl(hasName("func13")))) ))))); traverse(ast_type_traits::TK_IgnoreUnlessSpelledInSource, varDecl(hasName("b"), hasInitializer(declRefExpr(to(varDecl(hasName("c"))))), hasParent(lambdaExpr( forFunction(functionDecl(hasName("func13"))))))))); EXPECT_TRUE(matches( Code, traverse(ast_type_traits::TK_IgnoreUnlessSpelledInSource, Loading clang/lib/ASTMatchers/ASTMatchFinder.cpp +1 −1 File changed.Contains only whitespace changes. Show changes Loading
clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp +46 −33 Original line number Diff line number Diff line Loading @@ -1635,10 +1635,9 @@ void foo() auto ParentMatcher = floatLiteral(hasParent(varDecl(hasName("i")))); EXPECT_TRUE( notMatches(VarDeclCode, traverse(ast_type_traits::TK_AsIs, ParentMatcher))); EXPECT_TRUE( matches(VarDeclCode, EXPECT_TRUE(notMatches(VarDeclCode, traverse(ast_type_traits::TK_AsIs, ParentMatcher))); EXPECT_TRUE(matches(VarDeclCode, traverse(ast_type_traits::TK_IgnoreUnlessSpelledInSource, ParentMatcher))); Loading Loading @@ -1723,12 +1722,13 @@ void bar() functionDecl(hasName("foo"), traverse(ast_type_traits::TK_AsIs, hasDescendant(floatLiteral()))))); EXPECT_TRUE(notMatches(Code, traverse(ast_type_traits::TK_AsIs, floatLiteral(hasParent(callExpr(callee( functionDecl(hasName("foo"))))))))); EXPECT_TRUE( notMatches(Code, traverse(ast_type_traits::TK_AsIs, floatLiteral(hasParent(callExpr(callee(functionDecl(hasName("foo"))))))))); EXPECT_TRUE( matches(Code, traverse(ast_type_traits::TK_IgnoreUnlessSpelledInSource, floatLiteral(hasParent(callExpr(callee(functionDecl(hasName("foo"))))))))); matches(Code, traverse(ast_type_traits::TK_IgnoreUnlessSpelledInSource, floatLiteral(hasParent(callExpr( callee(functionDecl(hasName("foo"))))))))); Code = R"cpp( void foo() Loading @@ -1740,8 +1740,8 @@ void foo() matches(Code, traverse(ast_type_traits::TK_IgnoreUnlessSpelledInSource, varDecl(hasInitializer(integerLiteral(equals(3))))))); EXPECT_TRUE( matches(Code, EXPECT_TRUE(matches( Code, traverse(ast_type_traits::TK_IgnoreUnlessSpelledInSource, integerLiteral(equals(3), hasParent(varDecl(hasName("i"))))))); } Loading Loading @@ -1927,8 +1927,9 @@ void func14() { EXPECT_TRUE(matches( Code, traverse(ast_type_traits::TK_IgnoreUnlessSpelledInSource, integerLiteral(equals(42), hasParent(returnStmt(forFunction(functionDecl(hasName("func1")))))) ))); integerLiteral(equals(42), hasParent(returnStmt(forFunction( functionDecl(hasName("func1"))))))))); EXPECT_TRUE(matches( Code, Loading @@ -1939,7 +1940,10 @@ void func14() { EXPECT_TRUE(matches( Code, traverse(ast_type_traits::TK_IgnoreUnlessSpelledInSource, integerLiteral(equals(42), hasParent(cxxTemporaryObjectExpr(hasParent(returnStmt(forFunction(functionDecl(hasName("func2"))))))))))); integerLiteral( equals(42), hasParent(cxxTemporaryObjectExpr(hasParent(returnStmt( forFunction(functionDecl(hasName("func2"))))))))))); EXPECT_TRUE(matches( Code, traverse(ast_type_traits::TK_IgnoreUnlessSpelledInSource, Loading @@ -1949,8 +1953,12 @@ void func14() { integerLiteral(equals(42))))))))); EXPECT_TRUE(matches( Code, traverse(ast_type_traits::TK_IgnoreUnlessSpelledInSource, integerLiteral(equals(42), hasParent(cxxFunctionalCastExpr(hasParent(returnStmt(forFunction(functionDecl(hasName("func3")))) ))))))); Code, traverse(ast_type_traits::TK_IgnoreUnlessSpelledInSource, integerLiteral( equals(42), hasParent(cxxFunctionalCastExpr(hasParent(returnStmt( forFunction(functionDecl(hasName("func3"))))))))))); EXPECT_TRUE(matches( Code, traverse(ast_type_traits::TK_IgnoreUnlessSpelledInSource, Loading Loading @@ -1992,7 +2000,9 @@ void func14() { EXPECT_TRUE(matches( Code, traverse(ast_type_traits::TK_IgnoreUnlessSpelledInSource, declRefExpr(to(varDecl(hasName("a"))), hasParent(returnStmt(forFunction(functionDecl(hasName("func10"))))))))); declRefExpr(to(varDecl(hasName("a"))), hasParent(returnStmt(forFunction( functionDecl(hasName("func10"))))))))); EXPECT_TRUE(matches( Code, traverse(ast_type_traits::TK_IgnoreUnlessSpelledInSource, Loading @@ -2002,8 +2012,9 @@ void func14() { EXPECT_TRUE(matches( Code, traverse(ast_type_traits::TK_IgnoreUnlessSpelledInSource, declRefExpr(to(varDecl(hasName("b"))), hasParent(returnStmt(forFunction(functionDecl(hasName("func11")))))) ))); declRefExpr(to(varDecl(hasName("b"))), hasParent(returnStmt(forFunction( functionDecl(hasName("func11"))))))))); EXPECT_TRUE(matches( Code, traverse(ast_type_traits::TK_IgnoreUnlessSpelledInSource, Loading @@ -2013,8 +2024,9 @@ void func14() { EXPECT_TRUE(matches( Code, traverse(ast_type_traits::TK_IgnoreUnlessSpelledInSource, declRefExpr(to(varDecl(hasName("c"))), hasParent(returnStmt(forFunction(functionDecl(hasName("func12")))))) ))); declRefExpr(to(varDecl(hasName("c"))), hasParent(returnStmt(forFunction( functionDecl(hasName("func12"))))))))); EXPECT_TRUE(matches( Code, Loading @@ -2028,17 +2040,18 @@ void func14() { has(parmVarDecl(hasName("d"))))))); EXPECT_TRUE(matches( Code, traverse( ast_type_traits::TK_IgnoreUnlessSpelledInSource, declRefExpr(to(varDecl(hasName("a"))), hasParent( lambdaExpr(forFunction(functionDecl(hasName("func13")))) ))))); Code, traverse(ast_type_traits::TK_IgnoreUnlessSpelledInSource, declRefExpr(to(varDecl(hasName("a"))), hasParent(lambdaExpr(forFunction( functionDecl(hasName("func13"))))))))); EXPECT_TRUE(matches( Code, traverse( ast_type_traits::TK_IgnoreUnlessSpelledInSource, varDecl(hasName("b"), hasInitializer(declRefExpr(to( varDecl(hasName("c"))))), hasParent( lambdaExpr(forFunction(functionDecl(hasName("func13")))) ))))); traverse(ast_type_traits::TK_IgnoreUnlessSpelledInSource, varDecl(hasName("b"), hasInitializer(declRefExpr(to(varDecl(hasName("c"))))), hasParent(lambdaExpr( forFunction(functionDecl(hasName("func13"))))))))); EXPECT_TRUE(matches( Code, traverse(ast_type_traits::TK_IgnoreUnlessSpelledInSource, Loading
clang/lib/ASTMatchers/ASTMatchFinder.cpp +1 −1 File changed.Contains only whitespace changes. Show changes