Further restrict issuance of 'override' warning if method

is argument to a macro which is defined in system header.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@221172 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Fariborz Jahanian 2014-11-03 19:46:18 +00:00
parent eb46a586b6
commit 4f98f2cb15
3 changed files with 12 additions and 5 deletions

View File

@ -1905,11 +1905,13 @@ void Sema::DiagnoseAbsenceOfOverrideControl(NamedDecl *D) {
isa<CXXDestructorDecl>(MD))
return;
if (MD->getLocation().isMacroID()) {
SourceLocation MacroLoc = getSourceManager().getSpellingLoc(MD->getLocation());
if (getSourceManager().isInSystemHeader(MacroLoc))
SourceLocation Loc = MD->getLocation();
SourceLocation SpellingLoc = Loc;
if (getSourceManager().isMacroArgExpansion(Loc))
SpellingLoc = getSourceManager().getImmediateExpansionRange(Loc).first;
SpellingLoc = getSourceManager().getSpellingLoc(SpellingLoc);
if (SpellingLoc.isValid() && getSourceManager().isInSystemHeader(SpellingLoc))
return;
}
if (MD->size_overridden_methods() > 0) {
Diag(MD->getLocation(), diag::warn_function_marked_not_override_overriding)

View File

@ -1,3 +1,6 @@
// override-system-header.h to test out 'override' warning.
// rdar://18295240
#define END_COM_MAP virtual unsigned AddRef(void) = 0;
#define STDMETHOD(method) virtual void method
#define IFACEMETHOD(method) STDMETHOD(method)

View File

@ -8,10 +8,12 @@ struct A
{
virtual void x();
END_COM_MAP;
IFACEMETHOD(Initialize)();
};
struct B : A
{
virtual void x() override;
END_COM_MAP;
IFACEMETHOD(Initialize)();
};