The isPure() CXXMethodDecl matcher matches pure method declaration like "A::x"
in this example:
class A {
virtual void x() = 0;
}
Patch by Konrad Kleine.
llvm-svn: 202012
///
/// Example matches y
/// \code
-/// class X { void y() };
+/// class X { void y(); };
/// \endcode
const internal::VariadicDynCastAllOfMatcher<Decl, CXXMethodDecl> methodDecl;
return Node.isVirtual();
}
+/// \brief Matches if the given method declaration is pure.
+///
+/// Given
+/// \code
+/// class A {
+/// public:
+/// virtual void x() = 0;
+/// };
+/// \endcode
+/// matches A::x
+AST_MATCHER(CXXMethodDecl, isPure) {
+ return Node.isPure();
+}
+
/// \brief Matches if the given method declaration is const.
///
/// Given
methodDecl(isVirtual())));
}
+TEST(Matcher, MatchesPureMethod) {
+ EXPECT_TRUE(matches("class X { virtual int f() = 0; };",
+ methodDecl(isPure(), hasName("::X::f"))));
+ EXPECT_TRUE(notMatches("class X { int f(); };",
+ methodDecl(isPure())));
+}
+
TEST(Matcher, MatchesConstMethod) {
EXPECT_TRUE(matches("struct A { void foo() const; };",
methodDecl(isConst())));