[cfe-dev] [PATCH] scan-build: fix arguments for make and gmake

Andrey Vagin avagin at openvz.org
Fri Jun 21 04:45:59 PDT 2013


CC and CCX must be set not only for the IgnoreErrors case.

This patch fixes a case when CC is defined in Makefile, because
a value form the environment variable has smaller priority than makefile
definition.

"""
The priority of assignments is from least binding to most binding; the
* precedence of assignments is:
* internal definitions
* environment
* makefile(s)
* command line
"""

This bug was found by Roman Kagan <rkagan at parallels.com>.

Signed-off-by: Andrey Vagin <avagin at openvz.org>
---
 tools/scan-build/scan-build | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/tools/scan-build/scan-build b/tools/scan-build/scan-build
index 22d5289..cb79903 100755
--- a/tools/scan-build/scan-build
+++ b/tools/scan-build/scan-build
@@ -1017,10 +1017,10 @@ sub RunBuildCommand {
     shift @$Args;
     unshift @$Args, $CXXAnalyzer;
   }
-  elsif ($IgnoreErrors) {
-    if ($Cmd eq "make" or $Cmd eq "gmake") {
-      AddIfNotPresent($Args, "CC=$CCAnalyzer");
-      AddIfNotPresent($Args, "CXX=$CXXAnalyzer");
+  elsif ($Cmd eq "make" or $Cmd eq "gmake") {
+    AddIfNotPresent($Args, "CC=$CCAnalyzer");
+    AddIfNotPresent($Args, "CXX=$CXXAnalyzer");
+    if ($IgnoreErrors) {
       AddIfNotPresent($Args,"-k");
       AddIfNotPresent($Args,"-i");
     }
-- 
1.8.2.1




More information about the cfe-dev mailing list