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

Антон Ярцев anton.yartsev at gmail.com
Tue May 26 15:33:26 PDT 2015


The $line that hold arguments is the raw output from Clang with -### option passed. An output is consistent: each item in the output is double-quoted, each macro definition is split into "-D" and "definition".
In scan-build we call 'quotewords' to extract items. If we call 'quotewords' with the false 'keep' parameter we "remove all quotes and backslashes that are not themselves backslash-escaped or inside of single quotes" (perldoc <http://perldoc.perl.org/Text/ParseWords.html>). Here the problem with paths that have spaces arises (at least under Windows).
If we pass true to 'quotewords' 'keep' parameter we preserve all quotes and backslashes and this worked for me under Windows, but the regressions were reported in comments to r236423 like the following:
clang: error: no such file or directory: '"-cc1"'
clang: error: no such file or directory: '"-analyze"'
...

and regressions caused by extra quotes around macro definitions.
That's how matters stand.
So I came to the following solution: pass true to 'quotewords' to preserve arguments unmodified and then strip quotes from every macro definition and from all arguments that have no spaces (I've looked through the gcc options manual, it looks like macro definitions and paths are the only arguments that can have spaces if I am not missing something).


http://reviews.llvm.org/D9357

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/






More information about the cfe-commits mailing list