On 22.04.2013 23:51, Jordan Rose wrote:
Better MinGW support is certainly welcome! A few comments, though...
================
Comment at: tools/scan-build/scan-build:1563
@@ -1562,3 +1562,3 @@
$ClangCXX = $Clang;
-$ClangCXX =~ s/\-\d+\.\d+$//;
-$ClangCXX .= "++";
+if($^O =~/msys/) {
+ $ClangCXX =~ s/.exe$/++.exe/;
----------------
Not being a native Perl hacker, I found this a bit confusing. `$OSNAME` would
have been a bit friendlier.
Also, this check //only// handles MinGW, correct?
http://perldoc.perl.org/perlvar.html#General-Variables says that native Windows returns
"MSWin32" here.
================
Comment at: tools/scan-build/c++-analyzer.win:3
@@ +2,2 @@
+
+system ("ccc-analyzer @ARGV");
----------------
The reason we have c++-analyzer at all is so that we can set run the underlying
compilation with a C++ compiler. Simply forwarding c++-analyzer.win to
ccc-analyzer won't actually accomplish that -- you'll have to add a flag or
enviroment variable check to ccc-analyzer, which c++-analyzer.win can set
before invoking ccc-analyzer.
Also, are you sure this won't destroy arguments with spaces in them? (You can test with
something like `"-DSTR=macro with spaces"`.)
http://llvm-reviews.chandlerc.com/D703
Thanx for the review, all of your fears were confirmed.
Attached is a new patch.
Temporary excluded phabricator from recipients.
--
Anton
Index: tools/scan-build/c++-analyzer
===================================================================
--- tools/scan-build/c++-analyzer (revision 180263)
+++ tools/scan-build/c++-analyzer (working copy)
@@ -1 +1,14 @@
-link ccc-analyzer
\ No newline at end of file
+#!/usr/bin/env perl
+
+use FindBin;
+
+# tell ccc-analyzer that it was launched from this script
+$ENV{'CCC_ANALYZER_CALLER'} = $FindBin::Script;
+
+# add quotes around arguments to correctly transfer arguments with spaces
+my @ARGV_QUOTED = ();
+foreach my $arg (@ARGV) {
+ push(@ARGV_QUOTED, "\"$arg\"");
+}
+
+system ("ccc-analyzer @ARGV_QUOTED");
Index: tools/scan-build/ccc-analyzer
===================================================================
--- tools/scan-build/ccc-analyzer (revision 180263)
+++ tools/scan-build/ccc-analyzer (working copy)
@@ -14,7 +14,6 @@
use strict;
use warnings;
-use FindBin;
use Cwd qw/ getcwd abs_path /;
use File::Temp qw/ tempfile /;
use File::Path qw / mkpath /;
@@ -38,7 +37,7 @@
$DefaultCXXCompiler = 'g++';
}
-if ($FindBin::Script =~ /c\+\+-analyzer/) {
+if ($ENV{'CCC_ANALYZER_CALLER'} =~ /c\+\+-analyzer/ ) {
$Compiler = $ENV{'CCC_CXX'};
if (!defined $Compiler) { $Compiler = $DefaultCXXCompiler; }
Index: tools/scan-build/scan-build
===================================================================
--- tools/scan-build/scan-build (revision 180263)
+++ tools/scan-build/scan-build (working copy)
@@ -22,6 +22,7 @@
use Term::ANSIColor qw(:constants);
use Cwd qw/ getcwd abs_path /;
use Sys::Hostname;
+use English;
my $Verbose = 0; # Verbose output from this script.
my $Prog = "scan-build";
@@ -44,6 +45,9 @@
my $Date = localtime();
+# tell ccc-analyzer that it was launched from this script
+$ENV{'CCC_ANALYZER_CALLER'} = $FindBin::Script;
+
##----------------------------------------------------------------------------##
# Diagnostics
##----------------------------------------------------------------------------##
@@ -1560,8 +1564,15 @@
}
$ClangCXX = $Clang;
-$ClangCXX =~ s/\-\d+\.\d+$//;
-$ClangCXX .= "++";
+my $IsWinBuild = ($OSNAME =~/msys|cygwin|MSWin32/);
+if($IsWinBuild) {
+ $ClangCXX =~ s/.exe$/++.exe/;
+}
+else {
+ $ClangCXX =~ s/\-\d+\.\d+$//;
+ $ClangCXX .= "++";
+}
+
# Make sure to use "" to handle paths with spaces.
$ClangVersion = HtmlEscape(`"$Clang" --version`);
@@ -1576,16 +1587,17 @@
# Determine the location of ccc-analyzer.
my $AbsRealBin = Cwd::realpath($RealBin);
+my $CXXAnalyzerExecName = "c++-analyzer";
my $Cmd = "$AbsRealBin/libexec/ccc-analyzer";
-my $CmdCXX = "$AbsRealBin/libexec/c++-analyzer";
+my $CmdCXX = "$AbsRealBin/libexec/$CXXAnalyzerExecName";
if (!defined $Cmd || ! -x $Cmd) {
$Cmd = "$AbsRealBin/ccc-analyzer";
DieDiag("Executable 'ccc-analyzer' does not exist at '$Cmd'\n") if(! -x $Cmd);
}
if (!defined $CmdCXX || ! -x $CmdCXX) {
- $CmdCXX = "$AbsRealBin/c++-analyzer";
- DieDiag("Executable 'c++-analyzer' does not exist at '$CmdCXX'\n") if(! -x $CmdCXX);
+ $CmdCXX = "$AbsRealBin/$CXXAnalyzerExecName";
+ DieDiag("Executable '$CXXAnalyzerExecName' does not exist at '$CmdCXX'\n") if(! -x $CmdCXX);
}
Diag("Using '$Clang' for static analysis\n");
Index: tools/scan-build/scan-build.bat
===================================================================
--- tools/scan-build/scan-build.bat (revision 0)
+++ tools/scan-build/scan-build.bat (working copy)
@@ -0,0 +1 @@
+perl -S scan-build %*
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits