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

Manuel Klimek via cfe-dev cfe-dev at lists.llvm.org
Fri Sep 4 09:02:12 PDT 2015


On Fri, Sep 4, 2015 at 6:00 PM Paul Hoad <mydeveloperday at gmail.com> wrote:

> Manuel
>      clang-check went nuts! so backed up a bit and used Reid suggestion
>
> Reid
>     this did better once I added a -D_M_X64 (after getting a #error
> unsupported architecture)
>
> 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"
> -fms-extensions -fms-compatibility -fms-compatibility-version=19
> -std=c++11 -D_MSC_VER=1900 -D_M_X64
> 64 warnings and 3 errors generated.
>
> Error while processing D:\buildareas\HEAD\issdev\src\test\tidy\Stdio.cxx.
> c:/Program Files (x86)/Microsoft Visual Studio
> 14.0/VC/INCLUDE\limits:1117:24: error: constexpr function never produces a
> constant expression [clang-diagnostic-
> invalid-constexpr]
>          static _CONST_FUN _Ty infinity() _THROW0()
>                               ^
> c:/Program Files (x86)/Microsoft Visual Studio
> 14.0/VC/INCLUDE\limits:1119:11: note: floating point arithmetic produces an
> infinity
>                 return (_INF_LIMIT);
>                         ^
> c:/Program Files (x86)/Microsoft Visual Studio
> 14.0/VC/INCLUDE\limits:52:21: note: expanded from macro '_INF_LIMIT'
>  #define _INF_LIMIT     INFINITY
>
> as this was complaining about constexpr I dropped the -std=c++11 and this
> gave me an assertion.
>
> 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"
> -fms-extensions -fms-compatibility -fms-compatibility-version=19
> -D_MSC_VER=1900 -D_M_X64
>
> Assertion failed: !isNull() && "Cannot retrieve a NULL type pointer", file
> D:\src\llvm_snapshot_244436\llvm\tools\clang\include\clang/AST/Type.h, line
> 585
>
> So I backed up again
>
> clang-tidy Stdio.cxx -- -I"c:/Program Files (x86)/Microsoft Visual Studio
> 12.0/VC/INCLUDE" -fms-extensions -fms-compatibility
> -fms-compatibility-version=18 -std=c++11 -D_MSC_VER=1800 -D_M_X64
>
> This time dropping back to VS2013 and adding your c++11 back in...perfect
> that worked...
>
> clang-tidy Stdio.cxx -- -I"c:/Program Files (x86)/Microsoft Visual Studio
> 12.0/VC/INCLUDE" -fms-extensions -fms-compatibility
> -fms-compatibility-version=18 -std=c++11 -D_M_X64
> 18 warnings generated.
> Suppressed 18 warnings (18 in non-user code).
> Use -header-filter=.* to display errors from all non-system headers.
>
> I wonder if I should log a bug to this effect that clang-tidy isn't
> working with VS2015 headers?
>

This still looks like compiler warnings. You need to be able to compile the
code (with clang) before running clang-tidy on it.


>
>
>
> On Fri, Sep 4, 2015 at 4:26 PM, Reid Kleckner <rnk at google.com> wrote:
>
>> This looks like clang-tidy doesn't know it's targeting Windows and
>> doesn't know that C++11 is enabled.
>>
>> Try throwing "-fms-extensions -fms-compatibility
>> -fms-compatibility-version=19 -std=c++11" on the command line and see what
>> happens?
>>
>> On Fri, Sep 4, 2015 at 4:28 AM, 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
>>>
>>> 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/44908026/attachment.html>


More information about the cfe-dev mailing list