https://bugs.llvm.org/show_bug.cgi?id=44630

            Bug ID: 44630
           Summary: ccc-analyzer.bat does not preserve quotes in its
                    arguments
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Static Analyzer
          Assignee: dcough...@apple.com
          Reporter: c.schrei...@ibexinnovations.co.uk
                CC: dcough...@apple.com, llvm-bugs@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
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.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to