From: Samuel Benzaquen Date: Fri, 6 Mar 2015 16:24:47 +0000 (+0000) Subject: Fix isOverride() for the case of a dependent typed base class. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7aed51eb5771c2ba9004d4c099cd1c17ed401ab1;p=clang Fix isOverride() for the case of a dependent typed base class. The method decl is not marked as overriding any other method decls until the template is instantiated. Use the override attribute as another signal. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@231487 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/ASTMatchers/ASTMatchers.h b/include/clang/ASTMatchers/ASTMatchers.h index f317981517..4501a42149 100644 --- a/include/clang/ASTMatchers/ASTMatchers.h +++ b/include/clang/ASTMatchers/ASTMatchers.h @@ -2993,7 +2993,7 @@ AST_MATCHER(CXXMethodDecl, isConst) { /// \endcode /// matches B::x AST_MATCHER(CXXMethodDecl, isOverride) { - return Node.size_overridden_methods() > 0; + return Node.size_overridden_methods() > 0 || Node.hasAttr(); } /// \brief Matches member expressions that are called with '->' as opposed diff --git a/unittests/ASTMatchers/ASTMatchersTest.cpp b/unittests/ASTMatchers/ASTMatchersTest.cpp index 0d27b5db03..dab22e33cd 100644 --- a/unittests/ASTMatchers/ASTMatchersTest.cpp +++ b/unittests/ASTMatchers/ASTMatchersTest.cpp @@ -1790,6 +1790,9 @@ TEST(Matcher, MatchesOverridingMethod) { methodDecl(isOverride()))); EXPECT_TRUE(notMatches("class X { int f(); int f(int); }; ", methodDecl(isOverride()))); + EXPECT_TRUE( + matches("template struct Y : Base { void f() override;};", + methodDecl(isOverride(), hasName("::Y::f")))); } TEST(Matcher, ConstructorCall) {