<div dir="ltr"><br><br><div class="gmail_quote">On Wed Jan 28 2015 at 7:22:08 PM Hans Wennborg <<a href="mailto:hans@chromium.org">hans@chromium.org</a>> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">(Re-sending from the correct address; apologies if you receive this twice.)<br>
<br>
On Wed, Jan 28, 2015 at 6:11 AM, Manuel Klimek <<a href="mailto:klimek@google.com" target="_blank">klimek@google.com</a>> wrote:<br>
><br>
><br>
> On Wed Jan 28 2015 at 2:57:26 PM adrien.courdavault<br>
> <<a href="mailto:adrien.courdavault@gmail.com" target="_blank">adrien.courdavault@gmail.com</a>> wrote:<br>
>><br>
>> Hello everyone.<br>
>><br>
>> I would like to talk about an attempt to use clang-modernize and<br>
>> clang-tidy,<br>
>> and clang-analyzer on windows.<br>
>> I'm using CMake 3 and Visual studio 2013.<br>
>><br>
>> I would like to use the various great tools of clang to scan over my code<br>
>> base, but these seems to take a compile_commands.json file as input (this<br>
>> file should be in the build path provided by the "-p" option of those<br>
>> tools).<br>
>><br>
>> But sadly the CMAKE_EXPORT_COMPILE_COMMAND=<u></u>ON option does not work with<br>
>> the<br>
>> visual generator (which I use)<br>
>><br>
>> Some great people of Clang community are talking about here<br>
>><br>
>> <<a href="http://clang-developers.42468.n3.nabble.com/compile-commands-json-for-Windows-MSVC-tt4033848.html#none" target="_blank">http://clang-developers.<u></u>42468.n3.nabble.com/compile-<u></u>commands-json-for-Windows-<u></u>MSVC-tt4033848.html#none</a>><br>
>><br>
>> Their point is that it could be in the future added to CMake, but that<br>
>> they<br>
>> would prefer to not rely on it. Anyway, because of this *"Richard" decided<br>
>> to use the Log output of MSBuild to generate the compile_commands.json<br>
>> file*<br>
>> which he says should work.<br>
>><br>
>> Therefore as I don't see any of this implemented yet in a public repo, I<br>
>> decided to implement myself a little script to transform the output of the<br>
>> MSBuild log (that i get using "/fl<br>
>><br>
>> /fileLoggerParameters:LogFile=<u></u>MSBuild.log;Append;Verbosity=<u></u>normal;Encoding=UTF-8"<br>
>> as options to MSBuild, and parse it to generate a compile_commands.json<br>
>><br>
>> See here an example of a simple project which has only 1 cpp file:<br>
>> compile_commands.json<br>
>><br>
>> <<a href="http://clang-developers.42468.n3.nabble.com/file/n4043700/compile_commands.json" target="_blank">http://clang-developers.<u></u>42468.n3.nabble.com/file/<u></u>n4043700/compile_commands.json</a><u></u>><br>
>><br>
>> Then I used<br>
>> *clang-modernize -p=<build-path> -summary -include=<src_dir>*<br>
>> *clang-tidy -p=<build-path> src/main.cpp*<br>
>> Which leads to a lot of warnings and an error because "<stdlib.h> could<br>
>> not<br>
>> be found.<br>
>><br>
>> See the console log attached. log.log<br>
>> <<a href="http://clang-developers.42468.n3.nabble.com/file/n4043700/log.log" target="_blank">http://clang-developers.<u></u>42468.n3.nabble.com/file/<u></u>n4043700/log.log</a>><br>
>><br>
>> Do you have any idea of what is wrong?<br>
>><br>
>> Should I get as many errors, it looks like the tools don't understand the<br>
>> flags?<br>
>> Should this fail because of stdlib.h?<br>
>> what could be a solution?<br>
>> Is my use of the tools (command line parameters) right?<br>
><br>
><br>
> There are 2 problems here:<br>
> 1. you need to quote anything containing spaces, which includes the original<br>
> command (you have spaces in the path)<br>
> 2. clang needs to know it's in cl- mode; Hans might have an idea on how to<br>
> solve this...<br>
<br>
<br>
Right, I don't think anyone has been working on using these tools with<br>
cl-style command-lines.<br>
<br>
Getting the options parser to accept cl-style arguments is just a<br>
matter of flipping a flag. The question is how to design it. Should<br>
clang-tidy have an option for this? Should there be a clang-tidy-cl?<br>
Should there be something in the json file?<br>
<br>
The more difficult problem is that IIUC these tools don't go through<br>
the Driver, in which clang-cl does stuff like figuring out include<br>
paths, enabling -fms-extensions etc. Or maybe it does - how does<br>
clang-tidy et al find system include files?<br></blockquote><div><br></div><div>Well, libTooling does go through the clang::driver::Driver. The problem is that if we need the binary name to follow a certain pattern, the tool would need to know that... It's certainly doable</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
In any case, as it is today these tools are not ready to be used with<br>
cl-style command-lines.<br>
<br>
- Hans<br>
</blockquote></div></div>