From 95aa1050cd170f9729ca66a1b2e2f0219458671e Mon Sep 17 00:00:00 2001 From: Ted Kremenek Date: Thu, 4 Sep 2008 17:52:41 +0000 Subject: [PATCH] scan-build: - Only set the environment variable 'CXX' if the user specifies --use-c++. - Fix regression when setting LDPLUSPLUS: add a 'which' to determine the location of g++. This regression was pointed out by Jordan Breeding! git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@55780 91177308-0d34-0410-b5e6-96231b3b80d8 --- utils/scan-build | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/utils/scan-build b/utils/scan-build index 705ad2cd68..540a60b2f3 100755 --- a/utils/scan-build +++ b/utils/scan-build @@ -24,7 +24,7 @@ my $Verbose = 0; # Verbose output from this script. my $Prog = "scan-build"; my $BuildName; my $BuildDate; -my $CXX = 'g++'; +my $CXX; # Leave undefined initially. my $UseColor = ((($ENV{'TERM'} eq 'xterm-color') and -t STDOUT) and defined($ENV{'SCAN_BUILD_COLOR'})); @@ -692,7 +692,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. - my $LDPLUSPLUS = `$CXX`; + die if (!defined $CXX); + my $LDPLUSPLUS = `which $CXX`; $LDPLUSPLUS =~ s/\015?\012//; # strip newlines $ENV{'LDPLUSPLUS'} = $LDPLUSPLUS; } @@ -917,7 +918,14 @@ if (! -x $ClangSB) { Diag("Using 'clang' from path.\n"); } -$ENV{'CXX'} = $CXX; +if (defined $CXX) { + $ENV{'CXX'} = $CXX; +} +else { + $CXX = 'g++'; # This variable is used by other parts of scan-build + # that need to know a default C++ compiler to fall back to. +} + $ENV{'CC'} = $Cmd; $ENV{'CLANG'} = $Clang; -- 2.40.0