mirror of
https://github.com/llvm/llvm-project.git
synced 2025-05-03 10:56:06 +00:00
For -Woverloaded-virtual take into account canonical methods. Fixes rdar://8979966 & http://llvm.org/PR9182.
llvm-svn: 125296
This commit is contained in:
parent
77224a5422
commit
7dd856a76b
@ -2827,6 +2827,7 @@ static bool FindHiddenVirtualMethod(const CXXBaseSpecifier *Specifier,
|
|||||||
++Path.Decls.first) {
|
++Path.Decls.first) {
|
||||||
NamedDecl *D = *Path.Decls.first;
|
NamedDecl *D = *Path.Decls.first;
|
||||||
if (CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(D)) {
|
if (CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(D)) {
|
||||||
|
MD = MD->getCanonicalDecl();
|
||||||
foundSameNameMethod = true;
|
foundSameNameMethod = true;
|
||||||
// Interested only in hidden virtual methods.
|
// Interested only in hidden virtual methods.
|
||||||
if (!MD->isVirtual())
|
if (!MD->isVirtual())
|
||||||
@ -2871,10 +2872,10 @@ void Sema::DiagnoseHiddenVirtualMethods(CXXRecordDecl *DC, CXXMethodDecl *MD) {
|
|||||||
for (CXXMethodDecl::method_iterator I = MD->begin_overridden_methods(),
|
for (CXXMethodDecl::method_iterator I = MD->begin_overridden_methods(),
|
||||||
E = MD->end_overridden_methods();
|
E = MD->end_overridden_methods();
|
||||||
I != E; ++I)
|
I != E; ++I)
|
||||||
Data.OverridenAndUsingBaseMethods.insert(*I);
|
Data.OverridenAndUsingBaseMethods.insert((*I)->getCanonicalDecl());
|
||||||
if (UsingShadowDecl *shad = dyn_cast<UsingShadowDecl>(*res.first))
|
if (UsingShadowDecl *shad = dyn_cast<UsingShadowDecl>(*res.first))
|
||||||
if (CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(shad->getTargetDecl()))
|
if (CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(shad->getTargetDecl()))
|
||||||
Data.OverridenAndUsingBaseMethods.insert(MD);
|
Data.OverridenAndUsingBaseMethods.insert(MD->getCanonicalDecl());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DC->lookupInBases(&FindHiddenVirtualMethod, &Data, Paths) &&
|
if (DC->lookupInBases(&FindHiddenVirtualMethod, &Data, Paths) &&
|
||||||
|
@ -39,3 +39,16 @@ struct S4 : public B4 {
|
|||||||
void foo(float);
|
void foo(float);
|
||||||
void foo();
|
void foo();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
namespace PR9182 {
|
||||||
|
struct Base {
|
||||||
|
virtual void foo(int);
|
||||||
|
};
|
||||||
|
|
||||||
|
void Base::foo(int) { }
|
||||||
|
|
||||||
|
struct Derived : public Base {
|
||||||
|
virtual void foo(int);
|
||||||
|
void foo(int, int);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user