aaronpuchert wrote:

> There is one clang-tidy check (bugprone-switch-missing-default-case) also for 
> this feature.

This excludes enumeration types though, while GCC `-Wswitch-default` warns on 
them as well. (Even if all enumeration values are covered.)

> whether switch statements should have a default is not something the industry 
> seem to agree on, so it would be a very opinionated warning.

Yes. Though I have to say, even though I'm squarely in the 
`-Wcovered-switch-default` camp (i.e. no `default` label in switches that cover 
all enumeration values), I think it's still valuable to have this warning 
because some style guides/policies demand a `default`, and it is very little 
effort on our side to maintain this.

I understand the policy against off-by-default warnings to avoid crowding the 
core compiler, but this is essentially just two lines of code, and if GCC has 
it we're not going out on a limb here. And since we already seem to support the 
flag for GCC compatibility, we might as well make it work if it's that easy.

> LLVM development heavily relies on `-Wswitch-enum`, for example.

I think we're using `-Wswitch`, as `-Wswitch-enum` requires to cover all 
enumeration values even if there is a default label. Our policy is: cover all 
enumeration values or have a `default`. This is "enforced" by `-Wswitch` in 
combination with `-Wcovered-switch-default`.

https://github.com/llvm/llvm-project/pull/73077
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to