return Node.isDeleted();
}
+/// \brief Matches constexpr variable and function declarations.
+///
+/// Given:
+/// \code
+/// constexpr int foo = 42;
+/// constexpr int bar();
+/// \endcode
+/// varDecl(isConstexpr())
+/// matches the declaration of foo.
+/// functionDecl(isConstexpr())
+/// matches the declaration of bar.
+AST_POLYMORPHIC_MATCHER(isConstexpr,
+ AST_POLYMORPHIC_SUPPORTED_TYPES(VarDecl,
+ FunctionDecl)) {
+ return Node.isConstexpr();
+}
+
/// \brief Matches the condition expression of an if statement, for loop,
/// or conditional operator.
///
functionDecl(hasName("Func"), isDeleted())));
}
+TEST(isConstexpr, MatchesConstexprDeclarations) {
+ EXPECT_TRUE(matches("constexpr int foo = 42;",
+ varDecl(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")))))));