[PATCH] [analyzer] Support spaces in compiler path and arguments.

Антон Ярцев anton.yartsev at gmail.com
Wed Apr 29 16:15:49 PDT 2015


Hi jordan_rose,

The patch fixes errors that occur if a path to default compiler has spaces or if an argument with spaces is given to compiler (e.g. via -I).

The precedent: running scan-build that uses clang compiled by VS ends up with
error: error reading 'Files\Microsoft'
error: error reading 'Visual'
error: error reading 'Studio'
error: error reading '11.0\VC\include'

Ok to commit?

http://reviews.llvm.org/D9357

Files:
  tools/scan-build/ccc-analyzer

Index: tools/scan-build/ccc-analyzer
===================================================================
--- tools/scan-build/ccc-analyzer
+++ tools/scan-build/ccc-analyzer
@@ -145,7 +145,7 @@
   print OUT "@$Args\n";
   close OUT;
   `uname -a >> $PPFile.info.txt 2>&1`;
-  `$Compiler -v >> $PPFile.info.txt 2>&1`;
+  `"$Compiler" -v >> $PPFile.info.txt 2>&1`;
   rename($ofile, "$PPFile.stderr.txt");
   return (basename $PPFile);
 }
@@ -180,6 +180,10 @@
   # Strip leading and trailing whitespace characters.
   $line =~ s/^\s+|\s+$//g;
   my @items = quotewords('\s+', 0, $line);
+  # Wrap arguments that have spaces with quotes.
+  foreach (@items) {
+    $_ = qq/"$_"/ if (/\s+/);
+  }
   my $cmd = shift @items;
   die "cannot find 'clang' in 'clang' command\n" if (!($cmd =~ /clang/));
   return \@items;

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D9357.24664.patch
Type: text/x-patch
Size: 813 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150429/2dfbef5c/attachment.bin>


More information about the cfe-commits mailing list