auto ParentMatcher = floatLiteral(hasParent(varDecl(hasName("i"))));
- EXPECT_TRUE(
- notMatches(VarDeclCode, traverse(ast_type_traits::TK_AsIs, ParentMatcher)));
- EXPECT_TRUE(
- matches(VarDeclCode,
- traverse(ast_type_traits::TK_IgnoreUnlessSpelledInSource,
- ParentMatcher)));
+ EXPECT_TRUE(notMatches(VarDeclCode,
+ traverse(ast_type_traits::TK_AsIs, ParentMatcher)));
+ EXPECT_TRUE(matches(VarDeclCode,
+ traverse(ast_type_traits::TK_IgnoreUnlessSpelledInSource,
+ ParentMatcher)));
EXPECT_TRUE(
matches(VarDeclCode, decl(traverse(ast_type_traits::TK_AsIs,
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()
matches(Code,
traverse(ast_type_traits::TK_IgnoreUnlessSpelledInSource,
varDecl(hasInitializer(integerLiteral(equals(3)))))));
- EXPECT_TRUE(
- matches(Code,
- traverse(ast_type_traits::TK_IgnoreUnlessSpelledInSource,
- integerLiteral(equals(3), hasParent(varDecl(hasName("i")))))));
+ EXPECT_TRUE(matches(
+ Code,
+ traverse(ast_type_traits::TK_IgnoreUnlessSpelledInSource,
+ integerLiteral(equals(3), hasParent(varDecl(hasName("i")))))));
}
template <typename MatcherT>
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,
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,
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,
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,
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,
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,
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,