Further restrict issuance of 'override' warning if method

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

llvm-svn: 221172
This commit is contained in:
Fariborz Jahanian 2014-11-03 19:46:18 +00:00
parent 005505b027
commit e3db7784b6
3 changed files with 12 additions and 5 deletions

View File

@ -1905,12 +1905,14 @@ 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)
<< MD->getDeclName();

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)();
};