r350856 - Split -Wdelete-non-virtual-dtor into two groups
David Blaikie via cfe-commits
cfe-commits at lists.llvm.org
Sun Jan 13 17:28:34 PST 2019
Might be handy to summarize the changes from the previous reverted version
of this patch (& mention the original commit revision and revert revision)
- in the commit message is ideal, but in a reply to the commit after the
fact will do in a pinch
On Fri, Jan 11, 2019 at 4:06 AM Erik Pilkington via cfe-commits <
cfe-commits at lists.llvm.org> wrote:
> Author: epilk
> Date: Thu Jan 10 10:03:07 2019
> New Revision: 350856
>
> URL: http://llvm.org/viewvc/llvm-project?rev=350856&view=rev
> Log:
> Split -Wdelete-non-virtual-dtor into two groups
>
> This group controls two diagnostics: deleting an abstract class with
> a non-virtual dtor, which is a guaranteed crash, and deleting a
> non-abstract polymorphic class with a non-virtual dtor, which is just
> suspicious.
>
> rdar://40380564
>
> Differential revision: https://reviews.llvm.org/D56405
>
> Added:
> cfe/trunk/test/SemaCXX/delete-non-virtual-dtor.cpp
> Modified:
> cfe/trunk/include/clang/Basic/DiagnosticGroups.td
> cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
>
> Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=350856&r1=350855&r2=350856&view=diff
>
> ==============================================================================
> --- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
> +++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Thu Jan 10 10:03:07
> 2019
> @@ -104,7 +104,11 @@ def UndefinedFuncTemplate : DiagGroup<"u
> def MissingNoEscape : DiagGroup<"missing-noescape">;
>
> def DeleteIncomplete : DiagGroup<"delete-incomplete">;
> -def DeleteNonVirtualDtor : DiagGroup<"delete-non-virtual-dtor">;
> +def DeleteNonAbstractNonVirtualDtor :
> DiagGroup<"delete-non-abstract-non-virtual-dtor">;
> +def DeleteAbstractNonVirtualDtor :
> DiagGroup<"delete-abstract-non-virtual-dtor">;
> +def DeleteNonVirtualDtor : DiagGroup<"delete-non-virtual-dtor",
> + [DeleteNonAbstractNonVirtualDtor,
> + DeleteAbstractNonVirtualDtor]>;
> def AbstractFinalClass : DiagGroup<"abstract-final-class">;
>
> def CXX11CompatDeprecatedWritableStr :
>
> Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=350856&r1=350855&r2=350856&view=diff
>
> ==============================================================================
> --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
> +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Thu Jan 10
> 10:03:07 2019
> @@ -6455,12 +6455,12 @@ def warn_non_virtual_dtor : Warning<
> def warn_delete_non_virtual_dtor : Warning<
> "%select{delete|destructor}0 called on non-final %1 that has "
> "virtual functions but non-virtual destructor">,
> - InGroup<DeleteNonVirtualDtor>, DefaultIgnore, ShowInSystemHeader;
> + InGroup<DeleteNonAbstractNonVirtualDtor>, DefaultIgnore,
> ShowInSystemHeader;
> def note_delete_non_virtual : Note<
> "qualify call to silence this warning">;
> def warn_delete_abstract_non_virtual_dtor : Warning<
> "%select{delete|destructor}0 called on %1 that is abstract but has "
> - "non-virtual destructor">, InGroup<DeleteNonVirtualDtor>,
> ShowInSystemHeader;
> + "non-virtual destructor">, InGroup<DeleteAbstractNonVirtualDtor>,
> ShowInSystemHeader;
> def warn_overloaded_virtual : Warning<
> "%q0 hides overloaded virtual %select{function|functions}1">,
> InGroup<OverloadedVirtual>, DefaultIgnore;
>
> Added: cfe/trunk/test/SemaCXX/delete-non-virtual-dtor.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/delete-non-virtual-dtor.cpp?rev=350856&view=auto
>
> ==============================================================================
> --- cfe/trunk/test/SemaCXX/delete-non-virtual-dtor.cpp (added)
> +++ cfe/trunk/test/SemaCXX/delete-non-virtual-dtor.cpp Thu Jan 10 10:03:07
> 2019
> @@ -0,0 +1,30 @@
> +// RUN: %clang_cc1 %s -verify -DDIAG1
> +// RUN: %clang_cc1 %s -verify -DDIAG1 -DDIAG2 -Wdelete-non-virtual-dtor
> +// RUN: %clang_cc1 %s -verify -DDIAG1 -Wmost
> -Wno-delete-non-abstract-non-virtual-dtor
> +// RUN: %clang_cc1 %s -verify -DDIAG2 -Wmost
> -Wno-delete-abstract-non-virtual-dtor
> +// RUN: %clang_cc1 %s -verify -Wmost
> -Wno-delete-non-virtual-dtor
> +
> +#ifndef DIAG1
> +#ifndef DIAG2
> +// expected-no-diagnostics
> +#endif
> +#endif
> +
> +struct S1 {
> + ~S1() {}
> + virtual void abs() = 0;
> +};
> +
> +void f1(S1 *s1) { delete s1; }
> +#ifdef DIAG1
> +// expected-warning at -2 {{delete called on 'S1' that is abstract but has
> non-virtual destructor}}
> +#endif
> +
> +struct S2 {
> + ~S2() {}
> + virtual void real() {}
> +};
> +void f2(S2 *s2) { delete s2; }
> +#ifdef DIAG2
> +// expected-warning at -2 {{delete called on non-final 'S2' that has
> virtual functions but non-virtual destructor}}
> +#endif
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190114/0801ff12/attachment.html>
More information about the cfe-commits
mailing list