boostorg / test

The reference C++ unit testing framework (TDD, xUnit, C++03/11/14/17)
http://boost.org/libs/test
Boost Software License 1.0
183 stars 140 forks source link

Feature request: Integration with clang's __attribute__((analyzer_noreturn)) #380

Open jonesmz opened 1 year ago

jonesmz commented 1 year ago

When running clang-tidy, the analyzer is able to provide much more succinct problem reports when developers can inform the analyzer "if this function is called, stop, that's the bug".

Frequently, boost test based unit tests can give the analyzer fits where it dumps out hundreds or thousands of lines of additional analysis pertaining to the boost test framework, when it should really have stopped at the assertion failing instead of continuing to digest all of the inner machinery from the framework.

To enable this enhanced analysis, it's sufficient to check in the preprocessor

__has_feature(attribute_analyzer_noreturn)

and if that's true, then add

__attribute__((analyzer_noreturn))

to some appropriate function that is only called when a test case fails.