Implement G_ANALYZER_NORETURN for Coverity

This change is proposed by Kamil Dudka. It teaches Coverity to assume
that g_critical() will never return, which is desirable for the same
reasons it is for scan-build: once you've triggered undefined behavior,
the game is already lost, and there's limited benefit from trying to
avoid every possible memory leak on such codepaths. Notably, this
affects g_return_if_fail().

Arguably it might be desirable to fix every such issue, but if we're
already not doing so for scan-build, it doesn't make sense to hold
developers working with Coverity to a higher standard. This allows
focusing on more serious issues found by Coverity.

Thanks Kamil!
This commit is contained in:
Michael Catanzaro 2021-04-08 11:34:21 -05:00
parent 80c2981b62
commit f97ff20adf

View File

@ -760,6 +760,9 @@
#if g_macro__has_feature(attribute_analyzer_noreturn) && defined(__clang_analyzer__) #if g_macro__has_feature(attribute_analyzer_noreturn) && defined(__clang_analyzer__)
#define G_ANALYZER_ANALYZING 1 #define G_ANALYZER_ANALYZING 1
#define G_ANALYZER_NORETURN __attribute__((analyzer_noreturn)) #define G_ANALYZER_NORETURN __attribute__((analyzer_noreturn))
#elif defined(__COVERITY__)
#define G_ANALYZER_ANALYZING 1
#define G_ANALYZER_NORETURN __attribute__((noreturn))
#else #else
#define G_ANALYZER_ANALYZING 0 #define G_ANALYZER_ANALYZING 0
#define G_ANALYZER_NORETURN #define G_ANALYZER_NORETURN