<html>
<head>
<base href="https://bugs.llvm.org/">
</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 - ccc-analyzer.bat does not preserve quotes in its arguments"
href="https://bugs.llvm.org/show_bug.cgi?id=44630">44630</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>ccc-analyzer.bat does not preserve quotes in its arguments
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>unspecified
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Windows NT
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>enhancement
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>Static Analyzer
</td>
</tr>
<tr>
<th>Assignee</th>
<td>dcoughlin@apple.com
</td>
</tr>
<tr>
<th>Reporter</th>
<td>c.schreiber@ibexinnovations.co.uk
</td>
</tr>
<tr>
<th>CC</th>
<td>dcoughlin@apple.com, llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>I have been trying to run scan-build on one of our project usually built with
Visual Studio. To run scan-build, I converted the project to CMake, used CMake
to produce MinGW-MakeFiles, which I then compiled with "scan-build
mingw32-make" (running from the mintty terminal shipped with Git, also called
Git Bash). After a bit of trial and error, I managed to get it to run
correctly, with one exception.
Our Visual Studio project was setting a pre-processor variable as a string with
quotes, and these quotes are meant to be part of the macro definition. The
build command generated by CMake generates the associated pre-processor command
as:
c++-analyzer [...] -DMACRO_NAME=\"the string\"
>From inside c++-analyzer.bat, when inspecting the command line arguments, I can
see that the characters \" (backslash+quote) are still there, however the
backslashes are lost when passing these command line arguments over to Perl.
Therefore the quotes are no longer escaped, and down the line the C++
pre-processor only sees the string without the quotes, which then fails
compilation.
I don't think this is a problem with my make files, because the project
compiles fine if I don't use scan-build. However, I managed to fix this by
replacing the content of c++-analyzer.bat to:
@echo off
set v_params=%*
set v_params=%v_params:\"=\\\"%
perl -S c++-analyzer "%v_params%"
This essentially replaces \" by \\\", escaping the backslash and the quote. I'm
sure the correct fix would have to be more generic than this.</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>