From c896a8f33ca64b7b8631f9e0715323aadccaead5 Mon Sep 17 00:00:00 2001 From: Paul Khuong Date: Tue, 5 May 2020 11:33:25 -0400 Subject: [PATCH] ck_pr: default to cc builtin implementations for static analysers --- configure | 2 +- include/ck_pr.h | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/configure b/configure index ed188f9..7fadc6b 100755 --- a/configure +++ b/configure @@ -202,7 +202,7 @@ for option; do echo " --memory-model=N Specify memory model (currently tso, pso or rmo)" echo " --vma-bits=N Specify valid number of VMA bits" echo " --platform=N Force the platform type, instead of relying on autodetection" - echo " --use-cc-builtins Use the compiler atomic bultin functions, instead of the CK implementation" + echo " --use-cc-builtins Use the compiler atomic builtin functions, instead of the CK implementation" echo " --disable-double Don't generate any of the functions using the \"double\" type" echo echo "The following options will affect specific platform-dependent generated code." diff --git a/include/ck_pr.h b/include/ck_pr.h index 2de6e13..8ebf855 100644 --- a/include/ck_pr.h +++ b/include/ck_pr.h @@ -34,7 +34,20 @@ #include #include -#ifndef CK_USE_CC_BUILTINS +/* + * Default to using builtins for clang analyzer, coverity, and sparse: + * inline assembly is often too opaque for useful analysis. Override + * the defaults by defining CK_USE_CC_BUILTINS=0 or 1. + */ +#if !defined(CK_USE_CC_BUILTINS) +#if defined(__clang_analyzer__) || defined(__COVERITY__) || defined(__CHECKER__) +#define CK_USE_CC_BUILTINS 1 +#else +#define CK_USE_CC_BUILTINS 0 +#endif +#endif + +#if !CK_USE_CC_BUILTINS #if defined(__x86_64__) #include "gcc/x86_64/ck_pr.h" #elif defined(__x86__)