[PATCH] D61288: [Diagnostics] Implemented support for -Wswitch-default

Roman Lebedev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed May 1 06:45:05 PDT 2019


lebedev.ri added a comment.

In D61288#1486008 <https://reviews.llvm.org/D61288#1486008>, @aaron.ballman wrote:

> In D61288#1486006 <https://reviews.llvm.org/D61288#1486006>, @xbolva00 wrote:
>
> > Some coding guidelines may require switch to have always default label. Even if devs know that default is not reachable, they can add default: abort(); or assert to increase safety (and warning will be silenced).
> >
> > Yes, it not suitable to be enabled by default, but I still think it is good to have it.
>
>
> We typically don't add new, default-off warnings because experience has shown that users don't enable them. The coding guidelines argument is somewhat persuasive, but I wonder whether this is better handled through clang-tidy checks rather than the compiler itself -- that's where we put other diagnostics that may not be suitable for the compiler. Have you thought about surfacing this functionality that way?


I honestly have to agree. I think it would be best as a clang-tidy check, because i can fully envision the exact opposite guideline, "avoid `default` so you get notified about every switch that needs to be updated".


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D61288/new/

https://reviews.llvm.org/D61288





More information about the cfe-commits mailing list