mirror of
https://github.com/swaywm/sway.git
synced 2026-04-27 06:46:25 -04:00
Use clang analyzer_noreturn on assertion handler
If the assertion handler is not tagged, a lot of false positives are generated by clang static analyzer. > The Clang-specific 'analyzer_noreturn' attribute is almost identical > to 'noreturn' except that it is ignored by the compiler for the > purposes of code generation. > > This attribute is useful for annotating assertion handlers that > actually can return, but for the purpose of using the analyzer we > want to pretend that such functions do not return. https://clang-analyzer.llvm.org/annotations.html#custom_assertions
This commit is contained in:
parent
416c6ecb99
commit
08ce2613c8
1 changed files with 10 additions and 1 deletions
|
|
@ -20,6 +20,15 @@ typedef enum {
|
||||||
#define ATTRIB_PRINTF(start, end)
|
#define ATTRIB_PRINTF(start, end)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if !defined(CLANG_ANALYZER_NORETURN) && defined(__has_feature)
|
||||||
|
#if __has_feature(attribute_analyzer_noreturn)
|
||||||
|
#define CLANG_ANALYZER_NORETURN __attribute__((analyzer_noreturn))
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#ifndef CLANG_ANALYZER_NORETURN
|
||||||
|
#define CLANG_ANALYZER_NORETURN
|
||||||
|
#endif
|
||||||
|
|
||||||
void error_handler(int sig);
|
void error_handler(int sig);
|
||||||
|
|
||||||
typedef void (*terminate_callback_t)(int exit_code);
|
typedef void (*terminate_callback_t)(int exit_code);
|
||||||
|
|
@ -31,7 +40,7 @@ void sway_log_init(sway_log_importance_t verbosity, terminate_callback_t termina
|
||||||
void _sway_log(sway_log_importance_t verbosity, const char *format, ...) ATTRIB_PRINTF(2, 3);
|
void _sway_log(sway_log_importance_t verbosity, const char *format, ...) ATTRIB_PRINTF(2, 3);
|
||||||
void _sway_vlog(sway_log_importance_t verbosity, const char *format, va_list args) ATTRIB_PRINTF(2, 0);
|
void _sway_vlog(sway_log_importance_t verbosity, const char *format, va_list args) ATTRIB_PRINTF(2, 0);
|
||||||
void _sway_abort(const char *filename, ...) ATTRIB_PRINTF(1, 2);
|
void _sway_abort(const char *filename, ...) ATTRIB_PRINTF(1, 2);
|
||||||
bool _sway_assert(bool condition, const char* format, ...) ATTRIB_PRINTF(2, 3);
|
bool _sway_assert(bool condition, const char* format, ...) ATTRIB_PRINTF(2, 3) CLANG_ANALYZER_NORETURN;
|
||||||
|
|
||||||
// TODO: get meson to precompute this, for better reproducibility/less overhead
|
// TODO: get meson to precompute this, for better reproducibility/less overhead
|
||||||
const char *_sway_strip_path(const char *filepath);
|
const char *_sway_strip_path(const char *filepath);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue