]> granicus.if.org Git - clang/commitdiff
Further restrict issuance of 'override' warning if method
authorFariborz Jahanian <fjahanian@apple.com>
Mon, 3 Nov 2014 19:46:18 +0000 (19:46 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Mon, 3 Nov 2014 19:46:18 +0000 (19:46 +0000)
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

lib/Sema/SemaDeclCXX.cpp
test/SemaCXX/Inputs/override-system-header.h
test/SemaCXX/override-in-system-header.cpp

index 0fae8c86d1b275a48720234c7022c085a588eab7..c11574519663ac5e981f6ebade7218f704a87e8a 100644 (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();
index 9a1bde5a26b31e8a1de2e5f9946eb62f411d16d2..9831ab7952b1a88745e523331b43f728c2ae8d4e 100644 (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)
index 88c53e4430a4076ea85481e902583fb714047f6d..689585e0cf12c80a69286aa05a46ccc09ccb7ad1 100644 (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)();
 };