diff options
author | Samuel Benzaquen <sbenza@google.com> | 2015-03-06 16:24:47 +0000 |
---|---|---|
committer | Samuel Benzaquen <sbenza@google.com> | 2015-03-06 16:24:47 +0000 |
commit | bb5093fefdf6c3944e17e5ce2951be5bb5cb49aa (patch) | |
tree | e75a6661bb4102d2079e74cfa4659c86e3bd387b /clang | |
parent | 298a3a05673384d761e0f925f826b1f0646e190a (diff) | |
download | bcm5719-llvm-bb5093fefdf6c3944e17e5ce2951be5bb5cb49aa.tar.gz bcm5719-llvm-bb5093fefdf6c3944e17e5ce2951be5bb5cb49aa.zip |
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.
llvm-svn: 231487
Diffstat (limited to 'clang')
-rw-r--r-- | clang/include/clang/ASTMatchers/ASTMatchers.h | 2 | ||||
-rw-r--r-- | clang/unittests/ASTMatchers/ASTMatchersTest.cpp | 3 |
2 files changed, 4 insertions, 1 deletions
diff --git a/clang/include/clang/ASTMatchers/ASTMatchers.h b/clang/include/clang/ASTMatchers/ASTMatchers.h index f317981517f..4501a42149f 100644 --- a/clang/include/clang/ASTMatchers/ASTMatchers.h +++ b/clang/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<OverrideAttr>(); } /// \brief Matches member expressions that are called with '->' as opposed diff --git a/clang/unittests/ASTMatchers/ASTMatchersTest.cpp b/clang/unittests/ASTMatchers/ASTMatchersTest.cpp index 0d27b5db034..dab22e33cda 100644 --- a/clang/unittests/ASTMatchers/ASTMatchersTest.cpp +++ b/clang/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 <typename Base> struct Y : Base { void f() override;};", + methodDecl(isOverride(), hasName("::Y::f")))); } TEST(Matcher, ConstructorCall) { |