OSDN Git Service

coroutine: annotate coroutine_fn for libclang
authorAlberto Faria <afaria@redhat.com>
Fri, 16 Dec 2022 11:07:57 +0000 (12:07 +0100)
committerKevin Wolf <kwolf@redhat.com>
Tue, 24 Jan 2023 17:26:41 +0000 (18:26 +0100)
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>
include/qemu/osdep.h

index c850001..d1be7bf 100644 (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