[clang] Suppress noreturn warning if last statement in a function is a throw (PR #145166)

Alexander Kornienko via cfe-commits cfe-commits at lists.llvm.org
Tue Jul 15 18:00:46 PDT 2025


alexfh wrote:

> Just out of curiosity, could implementing this warning to be LTO only solve this? Anything requiring whole-program analysis sounds like a task to be done during LTO. IIRC GCC has some warnings that are only made possible by LTO.

I don't think this would be the right direction. First of all, LTO is inherently a more expensive build mode, which (in my surroundings at least) is mostly used for releases, but not in the normal development cycle. Making this diagnostic LTO-only will shift the moment when the corresponding issues are found from development to release build, breaking the latter without showing up earlier. If the release builds are performed automatically on a certain schedule, this will be a very unfortunate moment for the first detection of these problems.

I personally think that relying on explicit `[[noreturn]]` attributes and the `-Wmissing-noreturn` diagnostic to suggest annotating functions that never return should be a more robust approach with less undesired surprises.

https://github.com/llvm/llvm-project/pull/145166


More information about the cfe-commits mailing list