[cfe-commits] r165273 - in /cfe/trunk: lib/CodeGen/CodeGenFunction.cpp test/CodeGen/catch-undef-behavior.c test/CodeGenCXX/catch-undef-behavior.cpp test/CodeGenCXX/return.cpp

David Blaikie dblaikie at gmail.com
Wed Jan 23 11:00:46 PST 2013


>> > The right way to handle this is with appropriate annotations. This is
>> > simply
>> > not a good argument for emitting unreachable.
>>
>> The only reason LLVM/Clang have all those unreachables annotating the
>> end of functions is because of simplistic GCC warning. For codebases
>> that build Clang only it seems quite likely that those would not be
>> present. I don't really see how "users should be annotating these
>> things" is sufficient - users get all sorts of other optimizations
>> that the language allows without having to be explicit about that.
>
>
> If the only reason the annotations are there is for the simple GCC warning
> then as Argyrios points out a compiler analysis can do the optimization
> already.

Except it can't - the Clang warning optimistically assumes that enums
can only hold the enumerants but the standard allows them to contain
all values in the representable value's range. It's perfectly possible
that the enum could currently have other values - so, sure, we could
restrict the trap/unreachable to the subset of cases we think have a
better chance of being actually unreachable but that seems more than a
tad subtle & we still have bogus results in other cases.

- David



More information about the cfe-commits mailing list