Index: docs/LibASTMatchersReference.html =================================================================== --- docs/LibASTMatchersReference.html +++ docs/LibASTMatchersReference.html @@ -707,6 +707,14 @@ +
MAtches a reference to a block. + +Example: matches "^{}": + void f() { ^{}(); } +
Matches break statements. Index: include/clang/ASTMatchers/ASTMatchers.h =================================================================== --- include/clang/ASTMatchers/ASTMatchers.h +++ include/clang/ASTMatchers/ASTMatchers.h @@ -1776,6 +1776,14 @@ extern const internal::VariadicDynCastAllOfMatcherobjcIvarRefExpr; +/// Matches a reference to a block. +/// +/// Example: matches "^{}": +/// \code +/// void f() { ^{}(); } +/// \endcode +extern const internal::VariadicDynCastAllOfMatcher blockExpr; + /// Matches if statements. /// /// Example matches 'if (x) {}' Index: lib/ASTMatchers/ASTMatchersInternal.cpp =================================================================== --- lib/ASTMatchers/ASTMatchersInternal.cpp +++ lib/ASTMatchers/ASTMatchersInternal.cpp @@ -688,6 +688,7 @@ const internal::VariadicDynCastAllOfMatcher expr; const internal::VariadicDynCastAllOfMatcher declRefExpr; const internal::VariadicDynCastAllOfMatcher objcIvarRefExpr; +const internal::VariadicDynCastAllOfMatcher blockExpr; const internal::VariadicDynCastAllOfMatcher ifStmt; const internal::VariadicDynCastAllOfMatcher forStmt; const internal::VariadicDynCastAllOfMatcher Index: lib/ASTMatchers/Dynamic/Registry.cpp =================================================================== --- lib/ASTMatchers/Dynamic/Registry.cpp +++ lib/ASTMatchers/Dynamic/Registry.cpp @@ -139,6 +139,7 @@ REGISTER_MATCHER(binaryConditionalOperator); REGISTER_MATCHER(binaryOperator); REGISTER_MATCHER(blockDecl); + REGISTER_MATCHER(blockExpr); REGISTER_MATCHER(blockPointerType); REGISTER_MATCHER(booleanType); REGISTER_MATCHER(breakStmt); Index: unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp =================================================================== --- unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp +++ unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp @@ -1386,6 +1386,10 @@ hasDeclaration(namedDecl(hasName("y")))))); } +TEST(BlockExprMatcher, BlockExpr) { + EXPECT_TRUE(matchesObjC("void f() { ^{}(); }", blockExpr())); +} + TEST(StatementCountIs, FindsNoStatementsInAnEmptyCompoundStatement) { EXPECT_TRUE(matches("void f() { }", compoundStmt(statementCountIs(0))));