[cfe-dev] clang-cl mysteriously shuts up with --analyze

<Alexander G. Riccio> via cfe-dev cfe-dev at lists.llvm.org
Sat Jan 2 12:17:15 PST 2016


>
> I don’t think it’s possible. The way scan-build invokes is by invoking
> clang twice - once for compilation and once for analysis
>

Uggh. That seems awfully silly?  And actually, it's not compatible with
cl.exe, which runs /analyze alongside compilation, and prints warnings to
the console.

Is there some reason for that? I imagine that it'd be easier for all users
to simply invoke clang once to compile and analyze.

Sincerely,
Alexander Riccio
--
"Change the world or go home."
about.me/ariccio

<http://about.me/ariccio>
If left to my own devices, I will build more.
⁂

On Tue, Dec 29, 2015 at 4:10 PM, Anna Zaks <ganna at apple.com> wrote:

>
> On Dec 27, 2015, at 11:45 PM, <Alexander G. Riccio> <alexander at riccio.com>
> <Alexander G. Riccio> wrote:
>
> Ahh, that makes sense.
>
> On a slightly related note, is there a way to run Clang's static analysis
> as part of compilation WITHOUT scan-build?
>
>
> I don’t think it’s possible. The way scan-build invokes is by invoking
> clang twice - once for compilation and once for analysis.
>
> Sincerely,
> Alexander Riccio
> --
> "Change the world or go home."
> about.me/ariccio
>
> <http://about.me/ariccio>
> If left to my own devices, I will build more.
>>
> On Sun, Dec 27, 2015 at 10:55 PM, Anna Zaks <ganna at apple.com> wrote:
>
>> When you call clang with “--analyze”, the driver is only going analyze
>> your program with static analysis; it is not going to fully compile or link
>> it. This explains why you do not see the linker error.
>>
>> Cheers,
>> Anna.
>>
>> On Dec 21, 2015, at 3:12 PM, via cfe-dev <Alexander G. Riccio> wrote:
>>
>> When I try to build a simple C program (attached), clang-cl warns about
>> some - unrelated to this question - linking issue:
>>
>> C:\Users\Alexander Riccio\Documents\basically_flawed_c_program>clang-cl
>> basically_flawed_c_program.c
>> basically_flawed_c_program-1f4f44.obj : error LNK2019: unresolved
>> external symbol malloc referenced in function main
>> basically_flawed_c_program-1f4f44.obj : error LNK2019: unresolved
>> external symbol free referenced in function main
>> LINK : error LNK2001: unresolved external symbol mainCRTStartup
>> C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\LIB\libcmt.lib :
>> warning LNK4272: library machine type 'X86' conflicts with target machine
>> type 'x64'
>> basically_flawed_c_program.exe : fatal error LNK1120: 3 unresolved
>> externals
>> clang-cl.exe: error: linker command failed with exit code 1120 (use -v to
>> see invocation)
>>
>> ...but when I pass --analyze to clang-cl, it shuts up entirely:
>>
>> C:\Users\Alexander Riccio\Documents\basically_flawed_c_program>clang-cl
>> --analyze basically_flawed_c_program.c
>>
>> C:\Users\Alexander Riccio\Documents\basically_flawed_c_program>
>>
>>
>> What's going on here??
>>
>> I'm more interested in why the --analyze flag shuts clang-cl up, than I
>> am the strange linker error; but bonus points if you know what's going on
>> there too.
>>
>> I'm also attaching the verbose invocations of the two commands.
>>
>> Sincerely,
>> Alexander Riccio
>> --
>> "Change the world or go home."
>> about.me/ariccio
>>
>> <http://about.me/ariccio>
>> If left to my own devices, I will build more.
>>>> <clang-cl-verbose-invoke.txt><basically_flawed_c_program.c>
>> _______________________________________________
>> 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/20160102/2fcec7bb/attachment.html>


More information about the cfe-dev mailing list