Further restrict issuance of 'override' warning if method
is argument to a macro which is defined in system header.
llvm-svn: 221172
diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index 0fae8c8..c115745 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -1905,12 +1905,14 @@
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();