From 3f2b7d3fe20ddb22efd5748182214514d4a16bc6 Mon Sep 17 00:00:00 2001 From: Pavel Hrdina Date: Mon, 16 Nov 2020 10:57:56 +0100 Subject: [PATCH] src: rework static analysis detection MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Inspired by QEMU code. Signed-off-by: Pavel Hrdina Reviewed-by: Daniel P. Berrangé --- meson.build | 14 -------------- src/internal.h | 4 ++++ 2 files changed, 4 insertions(+), 14 deletions(-) diff --git a/meson.build b/meson.build index 3bc92b0dd5..01e7fbd409 100644 --- a/meson.build +++ b/meson.build @@ -142,20 +142,6 @@ if get_option('test_coverage') endif -# Detect when running under the clang static analyzer's scan-build driver -# or Coverity-prevent's cov-build. Define STATIC_ANALYSIS accordingly. - -rc = run_command( - 'sh', '-c', - 'test -n "${CCC_ANALYZER_HTML}"' + - ' -o -n "${CCC_ANALYZER_ANALYSIS+set}"' + - ' -o -n "$COVERITY_BUILD_COMMAND$COVERITY_LD_PRELOAD"', -) -if rc.returncode() == 0 - conf.set('STATIC_ANALYSIS', 1) -endif - - # Add RPATH information when building for a non-standard prefix, or # when explicitly requested to do so diff --git a/src/internal.h b/src/internal.h index d167e56b48..ff94e7e53e 100644 --- a/src/internal.h +++ b/src/internal.h @@ -29,6 +29,10 @@ #include #include "glibcompat.h" +#if defined __clang_analyzer__ || defined __COVERITY__ +# define STATIC_ANALYSIS 1 +#endif + #if STATIC_ANALYSIS # undef NDEBUG /* Don't let a prior NDEBUG definition cause trouble. */ # include