r220992 - C++-11 [qoi]. Do not warn on missing 'verride' on use of

jahanian fjahanian at apple.com
Mon Nov 3 11:57:36 PST 2014


On Oct 31, 2014, at 4:28 PM, Nico Weber <thakis at chromium.org> wrote:

> Thanks!
> 
> Here's an example where the method name isn't from a macro expansion, but it's still a macro argument. Could the warning be suppressed here too?

In r221172.
- Fariborz

> 
> ..\..\win8/metro_driver/chrome_app_view_ash.h(65,15) :  warning(clang): 'Initialize' overrides a member function but is not marked 'override' [-Winconsistent-missing-override]
>   IFACEMETHOD(Initialize)(winapp::Core::ICoreApplicationView* view);
>               ^
> C:\b\depot_tools\win_toolchain\vs2013_files\win8sdk/Include/um\combaseapi.h(217,58) :  note(clang): expanded from macro 'IFACEMETHOD'
> #define IFACEMETHOD(method)         __override STDMETHOD(method)
>                                                          ^
> C:\b\depot_tools\win_toolchain\vs2013_files\win8sdk/Include/um\combaseapi.h(205,89) :  note(clang): expanded from macro 'STDMETHOD'
> #define STDMETHOD(method)        virtual COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE method
>                                                                                         ^
> C:\b\depot_tools\win_toolchain\vs2013_files\win8sdk/Include/winrt/Windows.ApplicationModel.Core.h(1179,59) :  note(clang): overridden virtual function is here
>                         virtual HRESULT STDMETHODCALLTYPE Initialize( 
>                                                           ^
> 
> On Fri, Oct 31, 2014 at 12:56 PM, Fariborz Jahanian <fjahanian at apple.com> wrote:
> Author: fjahanian
> Date: Fri Oct 31 14:56:27 2014
> New Revision: 220992
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=220992&view=rev
> Log:
> C++-11 [qoi]. Do not warn on missing 'verride' on use of
> macros in user code when macros themselves are defined
> in a system header. rdar://18295240
> 
> Added:
>     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
> 
> Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=220992&r1=220991&r2=220992&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Fri Oct 31 14:56:27 2014
> @@ -1905,6 +1905,12 @@ void Sema::DiagnoseAbsenceOfOverrideCont
>        isa<CXXDestructorDecl>(MD))
>      return;
> 
> +  if (MD->getLocation().isMacroID()) {
> +    SourceLocation MacroLoc = getSourceManager().getSpellingLoc(MD->getLocation());
> +    if (getSourceManager().isInSystemHeader(MacroLoc))
> +      return;
> +  }
> +
>    if (MD->size_overridden_methods() > 0) {
>      Diag(MD->getLocation(), diag::warn_function_marked_not_override_overriding)
>        << MD->getDeclName();
> 
> Added: 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=220992&view=auto
> ==============================================================================
> --- cfe/trunk/test/SemaCXX/Inputs/override-system-header.h (added)
> +++ cfe/trunk/test/SemaCXX/Inputs/override-system-header.h Fri Oct 31 14:56:27 2014
> @@ -0,0 +1,3 @@
> +// override-system-header.h to test out 'override' warning.
> +// rdar://18295240
> +#define END_COM_MAP virtual unsigned AddRef(void) = 0;
> 
> Added: 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=220992&view=auto
> ==============================================================================
> --- cfe/trunk/test/SemaCXX/override-in-system-header.cpp (added)
> +++ cfe/trunk/test/SemaCXX/override-in-system-header.cpp Fri Oct 31 14:56:27 2014
> @@ -0,0 +1,17 @@
> +// RUN: %clang_cc1 -std=c++11 -isystem %S/Inputs %s -verify
> +// expected-no-diagnostics
> +// rdar://18295240
> +
> +#include <override-system-header.h>
> +
> +struct A
> +{
> +  virtual void x();
> +  END_COM_MAP;
> +};
> +
> +struct B : A
> +{
> +  virtual void x() override;
> +  END_COM_MAP;
> +};
> 
> 
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20141103/cc91b492/attachment.html>


More information about the cfe-commits mailing list