Index: include/clang/ASTMatchers/ASTMatchers.h =================================================================== --- include/clang/ASTMatchers/ASTMatchers.h +++ include/clang/ASTMatchers/ASTMatchers.h @@ -2709,6 +2709,19 @@ return Node.isDeleted(); } +/// \brief Matches constexpr function declarations. +/// +/// Given: +/// \code +/// int foo(); +/// constexpr int bar(); +/// \endcode +/// functionDecl(isConstexpr()) +/// matches the declaration of bar, but not foo. +AST_MATCHER(FunctionDecl, isConstexpr) { + return Node.isConstexpr(); +} + /// \brief Matches the condition expression of an if statement, for loop, /// or conditional operator. /// Index: unittests/ASTMatchers/ASTMatchersTest.cpp =================================================================== --- unittests/ASTMatchers/ASTMatchersTest.cpp +++ unittests/ASTMatchers/ASTMatchersTest.cpp @@ -1595,6 +1595,13 @@ functionDecl(hasName("Func"), isDeleted()))); } +TEST(isConstexpr, MatchesConstexprFunctionDeclarations) { + EXPECT_TRUE(notMatches("int foo();", + functionDecl(hasName("foo"), isConstexpr()))); + EXPECT_TRUE(matches("constexpr int bar();", + functionDecl(hasName("bar"), isConstexpr()))); +} + TEST(HasAnyParameter, DoesntMatchIfInnerMatcherDoesntMatch) { EXPECT_TRUE(notMatches("class Y {}; class X { void x(int) {} };", methodDecl(hasAnyParameter(hasType(recordDecl(hasName("X")))))));