[cfe-dev] [clang-tidy] Using clang-tidy on Windows

Manuel Klimek via cfe-dev cfe-dev at lists.llvm.org
Fri Sep 4 06:54:30 PDT 2015


On Fri, Sep 4, 2015 at 1:28 PM Paul Hoad via cfe-dev <cfe-dev at lists.llvm.org>
wrote:

> Sorry sorry in advance if this is a newbie question, I'm trying to get
> clang-tidy (3.8.0 trunk) working on Windows pointing at the with the Visual
> Studio 2015 headers (VC and UCRT)
>
> I'm trying a very simple programme
> -------------cut-------
> #include <iostream>
>
> void main(int argc,char **argv)
> {
>    std::cerr << "Hello World" << std::endl;
> }
> -------------cut-------
>
> clang-tidy will work perfectly until I start include system headers,stl
> etc...
>
> I run on the command line (inside cygwin bash shell) with the following.
>
> clang-tidy Stdio.cxx -- -I"c:/Program Files (x86)/Microsoft Visual Studio
> 14.0/VC/INCLUDE" -I"c:/Program Files (x86)/Windows
> Kits/10/Include/10.0.10150.0/ucrt"
>
>
> but I get a load of failures due to clang errors in the system headers.
>
> Can I:
>
> 1) parse a switch to clang-tidy to tell it not to complain about headers
> outside of my control?
> 2) avoid this problem in the first place (I get the same if I try to
> compile with clang.exe or clang-cl.exe)?
> 3) am I making an obvious mistake?
>
> -----------------compiler output-----------------
> 8 warnings and 20 errors generated.
> Error while processing D:\buildareas\HEAD\issdev\src\test\tidy\Stdio.cxx.
> error: too many errors emitted, stopping now [clang-diagnostic-error]
> c:/Program Files (x86)/Microsoft Visual Studio
> 14.0/VC/INCLUDE\vadefs.h:28:33: e
> rror: expected ';' after top level declarator [clang-diagnostic-error]
>         typedef unsigned __int64  uintptr_t;
>                                 ^
>                                 ;
> c:/Program Files (x86)/Microsoft Visual Studio
> 14.0/VC/INCLUDE\vadefs.h:127:18:
> error: expected identifier or '{' [clang-diagnostic-error]
>             enum : bool { __the_value = false };
>                  ^
> c:/Program Files (x86)/Microsoft Visual Studio
> 14.0/VC/INCLUDE\vadefs.h:133:18:
> error: expected identifier or '{' [clang-diagnostic-error]
>             enum : bool { __the_value = true };
>                  ^
> c:/Program Files (x86)/Microsoft Visual Studio
> 14.0/VC/INCLUDE\vadefs.h:139:18:
> error: expected identifier or '{' [clang-diagnostic-error]
>             enum : bool { __the_value = true };
>                  ^
> c:/Program Files (x86)/Microsoft Visual Studio
> 14.0/VC/INCLUDE\vcruntime.h:81:1:
>  error: C++ requires a type specifier for all declarations
> [clang-diagnostic-err
> or]
> _CRT_BEGIN_C_HEADER
> ...... more errors cut
>

Note that those are parsing errors, not clang-tidy errors.
You basically need to be able to run:
clang-check Stdio.cxx -- <the right command line parameters>
successfully first.

The easiest way to get there is to use CMake, and have it output a
compilation database (see the description how to do this for LLVM, it's
very similar: http://clang.llvm.org/docs/HowToSetupToolingForLLVM.html)


>
> Many thanks inadvance
>
> Paul
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20150904/2f1f3478/attachment.html>


More information about the cfe-dev mailing list