[llvm-bugs] [Bug 44630] New: ccc-analyzer.bat does not preserve quotes in its arguments

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Jan 23 04:48:34 PST 2020


            Bug ID: 44630
           Summary: ccc-analyzer.bat does not preserve quotes in its
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Static Analyzer
          Assignee: dcoughlin at apple.com
          Reporter: c.schreiber at ibexinnovations.co.uk
                CC: dcoughlin at apple.com, llvm-bugs at lists.llvm.org

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

    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

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.

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/20200123/b762aa3c/attachment-0001.html>

More information about the llvm-bugs mailing list