[cfe-dev] [PING][BUG] -Wunreachable-code not working

Artem Dergachev via cfe-dev cfe-dev at lists.llvm.org
Fri Apr 13 11:43:06 PDT 2018



On 4/13/18 7:48 AM, Martin Galvan wrote:
> 2018-04-12 22:53 GMT-03:00 Artem Dergachev <noqnoqneo at gmail.com>:
>> Such suppression might probably be made less brutal, but i'll be surprised
>> if it were possible to get away with not having it at all. And it's pretty
>> tricky to find deadcode before the preprocessor runs, when you're still
>> capable of accidentally concatenating 'ret' and 'urn' into 'return'. So it's
>> not the most pleasant problem to solve, and it's usually not that terrible
>> when we don't give a warning (it's much less terrible than emitting a
>> warning that's not actionable), so people usually make various suppressions
>> for this sort of stuff.
> Agreed, but wouldn't it make more sense that the dead code
> identification happened after the preprocessor is done? I know nothing
> of clang internals, that's just what makes sense to me.

Then it'd produce false alarms on the "WINDOWS" example i posted 
previously. It is inevitable that a deeper analysis that involves 
exploring both a fully constructed syntax tree and rich preprocessor 
information is necessary. Clang does provide such information, but 
probably the deeper analysis is not implemented beyond the "hmm there's 
a macro, let's silence the warning" level of ingenuity.



More information about the cfe-dev mailing list