[cfe-dev] Clang extra tools with compile_commands.json on windows

Manuel Klimek klimek at google.com
Wed Jan 28 06:11:55 PST 2015


On Wed Jan 28 2015 at 2:57:26 PM adrien.courdavault <
adrien.courdavault at gmail.com> wrote:

> Hello everyone.
>
> I would like to talk about an attempt to use clang-modernize and
> clang-tidy,
> and clang-analyzer on windows.
> I'm using CMake 3 and Visual studio 2013.
>
> I would like to use the various great tools of clang to scan over my code
> base, but these seems to take a compile_commands.json file as input (this
> file should be in the build path provided by the "-p" option of those
> tools).
>
> But sadly the CMAKE_EXPORT_COMPILE_COMMAND=ON option does not work with
> the
> visual generator (which I use)
>
> Some great people of Clang community are talking about  here
> <http://clang-developers.42468.n3.nabble.com/compile-
> commands-json-for-Windows-MSVC-tt4033848.html#none>
>
> Their point is that it could be in the future added to CMake, but that they
> would prefer to not rely on it. Anyway, because of this *"Richard" decided
> to use the Log output of MSBuild to generate the compile_commands.json
> file*
> which he says should work.
>
> Therefore as I don't see any of this implemented yet in a public repo, I
> decided to implement myself a little script to transform the output of the
> MSBuild log (that i get using "/fl
> /fileLoggerParameters:LogFile=MSBuild.log;Append;Verbosity=
> normal;Encoding=UTF-8"
> as options to MSBuild, and parse it to generate a compile_commands.json
>
> See here an example of a simple project which has only 1 cpp file:
> compile_commands.json
> <http://clang-developers.42468.n3.nabble.com/file/
> n4043700/compile_commands.json>
>
> Then I used
> *clang-modernize -p=<build-path> -summary -include=<src_dir>*
> *clang-tidy -p=<build-path> src/main.cpp*
> Which leads to a lot of warnings and an error because "<stdlib.h> could not
> be found.
>
> See the console log attached. log.log
> <http://clang-developers.42468.n3.nabble.com/file/n4043700/log.log>
>
> Do you have any idea of what is wrong?
>
> Should I get as many errors, it looks like the tools don't understand the
> flags?
> Should this fail because of stdlib.h?
> what could be a solution?
> Is my use of the tools (command line parameters) right?
>

There are 2 problems here:
1. you need to quote anything containing spaces, which includes the
original command (you have spaces in the path)
2. clang needs to know it's in cl- mode; Hans might have an idea on how to
solve this...


>
> thank you
>
>
>
> But as I yet do not know how to
>
>
>
>
>
> --
> View this message in context: http://clang-developers.42468.
> n3.nabble.com/Clang-extra-tools-with-compile-commands-
> json-on-windows-tp4043700.html
> Sent from the Clang Developers mailing list archive at Nabble.com.
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20150128/a1359b1c/attachment.html>


More information about the cfe-dev mailing list