[LLVMbugs] [Bug 21505] New: Quoting in the compilation database example is wrong
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Thu Nov 6 10:57:56 PST 2014
http://llvm.org/bugs/show_bug.cgi?id=21505
Bug ID: 21505
Summary: Quoting in the compilation database example is wrong
Product: Documentation
Version: trunk
Hardware: All
OS: All
Status: NEW
Severity: normal
Priority: P
Component: General docs
Assignee: unassignedbugs at nondot.org
Reporter: dpb at corrigendum.ru
CC: llvmbugs at cs.uiuc.edu
Classification: Unclassified
... or at least misleading.
I'm talking about this page:
<http://clang.llvm.org/docs/JSONCompilationDatabase.html>.
The example compilation command is, in JSON:
"/usr/bin/clang++ -Irelative -DSOMEDEF=\"With spaces, quotes and \\-es.\" -c -o
file.o file.cc"
Unapplying the JSON quoting, we get the shell command:
/usr/bin/clang++ -Irelative -DSOMEDEF="With spaces, quotes and \-es." -c -o
file.o file.cc
Unapplying the shell quoting, we get the argument list:
/usr/bin/clang++
-Irelative
-DSOMEDEF=With spaces, quotes and \-es.
-c
-o
file.o
file.cc
(Or at least we should get this argument list. Note that in the shell syntax, \
isn't special unless followed by one of $`"\ or a newline:
<http://pubs.opengroup.org/onlinepubs/007904975/utilities/xcu_chap02.html#tag_02_02_03>.
However, testing shows that the backslash actually disappears at this stage, so
Clang probably implements this incorrectly.)
The -D argument, as written, produces a macro definition analogous to the
following:
#define SOMEDEF With spaces, quotes and \-es.
Which, I guess, is legal, but insensible. I doubt this definition can ever be
used in a legal C++ program.
Now, as far as what the correct command should be... I'm assuming the intention
is to yield a definition like this:
#define SOMEDEF "With spaces, quotes and \\-es."
Then the argument needs to be:
-DSOMEDEF="With spaces, quotes and \\-es."
Applying shell quoting gives us:
"-DSOMEDEF=\"With spaces, quotes and \\\\-es.\""
And applying JSON quoting (and adding the other arguments) yields:
"/usr/bin/clang++ -Irelative \"-DSOMEDEF=\\\"With spaces, quotes and
\\\\\\\\-es.\\\"\" -c -o file.o file.cc"
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20141106/7c68449a/attachment.html>
More information about the llvm-bugs
mailing list