]> granicus.if.org Git - clang/commitdiff
Fix isOverride() for the case of a dependent typed base class.
authorSamuel Benzaquen <sbenza@google.com>
Fri, 6 Mar 2015 16:24:47 +0000 (16:24 +0000)
committerSamuel Benzaquen <sbenza@google.com>
Fri, 6 Mar 2015 16:24:47 +0000 (16:24 +0000)
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

include/clang/ASTMatchers/ASTMatchers.h
unittests/ASTMatchers/ASTMatchersTest.cpp

index f317981517fdaa6cc122340ab85068e35090a74e..4501a42149f6d0629cfc660706a12c31fb4b2aa1 100644 (file)
@@ -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<OverrideAttr>();
 }
 
 /// \brief Matches member expressions that are called with '->' as opposed
index 0d27b5db0348be24a72e3720c0020b3bcd11b772..dab22e33cdaa248c235e24b6d079cd85a6128fc9 100644 (file)
@@ -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 <typename Base> struct Y : Base { void f() override;};",
+              methodDecl(isOverride(), hasName("::Y::f"))));
 }
 
 TEST(Matcher, ConstructorCall) {