r221172 - Further restrict issuance of 'override' warning if method
Fariborz Jahanian
fjahanian at apple.com
Mon Nov 3 11:46:19 PST 2014
Author: fjahanian
Date: Mon Nov 3 13:46:18 2014
New Revision: 221172
URL: http://llvm.org/viewvc/llvm-project?rev=221172&view=rev
Log:
Further restrict issuance of 'override' warning if method
is argument to a macro which is defined in system header.
Modified:
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/test/SemaCXX/Inputs/override-system-header.h
cfe/trunk/test/SemaCXX/override-in-system-header.cpp
Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=221172&r1=221171&r2=221172&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Mon Nov 3 13:46:18 2014
@@ -1905,12 +1905,14 @@ void Sema::DiagnoseAbsenceOfOverrideCont
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();
Modified: cfe/trunk/test/SemaCXX/Inputs/override-system-header.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/Inputs/override-system-header.h?rev=221172&r1=221171&r2=221172&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/Inputs/override-system-header.h (original)
+++ cfe/trunk/test/SemaCXX/Inputs/override-system-header.h Mon Nov 3 13:46:18 2014
@@ -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)
Modified: cfe/trunk/test/SemaCXX/override-in-system-header.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/override-in-system-header.cpp?rev=221172&r1=221171&r2=221172&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/override-in-system-header.cpp (original)
+++ cfe/trunk/test/SemaCXX/override-in-system-header.cpp Mon Nov 3 13:46:18 2014
@@ -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)();
};
More information about the cfe-commits
mailing list