diff options
author | Daniel Thompson <daniel.thompson@linaro.org> | 2022-04-26 16:10:30 +0100 |
---|---|---|
committer | Daniel Thompson <daniel.thompson@linaro.org> | 2022-04-27 11:49:05 +0100 |
commit | f17c56629715199f7e520e06c01b4a46bf95c24d (patch) | |
tree | 39e6bcd88daa1913021856d04accfc558b3762b1 | |
parent | 48bf8eb0107d42c158fdbaec20805f5041492ae7 (diff) |
[RFC] compiler.h: Introduce CC_IS_STATIC_ANALYZER
Provide a means for code to detect and react to being compiled under a
static analyzer. This is not intended for pervasive use but, in some
cases, we can improve the analysis quality by making subtle changes to
how some functions are declared.
Signed-off-by: Daniel Thompson <daniel.thompson@linaro.org>
-rw-r--r-- | include/linux/compiler.h | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/include/linux/compiler.h b/include/linux/compiler.h index 0f7fd205ab7e..4e7b4861d234 100644 --- a/include/linux/compiler.h +++ b/include/linux/compiler.h @@ -220,6 +220,18 @@ void ftrace_likely_update(struct ftrace_likely_data *f, int val, #define function_nocfi(x) (x) #endif +#ifdef __clang_analyzer__ +/* + * Provide a way for macros to optimize themselves for static analyzers. + * Currently this is limited to clang-analyzer since that's what we have + * support for in the kernel build. + * + * Like CONFIG_ options, this macro yields a 1 so that we can reuse the + * same machinery we use to handle config options in C expressions. + */ +#define CC_IS_STATIC_ANALYZER 1 +#endif /* __clang_analyzer__ */ + #endif /* __KERNEL__ */ /* |