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
This commit is contained in:
Samuel Benzaquen 2015-03-06 16:24:47 +00:00
parent 298a3a0567
commit bb5093fefd
2 changed files with 4 additions and 1 deletions

View 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

View 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) {