ASTMatchers: added CXXMethodDecl matcher isPure()
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
			
			
This commit is contained in:
		
							parent
							
								
									cf5d8e4f29
								
							
						
					
					
						commit
						51c1b55bc2
					
				| 
						 | 
					@ -555,7 +555,7 @@ const internal::VariadicDynCastAllOfMatcher<
 | 
				
			||||||
///
 | 
					///
 | 
				
			||||||
/// Example matches y
 | 
					/// Example matches y
 | 
				
			||||||
/// \code
 | 
					/// \code
 | 
				
			||||||
///   class X { void y() };
 | 
					///   class X { void y(); };
 | 
				
			||||||
/// \endcode
 | 
					/// \endcode
 | 
				
			||||||
const internal::VariadicDynCastAllOfMatcher<Decl, CXXMethodDecl> methodDecl;
 | 
					const internal::VariadicDynCastAllOfMatcher<Decl, CXXMethodDecl> methodDecl;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -2656,6 +2656,20 @@ AST_MATCHER(CXXMethodDecl, isVirtual) {
 | 
				
			||||||
  return Node.isVirtual();
 | 
					  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.
 | 
					/// \brief Matches if the given method declaration is const.
 | 
				
			||||||
///
 | 
					///
 | 
				
			||||||
/// Given
 | 
					/// Given
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1588,6 +1588,13 @@ TEST(Matcher, MatchesVirtualMethod) {
 | 
				
			||||||
      methodDecl(isVirtual())));
 | 
					      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) {
 | 
					TEST(Matcher, MatchesConstMethod) {
 | 
				
			||||||
  EXPECT_TRUE(matches("struct A { void foo() const; };",
 | 
					  EXPECT_TRUE(matches("struct A { void foo() const; };",
 | 
				
			||||||
                      methodDecl(isConst())));
 | 
					                      methodDecl(isConst())));
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue