Fixed an issue with spaces. However additional changes (support for spaces in
compiler arguments) are required to fully support spaces in a compiler path.
Giving --use-analyzer="F:/C LANG/clang.exe" to scan-build ends up with
error: error reading 'LANG\..\lib\clang\3.7.0'
That's because -resource-dir F:\C LANG\..\lib\clang\3.7.0 is given to clang.
http://reviews.llvm.org/D9357 has lacking changes that completely fix an issue.
The updated patch also eliminates the regression in case if clang crashes - now
the proper value is rad from $?.
Please review!
http://reviews.llvm.org/D8774
Files:
tools/scan-build/ccc-analyzer
tools/scan-build/scan-build
EMAIL PREFERENCES
http://reviews.llvm.org/settings/panel/emailpreferences/
Index: tools/scan-build/ccc-analyzer
===================================================================
--- tools/scan-build/ccc-analyzer
+++ tools/scan-build/ccc-analyzer
@@ -158,28 +158,18 @@
my $mode = shift;
my $Args = shift;
- pipe (FROM_CHILD, TO_PARENT);
- my $pid = fork();
- if ($pid == 0) {
- close FROM_CHILD;
- open(STDOUT,">&", \*TO_PARENT);
- open(STDERR,">&", \*TO_PARENT);
- exec $Clang, "-###", $mode, @$Args;
- }
- close(TO_PARENT);
- my $line;
- while (<FROM_CHILD>) {
+ my $ClangLine;
+ my $ExecLine = join(' ', qq/"$Clang"/, "-###", $mode, @$Args, "2>&1", "|");
+ open(PS, $ExecLine);
+ while ( <PS> ) {
next if (!/\s"?-cc1"?\s/);
- $line = $_;
+ $ClangLine = $_;
}
- waitpid($pid,0);
- close(FROM_CHILD);
-
- die "could not find clang line\n" if (!defined $line);
+ die "could not find clang line\n" if (!defined $ClangLine);
# Strip leading and trailing whitespace characters.
- $line =~ s/^\s+|\s+$//g;
- my @items = quotewords('\s+', 0, $line);
+ $ClangLine =~ s/^\s+|\s+$//g;
+ my @items = quotewords('\s+', 0, $ClangLine);
my $cmd = shift @items;
die "cannot find 'clang' in 'clang' command\n" if (!($cmd =~ /clang/));
return \@items;
@@ -259,27 +249,16 @@
# Capture the STDOUT of clang and reroute it to ccc-analyzer's STDERR.
# We save the output file in the 'crashes' directory if clang encounters
# any problems with the file.
- pipe (FROM_CHILD, TO_PARENT);
- my $pid = fork();
- if ($pid == 0) {
- close FROM_CHILD;
- open(STDOUT,">&", \*TO_PARENT);
- open(STDERR,">&", \*TO_PARENT);
- exec $Cmd, @CmdArgs;
- }
-
- close TO_PARENT;
my ($ofh, $ofile) = tempfile("clang_output_XXXXXX", DIR => $HtmlDir);
-
- while (<FROM_CHILD>) {
+ my $ExecLine = join(' ', qq/"$Cmd"/, @CmdArgs, "2>&1", "|");
+ open(PS, $ExecLine);
+ while ( <PS> ) {
print $ofh $_;
print STDERR $_;
}
- close $ofh;
-
- waitpid($pid,0);
- close(FROM_CHILD);
+ close PS;
my $Result = $?;
+ close $ofh;
# Did the command die because of a signal?
if ($ReportFailures) {
Index: tools/scan-build/scan-build
===================================================================
--- tools/scan-build/scan-build
+++ tools/scan-build/scan-build
@@ -1232,40 +1232,24 @@
}
my %EnabledCheckers;
foreach my $lang ("c", "objective-c", "objective-c++", "c++") {
- pipe(FROM_CHILD, TO_PARENT);
- my $pid = fork();
- if ($pid == 0) {
- close FROM_CHILD;
- open(STDOUT,">&", \*TO_PARENT);
- open(STDERR,">&", \*TO_PARENT);
- exec $Clang, ( @PluginLoadCommandline_xclang, '--analyze', '-x', $lang, '-', '-###');
- }
- close(TO_PARENT);
- while(<FROM_CHILD>) {
+ my $ExecLine = join(' ', qq/"$Clang"/, @PluginLoadCommandline_xclang, '--analyze', '-x', "$lang", '-', '-###', '2>&1', '|');
+ open(PS, $ExecLine);
+ while (<PS>) {
foreach my $val (split /\s+/) {
$val =~ s/\"//g;
if ($val =~ /-analyzer-checker\=([^\s]+)/) {
$EnabledCheckers{$1} = 1;
}
}
}
- waitpid($pid,0);
- close(FROM_CHILD);
}
# Query clang for complete list of checkers.
if (defined $Clang && -x $Clang) {
- pipe(FROM_CHILD, TO_PARENT);
- my $pid = fork();
- if ($pid == 0) {
- close FROM_CHILD;
- open(STDOUT,">&", \*TO_PARENT);
- open(STDERR,">&", \*TO_PARENT);
- exec $Clang, ('-cc1', @PluginsToLoad , '-analyzer-checker-help');
- }
- close(TO_PARENT);
+ my $ExecLine = join(' ', qq/"$Clang"/, '-cc1', @PluginsToLoad, '-analyzer-checker-help', '2>&1', '|');
+ open(PS, $ExecLine);
my $foundCheckers = 0;
- while(<FROM_CHILD>) {
+ while (<PS>) {
if (/CHECKERS:/) {
$foundCheckers = 1;
last;
@@ -1277,7 +1261,7 @@
else {
print("\nAVAILABLE CHECKERS:\n\n");
my $skip = 0;
- while(<FROM_CHILD>) {
+ while(<PS>) {
if (/experimental/) {
$skip = 1;
next;
@@ -1314,10 +1298,8 @@
}
print $_;
}
- print "\nNOTE: \"+\" indicates that an analysis is enabled by default.\n"
+ print "\nNOTE: \"+\" indicates that an analysis is enabled by default.\n";
}
- waitpid($pid,0);
- close(FROM_CHILD);
}
print <<ENDTEXT
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits