On 01.05.2013 6:29, Jordan Rose wrote:
Comments:

+use English;

According to http://perldoc.perl.org/English.html, it's probably better to use

use English qw( -no_match_vars ) ;

...not that scan-build's startup time matters /that/ much.
Currently this is used only for $OSNAME while short names are used for all other special perl variables. Considering that using English affects performance, what about rolling back to $^O and adding explanatory comment instead?

@@ -1576,16 +1584,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);
 }

This section is no longer necessary.


Finally, it seems a bit funny to have a .pm file that contains top-level code and then exits, rather than just declaring stuff. Here's another redesign: ccc-analyzer stays the same, and c++-analyzer is just "do 'ccc-analyzer'". How's that sound?
'do' is just what I searched for, but missed.


If you don't like that, then the top-level code in analyzer_common.pm should probably be organized into some run()-like function. That would at least take out the check for $FindBin::Script: each wrapper script would already know if it was supposed to be a C++ compiler or not.

Jordan

--
Anton

Index: tools/scan-build/c++-analyzer
===================================================================
--- tools/scan-build/c++-analyzer	(revision 180722)
+++ tools/scan-build/c++-analyzer	(working copy)
@@ -1 +1,8 @@
-link ccc-analyzer
\ No newline at end of file
+#!/usr/bin/env perl
+
+use Cwd qw/ abs_path /;
+use File::Basename qw/ dirname /;
+# Add scan-build dir to the list of places where perl looks for modules.
+use lib dirname(abs_path($0));
+
+do 'ccc-analyzer';
Index: tools/scan-build/scan-build
===================================================================
--- tools/scan-build/scan-build	(revision 180722)
+++ tools/scan-build/scan-build	(working copy)
@@ -1560,8 +1560,16 @@
 }
 
 $ClangCXX = $Clang;
-$ClangCXX =~ s/\-\d+\.\d+$//;
-$ClangCXX .= "++";
+# Determine operating system under which this copy of Perl was built.
+my $IsWinBuild = ($^O =~/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`);
 
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

Reply via email to