coroutine: annotate coroutine_fn for libclang

Clang has a generic __annotate__ attribute that can be used by
static analyzers to understand properties of functions and
analyze the control flow.  Furthermore, unlike TSA annotations, the
__annotate__ attribute applies to function pointers as well.

As a first step towards static analysis of coroutine_fn markers,
attach the attribute to the marker when compiling with clang.

Signed-off-by: Alberto Faria <afaria@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20221216110758.559947-2-pbonzini@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
Alberto Faria 2022-12-16 12:07:57 +01:00 committed by Kevin Wolf
parent a4b15a8b9e
commit cbdbc47cee
1 changed files with 4 additions and 0 deletions

View File

@ -171,7 +171,11 @@ extern "C" {
* ....
* }
*/
#ifdef __clang__
#define coroutine_fn __attribute__((__annotate__("coroutine_fn")))
#else
#define coroutine_fn
#endif
/*
* For mingw, as of v6.0.0, the function implementing the assert macro is