summaryrefslogtreecommitdiffstats
path: root/clang/unittests/ASTMatchers/ASTMatchersTest.cpp
diff options
context:
space:
mode:
authorEdwin Vane <edwin.vane@intel.com>2013-04-09 20:46:36 +0000
committerEdwin Vane <edwin.vane@intel.com>2013-04-09 20:46:36 +0000
commit37ee1d7b80bcae3d63ab12ba0b89698765e10a5d (patch)
treec237801085785ca44b64ec51fd4e82ec44e1b882 /clang/unittests/ASTMatchers/ASTMatchersTest.cpp
parent10d1d1ccb8754358f127898f845a025933c2f231 (diff)
downloadbcm5719-llvm-37ee1d7b80bcae3d63ab12ba0b89698765e10a5d.tar.gz
bcm5719-llvm-37ee1d7b80bcae3d63ab12ba0b89698765e10a5d.zip
Adding new AST Matchers isVirtual and isOverride
isVirtual - matches CXXMethodDecl nodes for virtual methods isOverride - matches CXXMethodDecl nodes for methods that override virtual methods from a base class. Author: Philip Dunstan <phil@philipdunstan.com> llvm-svn: 179126
Diffstat (limited to 'clang/unittests/ASTMatchers/ASTMatchersTest.cpp')
-rw-r--r--clang/unittests/ASTMatchers/ASTMatchersTest.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/clang/unittests/ASTMatchers/ASTMatchersTest.cpp b/clang/unittests/ASTMatchers/ASTMatchersTest.cpp
index 82f349fb0e8..24438a2ee4f 100644
--- a/clang/unittests/ASTMatchers/ASTMatchersTest.cpp
+++ b/clang/unittests/ASTMatchers/ASTMatchersTest.cpp
@@ -1500,6 +1500,27 @@ TEST(Matcher, MatchesAccessSpecDecls) {
EXPECT_TRUE(notMatches("class C { int i; };", accessSpecDecl()));
}
+TEST(Matcher, MatchesVirtualMethod) {
+ EXPECT_TRUE(matches("class X { virtual int f(); };",
+ methodDecl(isVirtual(), hasName("::X::f"))));
+ EXPECT_TRUE(notMatches("class X { int f(); };",
+ methodDecl(isVirtual())));
+}
+
+TEST(Matcher, MatchesOverridingMethod) {
+ EXPECT_TRUE(matches("class X { virtual int f(); }; "
+ "class Y : public X { int f(); };",
+ methodDecl(isOverride(), hasName("::Y::f"))));
+ EXPECT_TRUE(notMatches("class X { virtual int f(); }; "
+ "class Y : public X { int f(); };",
+ methodDecl(isOverride(), hasName("::X::f"))));
+ EXPECT_TRUE(notMatches("class X { int f(); }; "
+ "class Y : public X { int f(); };",
+ methodDecl(isOverride())));
+ EXPECT_TRUE(notMatches("class X { int f(); int f(int); }; ",
+ methodDecl(isOverride())));
+}
+
TEST(Matcher, ConstructorCall) {
StatementMatcher Constructor = constructExpr();
OpenPOWER on IntegriCloud