[PATCH] [PATCH][Review request][analyzer] scan-build for windows

Антон Ярцев anton.yartsev at gmail.com
Mon Apr 22 08:46:29 PDT 2013


Hi jordan_rose,

The patch allows MinGW+MSYS users to launch scan-build without any additional preparations in the same way as it described in http://clang-analyzer.llvm.org/scan-build.html. The only thing that should be made to make scan-build work from an arbitrary location is adding scan-build folder to the PATH environment variable.
Currently using this locally, decided to propose to community as it might be helpful.

http://llvm-reviews.chandlerc.com/D703

Files:
  tools/scan-build/scan-build
  tools/scan-build/scan-build.bat
  tools/scan-build/c++-analyzer.win

Index: tools/scan-build/scan-build
===================================================================
--- tools/scan-build/scan-build
+++ tools/scan-build/scan-build
@@ -1560,8 +1560,14 @@
 }
 
 $ClangCXX = $Clang;
-$ClangCXX =~ s/\-\d+\.\d+$//;
-$ClangCXX .= "++";
+if($^O =~/msys/) {
+  $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 +1582,17 @@
 
 # Determine the location of ccc-analyzer.
 my $AbsRealBin = Cwd::realpath($RealBin);
+my $CXXAnalyzerExecName = "c++-analyzer".($^O =~ /msys/ ? "\.win" : "");
 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
+++ tools/scan-build/scan-build.bat
@@ -0,0 +1 @@
+perl -S scan-build %*
Index: tools/scan-build/c++-analyzer.win
===================================================================
--- tools/scan-build/c++-analyzer.win
+++ tools/scan-build/c++-analyzer.win
@@ -0,0 +1,3 @@
+#!/usr/bin/env perl
+
+system ("ccc-analyzer @ARGV");
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D703.1.patch
Type: text/x-patch
Size: 1840 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130422/e3495a89/attachment.bin>


More information about the cfe-commits mailing list