diff options
author | Edwin Vane <edwin.vane@intel.com> | 2013-04-09 20:46:36 +0000 |
---|---|---|
committer | Edwin Vane <edwin.vane@intel.com> | 2013-04-09 20:46:36 +0000 |
commit | 5771a2f0830228ac50e3473740e24d9dca67b54f (patch) | |
tree | cae2c0ba487459d8e0881211962a6bc76008036b /unittests | |
parent | cd6dcb3434d77b1f652416f2b5c3c62394f1472c (diff) |
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>
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@179126 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests')
-rw-r--r-- | unittests/ASTMatchers/ASTMatchersTest.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/unittests/ASTMatchers/ASTMatchersTest.cpp b/unittests/ASTMatchers/ASTMatchersTest.cpp index 82f349fb0e..24438a2ee4 100644 --- a/unittests/ASTMatchers/ASTMatchersTest.cpp +++ b/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(); |