<html>
<head>
<base href="http://llvm.org/bugs/" />
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW --- - Quoting in the compilation database example is wrong"
href="http://llvm.org/bugs/show_bug.cgi?id=21505">21505</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Quoting in the compilation database example is wrong
</td>
</tr>
<tr>
<th>Product</th>
<td>Documentation
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>All
</td>
</tr>
<tr>
<th>OS</th>
<td>All
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>General docs
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>dpb@corrigendum.ru
</td>
</tr>
<tr>
<th>CC</th>
<td>llvmbugs@cs.uiuc.edu
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>... or at least misleading.
I'm talking about this page:
<<a href="http://clang.llvm.org/docs/JSONCompilationDatabase.html">http://clang.llvm.org/docs/JSONCompilationDatabase.html</a>>.
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:
<<a href="http://pubs.opengroup.org/onlinepubs/007904975/utilities/xcu_chap02.html#tag_02_02_03">http://pubs.opengroup.org/onlinepubs/007904975/utilities/xcu_chap02.html#tag_02_02_03</a>>.
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"</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>