From: Ted Kremenek Date: Sat, 27 Mar 2010 00:20:01 +0000 (+0000) Subject: scan-build: set environment variable LDPLUSPLUS to 'c++-analyzer' to correctly link... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=524c308506e77e173092e87a0724a27817311428;p=clang scan-build: set environment variable LDPLUSPLUS to 'c++-analyzer' to correctly link projects with c++ code. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99684 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/tools/scan-build/scan-build b/tools/scan-build/scan-build index 432456b15f..8a7afbb3ea 100755 --- a/tools/scan-build/scan-build +++ b/tools/scan-build/scan-build @@ -783,6 +783,7 @@ sub RunBuildCommand { my $IgnoreErrors = shift; my $Cmd = $Args->[0]; my $CCAnalyzer = shift; + my $CXXAnalyzer = shift; # Get only the part of the command after the last '/'. if ($Cmd =~ /\/([^\/]+)$/) { @@ -809,12 +810,12 @@ sub RunBuildCommand { $ENV{"CCC_CXX"} = $1; } shift @$Args; - unshift @$Args, $CCAnalyzer; + unshift @$Args, $CXXAnalyzer; } elsif ($IgnoreErrors) { if ($Cmd eq "make" or $Cmd eq "gmake") { AddIfNotPresent($Args, "CC=$CCAnalyzer"); - AddIfNotPresent($Args, "CXX=$CCAnalyzer"); + AddIfNotPresent($Args, "CXX=$CXXAnalyzer"); AddIfNotPresent($Args,"-k"); AddIfNotPresent($Args,"-i"); } @@ -845,7 +846,8 @@ sub RunBuildCommand { # When 'CC' is set, xcodebuild uses it to do all linking, even if we are # linking C++ object files. Set 'LDPLUSPLUS' so that xcodebuild uses 'g++' - # when linking such files. + # (via c++-analyzer) when linking such files. + $ENV{"LDPLUSPLUS"} = $CXXAnalyzer; } return (system(@$Args) >> 8); @@ -1232,9 +1234,8 @@ if (defined $OutputFormat) { $ENV{'CCC_ANALYZER_OUTPUT_FORMAT'} = $OutputFormat; } - # Run the build. -my $ExitStatus = RunBuildCommand(\@ARGV, $IgnoreErrors, $Cmd); +my $ExitStatus = RunBuildCommand(\@ARGV, $IgnoreErrors, $Cmd, $CmdCXX); if (defined $OutputFormat) { if ($OutputFormat =~ /plist/) {