[prev in list] [next in list] [prev in thread] [next in thread] 

List:       cfe-dev
Subject:    Re: [cfe-dev] analyzer: invoking a single analyzer from the static analysis tools.
From:       Michael Katelman <katelman () gmail ! com>
Date:       2014-02-28 0:31:48
Message-ID: CAAn2fBD-aA4bR8=Jb2qSofXuE9dV3f_K9b8w-Zr=AWf+kPTnuw () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


This doesn't have the same issue that I encountered. As far as I can tell
it should do what you expect, but that's not saying much.


On Thu, Feb 27, 2014 at 10:37 AM, Aitor San Juan <aitor.sj@opendeusto.es>wrote:

> Ok, no worries. I've pasted the content of the "custom" shell script.
>
> The option marked (*) is what I added to enable my checker, but it seems
> to have no effect. I'm racking my brains to work it out. No successful
> result for the time being, though.
>
> Here you are. I hope it helps.
>
> #!/bin/bash
> /usr/local/src/build/Release+Asserts/bin/clang '-cc1' \
>     '-triple' 'x86_64-unknown-linux-gnu' \
>     '-analyze' \
>     '-disable-free' \
>     '-main-file-name' 'dcl41c_03_bad.c' \
>     '-analyzer-store=region' \
>     '-analyzer-opt-analyze-nested-blocks' \
>     '-analyzer-eagerly-assume' \
>     '-analyzer-checker=core' \
>     '-analyzer-checker=unix' \
>     '-analyzer-checker=deadcode' \
>     '-analyzer-checker=security.insecureAPI.UncheckedReturn' \
>     '-analyzer-checker=security.insecureAPI.getpw' \
>     '-analyzer-checker=security.insecureAPI.gets' \
>     '-analyzer-checker=security.insecureAPI.mktemp' \
>     '-analyzer-checker=security.insecureAPI.mkstemp' \
>     '-analyzer-checker=security.insecureAPI.vfork' \
>     '-analyzer-output' 'plist' '-w' \
>     '-mrelocation-model' 'static' \
>     '-mdisable-fp-elim' '-fmath-errno' \
>     '-masm-verbose' \
>     '-mconstructor-aliases' '-munwind-tables' \
>     '-target-cpu' 'x86-64' \
>     '-target-linker-version' '2.22' \
>     '-resource-dir'
> '/usr/local/src/build/Release+Asserts/bin/../lib/clang/3.5' \
>     '-internal-isystem' '/usr/local/include' \
>     '-internal-isystem'
> '/usr/local/src/build/Release+Asserts/bin/../lib/clang/3.5/include' \
>     '-internal-externc-isystem' '/usr/include/x86_64-linux-gnu' \
>     '-internal-externc-isystem' '/include' \
>     '-internal-externc-isystem' '/usr/include' \
>     '-fdebug-compilation-dir' '/home/user1/src' \
>     '-ferror-limit' '19' '-fmessage-length' '0' \
>     '-mstackrealign' \
>     '-fobjc-runtime=gcc' '-fdiagnostics-show-option' \
>     '-vectorize-slp' \
>     '-analyzer-display-progress' \
> (*) '-analyzer-checker=alpha.security.DCL41C' \
>     '-analyzer-output=html' \
>     '-o' '/tmp/scan-build-2014-02-26-4' \
>     '-x' 'c' 'dcl41c_03_bad.c'
>
>
> 2014-02-27 19:12 GMT+01:00 Michael Katelman <katelman@gmail.com>:
>
> Aitor,
>>
>> I think something got lost in my message. I understand the process that
>> you're talking about, but when I did it I needed to manually modify the
>> resulting bash script that was emitted; that's why I was asking about you
>> posting the full clang command (so I could see if you had made similar
>> changes to what I had). I did this through clang originally with -###, so
>> perhaps some of the edits aren't necessary since you used scan-build, but
>> one thing I'm wondering about is if the command that you're ultimately
>> running invokes the system installed clang or your locally built one, as I
>> needed to use -use-analyzer=... when invoking scan-build.
>>
>>
>> On Thu, Feb 27, 2014 at 4:03 AM, Aitor San Juan <aitor.sj@opendeusto.es>wrote:
>>
>>> Michael,
>>>>
>>>> You will see the complete command executed behind the scenes if you run
>>>> scan-build with the verbose option enabled (-v -v):
>>>>
>>>> scan-build -v -v -enable-checker my_checker_name clang -c my_file.c
>>>>
>>>> You may save the output to a file, get rid of the debug messages, save
>>>> the first lines, add #!/bin/bash at the beginning, and give it exec
>>>> permissions (chmod 755 your_script_name) to run it as a shell script.
>>>> That's what I did.
>>>>
>>>> However, the previous command seems to not effectively enable the
>>>> checker supplied at the command line. As I mentioned in my previous
>>>> message, the option "-enable-checker my_checker_name" to scan-build is
>>>> internally passed as '-analyzer-checker' 'my_checker_name'. If you inspect
>>>> the full command printed out by scan-build (when using -v -v), the default
>>>> checkers are enabled with the syntax '-analyzer-checker=core', and so on.
>>>>
>>>> I tried passing '-analyzer-checker=my_checker_name' in the shell
>>>> script, but apparently nothing happens.
>>>>
>>>> So I don't know how to enable my custom checker, which, according to
>>>> the manual, is disabled by default.
>>>>
>>>> Could anybody shed some light on this?
>>>> Many thanks.
>>>> Aitor.
>>>>
>>>>
>>>>> Date: Wed, 26 Feb 2014 13:04:24 -0800
>>>>> From: Michael Katelman <katelman@gmail.com>
>>>>> To: "cfe-dev@cs.uiuc.edu" <cfe-dev@cs.uiuc.edu>
>>>>>
>>>>> Subject: Re: [cfe-dev] analyzer: invoking a single analyzer from the
>>>>>         static analysis tools.
>>>>> Message-ID:
>>>>>         <
>>>>> CAAn2fBDsqM_x2wxbb7O+4OKA_9q4+uOKAOX5CTaL8na7B9yhEw@mail.gmail.com>
>>>>> Content-Type: text/plain; charset="iso-8859-1"
>>>>>
>>>>>
>>>>> I've gone down a similar road within the last couple of days. I'm not
>>>>> sure
>>>>> I'll be able to solve your problem -- I'm just familiarizing myself
>>>>> with
>>>>> the tools and code myself -- but I did get what you're talking about to
>>>>> work for the simple checker that I made. Would you mind posting the
>>>>> entirety of the shell script you made?
>>>>>
>>>>>
>>>>> On Wed, Feb 26, 2014 at 11:05 AM, Aitor San Juan <
>>>>> aitor.sj@opendeusto.es>wrote:
>>>>>
>>>>> > Hello,
>>>>> >
>>>>> > I have developed a simple checker, just to become familiar with
>>>>> Clang's
>>>>> > Checker API. I have sucessfully compiled it and installed in package
>>>>> > alpha.security. For the sake of understanding and tracing the
>>>>> execution
>>>>> > flow of the checker, I have added some "debug" lines like the
>>>>> following
>>>>> > (I'm aware this is discouraged):
>>>>> >
>>>>> > llvm::outs() << "BEGIN: checkPreStmt" << "\n";
>>>>> >
>>>>> > I run scan-build or clang --analyze, as suggested in previous
>>>>> answers, but
>>>>> > I don't see the messages printed out. The commands I'm running are:
>>>>> >
>>>>> > (1) clang --analyze my_file.c
>>>>> >
>>>>> > (2) scan-build clang -c my_file.c
>>>>> >
>>>>> > Reading the manual, I understand that the reason is that "my"
>>>>> checker is
>>>>> > not enabled by default, only a few.
>>>>> >
>>>>> > So I tried the following command to enable it:
>>>>> >
>>>>> > (3) scan-build -enable-checker alpha.security.DCL41C clang -c
>>>>> my_file.c
>>>>> >
>>>>> > but again my "debugging" messages don't appear in the standard
>>>>> output. So
>>>>> > enabling verbose info with "-v -v" in command (3), I can see the
>>>>> complete
>>>>> > command line run behind the scenes, and scan-build is passing:
>>>>> >
>>>>> > '-analyzer-checker' 'alpha.security.DCL41C'
>>>>> >
>>>>> > but I've remarked that the checkers enabled by default are being
>>>>> enabled
>>>>> > like this:
>>>>> >
>>>>> >  '-analyzer-checker=core' '-analyzer-checker=unix'
>>>>> > '-analyzer-checker=deadcode'
>>>>> > '-analyzer-checker=security.insecureAPI.UncheckedReturn'
>>>>> >
>>>>> > So I saved the complete command lie to a shell script, and changed
>>>>> the
>>>>> > options '-analyzer-checker' 'alpha.security.DCL41C' to
>>>>> > '-analyzer-checker=alpha.security.DCL41C'
>>>>> >
>>>>> > The same problem: I don't see the messages of llvm:outs, so I don't
>>>>> > whether my checker is being called, or the output of llvm::outs is
>>>>> going to
>>>>> > some other place I don't know.
>>>>> >
>>>>> > My Clang version is a build that dates back to late Dec. 2013. I
>>>>> hope it's
>>>>> > not a bug :-(
>>>>> >
>>>>> > clang version 3.5 (trunk 197976) (llvm/trunk 197973)
>>>>> > Target: x86_64-unknown-linux-gnu
>>>>> > Thread model: posix
>>>>> >
>>>>> > Any help would he highly appreciated
>>>>> >
>>>>> > Date: Tue, 25 Feb 2014 11:37:17 -0800
>>>>> >
>>>>> >> From: Michael Katelman <katelman@gmail.com>
>>>>> >> To: Ted Kremenek <kremenek@apple.com>
>>>>> >> Cc: cfe-dev@cs.uiuc.edu
>>>>> >> Subject: Re: [cfe-dev] analyzer: invoking a single analyzer from the
>>>>> >>         static analysis tools.
>>>>> >> Message-ID:
>>>>> >>         <
>>>>> >> CAAn2fBCGH69fAWP_kXGpwpqjAykj29ps9RfcPbNi9e4foqqKuQ@mail.gmail.com>
>>>>> >> Content-Type: text/plain; charset="iso-8859-1"
>>>>> >>
>>>>> >>
>>>>> >> Hi Ted,
>>>>> >>
>>>>> >> Thanks for the help! I actually have a follow-up question, though.
>>>>> This
>>>>> >> question came up because I was toying around with developing my own
>>>>> simple
>>>>> >> checker and wanted to test it out. My first inclination was to do
>>>>> this in
>>>>> >> isolation from the other checkers which is why I attempted the
>>>>> invocation
>>>>> >> from my original post, but perhaps you're saying that even for a dev
>>>>> >> situation like this just run the whole platter of checkers? Or, did
>>>>> you
>>>>> >> just mean for a general usage scenario where someone isn't adding
>>>>> new
>>>>> >> checkers etc.?
>>>>> >>
>>>>> >> I just ended up using --analyze because the scan-build command I
>>>>> could
>>>>> >> figure out was somewhat more verbose, needing --use-analyzer=...
>>>>> etc.;
>>>>> >> but,
>>>>> >> I was mostly fumbling around trying to get it to work, so I'm sure
>>>>> I'm
>>>>> >> missing a bunch of different things.
>>>>> >>
>>>>> >> Thanks again.
>>>>> >>
>>>>> >> -Mike
>>>>> >>
>>>>> >>
>>>>> >> On Tue, Feb 25, 2014 at 11:00 AM, Ted Kremenek <kremenek@apple.com>
>>>>> >> wrote:
>>>>> >>
>>>>> >> > Hi Michael,
>>>>> >> >
>>>>> >> > It's not recommended to run the low-level driver like this.  You
>>>>> can
>>>>> >> just
>>>>> >> > use scan-build, for example:
>>>>> >> >
>>>>> >> >   $ scan-build clang -c /tmp/main.c
>>>>> >> >
>>>>> >> > or more generally
>>>>> >> >
>>>>> >> >   $ scan-build <compiler line>
>>>>> >> >
>>>>> >> > You can also use:
>>>>> >> >
>>>>> >> >   $ clang --analyze /tmp/main.c
>>>>> >>
>>>>> >> >
>>>>> >> > directly.  That's somewhat discouraged because the long-term idea
>>>>> is
>>>>> >> that
>>>>> >> > the static analyzer supports global analysis.  The intention is
>>>>> that you
>>>>> >> > can declare a set of files to analyze and they get analyzed
>>>>> together,
>>>>> >> > whereas the latter line is clearly just analyzing a particular
>>>>> file
>>>>> >> using
>>>>> >> > clang.
>>>>> >> >
>>>>> >> > Cheers,
>>>>> >> > Ted
>>>>> >> >
>>>>> >> > On Feb 21, 2014, at 2:22 PM, Michael Katelman <katelman@gmail.com
>>>>> >
>>>>> >> wrote:
>>>>> >> >
>>>>> >> > > I was wondering if someone might be able to help me with cleanly
>>>>> >> > invoking a single analyzer from the static analysis tools.
>>>>> >> > >
>>>>> >> > > I am not sure what I need to do (or, should be doing instead)
>>>>> in a
>>>>> >> > situation like the one below where I've got a header like stdio.h
>>>>> >> included
>>>>> >> > (--analyze figures it out, but then it appears that I lose the
>>>>> ability
>>>>> >> to
>>>>> >> > apply a single checker) :
>>>>> >> > >
>>>>> >> > > %  ./Debug+Asserts/bin/clang -cc1 -analyze
>>>>> >> > -analyzer-checker=core.DivideZero ./tmp/main.c
>>>>> >> > >
>>>>> >> > > ./tmp/main.c:1:10: fatal error: 'stdio.h' file not found
>>>>> >> > > #include <stdio.h>
>>>>> >> > >          ^
>>>>> >> > > 1 error generated.
>>>>> >> > >
>>>>> >> > >  % cat ./tmp /main.c
>>>>> >> > >
>>>>> >> > > #include <stdio.h>
>>>>> >> > >
>>>>> >> > > int main( int argc, char** argv){
>>>>> >> > >   int x = 1;
>>>>> >> > >   int y = 0;
>>>>> >> > >
>>>>> >> > >   printf("%d\n", x / y);
>>>>> >> > >
>>>>> >> > >   return  0;
>>>>> >> > > }
>>>>> >> > >
>>>>> >> > > Thanks!
>>>>>
>>>>
>>>
>>> _______________________________________________
>>> cfe-dev mailing list
>>> cfe-dev@cs.uiuc.edu
>>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>>>
>>>
>>
>

[Attachment #5 (text/html)]

<div dir="ltr">This doesn&#39;t have the same issue that I encountered. As far as I \
can tell it should do what you expect, but that&#39;s not saying much.</div><div \
class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Feb 27, 2014 at 10:37 \
AM, Aitor San Juan <span dir="ltr">&lt;<a href="mailto:aitor.sj@opendeusto.es" \
target="_blank">aitor.sj@opendeusto.es</a>&gt;</span> wrote:<br> <blockquote \
class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc \
solid;padding-left:1ex"><div dir="ltr">Ok, no worries. I&#39;ve pasted the content of \
the &quot;custom&quot; shell script.<br><br>The option marked (*) is what I added to \
enable my checker, but it seems to have no effect. I&#39;m racking my brains to work \
it out. No successful result for the time being, though.<br>

<br>Here you are. I hope it helps.<br><br><span style="font-family:courier \
new,monospace">#!/bin/bash<br>/usr/local/src/build/Release+Asserts/bin/clang \
&#39;-cc1&#39; \<br>    &#39;-triple&#39; &#39;x86_64-unknown-linux-gnu&#39; \<br>

    &#39;-analyze&#39; \<br>    &#39;-disable-free&#39; \<br>    \
&#39;-main-file-name&#39; &#39;dcl41c_03_bad.c&#39; \<br>    \
&#39;-analyzer-store=region&#39; \<br>    \
&#39;-analyzer-opt-analyze-nested-blocks&#39; \<br>    \
&#39;-analyzer-eagerly-assume&#39; \<br>

    &#39;-analyzer-checker=core&#39; \<br>    &#39;-analyzer-checker=unix&#39; \<br>  \
&#39;-analyzer-checker=deadcode&#39; \<br>    \
&#39;-analyzer-checker=security.insecureAPI.UncheckedReturn&#39; \<br>    \
&#39;-analyzer-checker=security.insecureAPI.getpw&#39; \<br>

    &#39;-analyzer-checker=security.insecureAPI.gets&#39; \<br>    \
&#39;-analyzer-checker=security.insecureAPI.mktemp&#39; \<br>    \
&#39;-analyzer-checker=security.insecureAPI.mkstemp&#39; \<br>    \
&#39;-analyzer-checker=security.insecureAPI.vfork&#39; \<br>

    &#39;-analyzer-output&#39; &#39;plist&#39; &#39;-w&#39; \<br>    \
&#39;-mrelocation-model&#39; &#39;static&#39; \<br>    &#39;-mdisable-fp-elim&#39; \
&#39;-fmath-errno&#39; \<br>    &#39;-masm-verbose&#39; \<br>    \
&#39;-mconstructor-aliases&#39; &#39;-munwind-tables&#39; \<br>

    &#39;-target-cpu&#39; &#39;x86-64&#39; \<br>    &#39;-target-linker-version&#39; \
&#39;2.22&#39; \<br>    &#39;-resource-dir&#39; \
&#39;/usr/local/src/build/Release+Asserts/bin/../lib/clang/3.5&#39; \<br>    \
&#39;-internal-isystem&#39; &#39;/usr/local/include&#39; \<br>

    &#39;-internal-isystem&#39; \
&#39;/usr/local/src/build/Release+Asserts/bin/../lib/clang/3.5/include&#39; \<br>    \
&#39;-internal-externc-isystem&#39; &#39;/usr/include/x86_64-linux-gnu&#39; \<br>    \
&#39;-internal-externc-isystem&#39; &#39;/include&#39; \<br>

    &#39;-internal-externc-isystem&#39; &#39;/usr/include&#39; \<br>    \
&#39;-fdebug-compilation-dir&#39; &#39;/home/user1/src&#39; \<br>    \
&#39;-ferror-limit&#39; &#39;19&#39; &#39;-fmessage-length&#39; &#39;0&#39; \<br>

    &#39;-mstackrealign&#39; \<br>    &#39;-fobjc-runtime=gcc&#39; \
&#39;-fdiagnostics-show-option&#39; \<br>    &#39;-vectorize-slp&#39; \<br>    \
&#39;-analyzer-display-progress&#39; \<br>(*) \
&#39;-analyzer-checker=alpha.security.DCL41C&#39; \<br>

    &#39;-analyzer-output=html&#39; \<br>    &#39;-o&#39; \
&#39;/tmp/scan-build-2014-02-26-4&#39; \<br>    &#39;-x&#39; &#39;c&#39; \
&#39;dcl41c_03_bad.c&#39;</span><br><div><div class="gmail_extra"><br><br><div \
class="gmail_quote">

2014-02-27 19:12 GMT+01:00 Michael Katelman <span dir="ltr">&lt;<a \
href="mailto:katelman@gmail.com" \
target="_blank">katelman@gmail.com</a>&gt;</span>:<div><div class="h5"><br> \
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid \
rgb(204,204,204);padding-left:1ex"><div dir="ltr">Aitor,<div><br></div><div>I think \
something got lost in my message. I understand the process that you&#39;re talking \
about, but when I did it I needed to manually modify the resulting bash script that \
was emitted; that&#39;s why I was asking about you posting the full clang command (so \
I could see if you had made similar changes to what I had). I did this through clang \
originally with -###, so perhaps some of the edits aren&#39;t necessary since you \
used scan-build, but one thing I&#39;m wondering about is if the command that \
you&#39;re ultimately running invokes the system installed clang or your locally \
built one, as I needed to use -use-analyzer=... when invoking scan-build.</div>



</div><div class="gmail_extra"><br><br><div class="gmail_quote"><div><div>On Thu, Feb \
27, 2014 at 4:03 AM, Aitor San Juan <span dir="ltr">&lt;<a \
href="mailto:aitor.sj@opendeusto.es" \
target="_blank">aitor.sj@opendeusto.es</a>&gt;</span> wrote:<br>



</div></div><blockquote class="gmail_quote" style="margin:0px 0px 0px \
0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><div><div \
dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><blockquote \
class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid \
rgb(204,204,204);padding-left:1ex">



<div dir="ltr">Michael,<br><br>You will see the complete command executed behind the \
scenes if you run scan-build with the verbose option enabled (-v -v): <div> <div \
class="gmail_extra"><br>scan-build -v -v -enable-checker my_checker_name clang -c \
my_file.c<br> <div class="gmail_quote"><br></div><div class="gmail_quote">You may \
save the output to a file, get rid of the debug messages, save the first lines, add \
#!/bin/bash at the beginning, and give it exec permissions (chmod 755 \
your_script_name) to run it as a shell script. That&#39;s what I did.<br>





<br></div><div class="gmail_quote">However, the previous command seems to not \
effectively enable the checker supplied at the command line. As I mentioned in my \
previous message, the option &quot;-enable-checker my_checker_name&quot; to \
scan-build is internally passed as &#39;-analyzer-checker&#39; \
&#39;my_checker_name&#39;. If you inspect the full command printed out by scan-build \
(when using -v -v), the default checkers are enabled with the syntax \
&#39;-analyzer-checker=core&#39;, and so on.<br>





<br></div><div class="gmail_quote">I tried passing \
&#39;-analyzer-checker=my_checker_name&#39; in the shell script, but apparently \
nothing happens.<br><br>So I don&#39;t know how to enable my custom checker, which, \
according to the manual, is disabled by default.<br>





<br></div><div class="gmail_quote">Could anybody shed some light on \
this?<br></div><div class="gmail_quote">Many thanks.<span><font \
color="#888888"><br></font></span></div><span><font color="#888888"><div \
class="gmail_quote">




Aitor.<br></div></font></span><div><div><div class="gmail_quote"><br><blockquote \
class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid \
rgb(204,204,204);padding-left:1ex"> <br>
Date: Wed, 26 Feb 2014 13:04:24 -0800<br>
From: Michael Katelman &lt;<a href="mailto:katelman@gmail.com" \
                target="_blank">katelman@gmail.com</a>&gt;<br>
To: &quot;<a href="mailto:cfe-dev@cs.uiuc.edu" \
target="_blank">cfe-dev@cs.uiuc.edu</a>&quot; &lt;<a \
href="mailto:cfe-dev@cs.uiuc.edu" \
                target="_blank">cfe-dev@cs.uiuc.edu</a>&gt;<div><br>
Subject: Re: [cfe-dev] analyzer: invoking a single analyzer from the<br>
        static analysis tools.<br>
Message-ID:<br></div>
        &lt;<a href="mailto:CAAn2fBDsqM_x2wxbb7O%2B4OKA_9q4%2BuOKAOX5CTaL8na7B9yhEw@mail.gmail.com" \
target="_blank">CAAn2fBDsqM_x2wxbb7O+4OKA_9q4+uOKAOX5CTaL8na7B9yhEw@mail.gmail.com</a>&gt;<br>
                
Content-Type: text/plain; charset=&quot;iso-8859-1&quot;<div><div><br>
<br>
I&#39;ve gone down a similar road within the last couple of days. I&#39;m not \
sure<br> I&#39;ll be able to solve your problem -- I&#39;m just familiarizing myself \
with<br> the tools and code myself -- but I did get what you&#39;re talking about \
to<br> work for the simple checker that I made. Would you mind posting the<br>
entirety of the shell script you made?<br>
<br>
<br>
On Wed, Feb 26, 2014 at 11:05 AM, Aitor San Juan &lt;<a \
href="mailto:aitor.sj@opendeusto.es" \
target="_blank">aitor.sj@opendeusto.es</a>&gt;wrote:<br> <br>
&gt; Hello,<br>
&gt;<br>
&gt; I have developed a simple checker, just to become familiar with Clang&#39;s<br>
&gt; Checker API. I have sucessfully compiled it and installed in package<br>
&gt; alpha.security. For the sake of understanding and tracing the execution<br>
&gt; flow of the checker, I have added some &quot;debug&quot; lines like the \
following<br> &gt; (I&#39;m aware this is discouraged):<br>
&gt;<br>
&gt; llvm::outs() &lt;&lt; &quot;BEGIN: checkPreStmt&quot; &lt;&lt; \
&quot;\n&quot;;<br> &gt;<br>
&gt; I run scan-build or clang --analyze, as suggested in previous answers, but<br>
&gt; I don&#39;t see the messages printed out. The commands I&#39;m running are:<br>
&gt;<br>
&gt; (1) clang --analyze my_file.c<br>
&gt;<br>
&gt; (2) scan-build clang -c my_file.c<br>
&gt;<br>
&gt; Reading the manual, I understand that the reason is that &quot;my&quot; checker \
is<br> &gt; not enabled by default, only a few.<br>
&gt;<br>
&gt; So I tried the following command to enable it:<br>
&gt;<br>
&gt; (3) scan-build -enable-checker alpha.security.DCL41C clang -c my_file.c<br>
&gt;<br>
&gt; but again my &quot;debugging&quot; messages don&#39;t appear in the standard \
output. So<br> &gt; enabling verbose info with &quot;-v -v&quot; in command (3), I \
can see the complete<br> &gt; command line run behind the scenes, and scan-build is \
passing:<br> &gt;<br>
&gt; &#39;-analyzer-checker&#39; &#39;alpha.security.DCL41C&#39;<br>
&gt;<br>
&gt; but I&#39;ve remarked that the checkers enabled by default are being enabled<br>
&gt; like this:<br>
&gt;<br>
&gt;  &#39;-analyzer-checker=core&#39; &#39;-analyzer-checker=unix&#39;<br>
&gt; &#39;-analyzer-checker=deadcode&#39;<br>
&gt; &#39;-analyzer-checker=security.insecureAPI.UncheckedReturn&#39;<br>
&gt;<br>
&gt; So I saved the complete command lie to a shell script, and changed the<br>
&gt; options &#39;-analyzer-checker&#39; &#39;alpha.security.DCL41C&#39; to<br>
&gt; &#39;-analyzer-checker=alpha.security.DCL41C&#39;<br>
&gt;<br>
&gt; The same problem: I don&#39;t see the messages of llvm:outs, so I don&#39;t<br>
&gt; whether my checker is being called, or the output of llvm::outs is going to<br>
&gt; some other place I don&#39;t know.<br>
&gt;<br>
&gt; My Clang version is a build that dates back to late Dec. 2013. I hope \
it&#39;s<br> &gt; not a bug :-(<br>
&gt;<br>
&gt; clang version 3.5 (trunk 197976) (llvm/trunk 197973)<br>
&gt; Target: x86_64-unknown-linux-gnu<br>
&gt; Thread model: posix<br>
&gt;<br>
&gt; Any help would he highly appreciated<br>
&gt;<br>
&gt; Date: Tue, 25 Feb 2014 11:37:17 -0800<br>
&gt;<br>
&gt;&gt; From: Michael Katelman &lt;<a href="mailto:katelman@gmail.com" \
target="_blank">katelman@gmail.com</a>&gt;<br> &gt;&gt; To: Ted Kremenek &lt;<a \
href="mailto:kremenek@apple.com" target="_blank">kremenek@apple.com</a>&gt;<br> \
&gt;&gt; Cc: <a href="mailto:cfe-dev@cs.uiuc.edu" \
target="_blank">cfe-dev@cs.uiuc.edu</a><br> &gt;&gt; Subject: Re: [cfe-dev] analyzer: \
invoking a single analyzer from the<br> &gt;&gt;         static analysis tools.<br>
&gt;&gt; Message-ID:<br>
&gt;&gt;         &lt;<br>
&gt;&gt; <a href="mailto:CAAn2fBCGH69fAWP_kXGpwpqjAykj29ps9RfcPbNi9e4foqqKuQ@mail.gmail.com" \
target="_blank">CAAn2fBCGH69fAWP_kXGpwpqjAykj29ps9RfcPbNi9e4foqqKuQ@mail.gmail.com</a>&gt;<br>
 &gt;&gt; Content-Type: text/plain; charset=&quot;iso-8859-1&quot;<br>
&gt;&gt;<br>
&gt;&gt;<br></div></div><div>
&gt;&gt; Hi Ted,<br>
&gt;&gt;<br>
&gt;&gt; Thanks for the help! I actually have a follow-up question, though. This<br>
&gt;&gt; question came up because I was toying around with developing my own \
simple<br> &gt;&gt; checker and wanted to test it out. My first inclination was to do \
this in<br> &gt;&gt; isolation from the other checkers which is why I attempted the \
invocation<br> &gt;&gt; from my original post, but perhaps you&#39;re saying that \
even for a dev<br> &gt;&gt; situation like this just run the whole platter of \
checkers? Or, did you<br> &gt;&gt; just mean for a general usage scenario where \
someone isn&#39;t adding new<br> &gt;&gt; checkers etc.?<br>
&gt;&gt;<br>
&gt;&gt; I just ended up using --analyze because the scan-build command I could<br>
&gt;&gt; figure out was somewhat more verbose, needing --use-analyzer=... etc.;<br>
&gt;&gt; but,<br>
&gt;&gt; I was mostly fumbling around trying to get it to work, so I&#39;m sure \
I&#39;m<br> &gt;&gt; missing a bunch of different things.<br>
&gt;&gt;<br>
&gt;&gt; Thanks again.<br>
&gt;&gt;<br>
&gt;&gt; -Mike<br>
&gt;&gt;<br>
&gt;&gt;<br></div><div><div>
&gt;&gt; On Tue, Feb 25, 2014 at 11:00 AM, Ted Kremenek &lt;<a \
href="mailto:kremenek@apple.com" target="_blank">kremenek@apple.com</a>&gt;<br> \
&gt;&gt; wrote:<br> &gt;&gt;<br>
&gt;&gt; &gt; Hi Michael,<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; It&#39;s not recommended to run the low-level driver like this.  You \
can<br> &gt;&gt; just<br>
&gt;&gt; &gt; use scan-build, for example:<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;   $ scan-build clang -c /tmp/main.c<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; or more generally<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;   $ scan-build &lt;compiler line&gt;<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; You can also use:<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;   $ clang --analyze /tmp/main.c<br>
&gt;&gt;<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; directly.  That&#39;s somewhat discouraged because the long-term idea \
is<br> &gt;&gt; that<br>
&gt;&gt; &gt; the static analyzer supports global analysis.  The intention is that \
you<br> &gt;&gt; &gt; can declare a set of files to analyze and they get analyzed \
together,<br> &gt;&gt; &gt; whereas the latter line is clearly just analyzing a \
particular file<br> &gt;&gt; using<br>
&gt;&gt; &gt; clang.<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; Cheers,<br>
&gt;&gt; &gt; Ted<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; On Feb 21, 2014, at 2:22 PM, Michael Katelman &lt;<a \
href="mailto:katelman@gmail.com" target="_blank">katelman@gmail.com</a>&gt;<br> \
&gt;&gt; wrote:<br> &gt;&gt; &gt;<br>
&gt;&gt; &gt; &gt; I was wondering if someone might be able to help me with \
cleanly<br> &gt;&gt; &gt; invoking a single analyzer from the static analysis \
tools.<br> &gt;&gt; &gt; &gt;<br>
&gt;&gt; &gt; &gt; I am not sure what I need to do (or, should be doing instead) in \
a<br> &gt;&gt; &gt; situation like the one below where I&#39;ve got a header like \
stdio.h<br> &gt;&gt; included<br>
&gt;&gt; &gt; (--analyze figures it out, but then it appears that I lose the \
ability<br> &gt;&gt; to<br>
&gt;&gt; &gt; apply a single checker) :<br>
&gt;&gt; &gt; &gt;<br>
&gt;&gt; &gt; &gt; %  ./Debug+Asserts/bin/clang -cc1 -analyze<br>
&gt;&gt; &gt; -analyzer-checker=core.DivideZero ./tmp/main.c<br>
&gt;&gt; &gt; &gt;<br>
&gt;&gt; &gt; &gt; ./tmp/main.c:1:10: fatal error: &#39;stdio.h&#39; file not \
found<br> &gt;&gt; &gt; &gt; #include &lt;stdio.h&gt;<br>
&gt;&gt; &gt; &gt;          ^<br>
&gt;&gt; &gt; &gt; 1 error generated.<br>
&gt;&gt; &gt; &gt;<br>
&gt;&gt; &gt; &gt;  % cat ./tmp /main.c<br>
&gt;&gt; &gt; &gt;<br>
&gt;&gt; &gt; &gt; #include &lt;stdio.h&gt;<br>
&gt;&gt; &gt; &gt;<br>
&gt;&gt; &gt; &gt; int main( int argc, char** argv){<br>
&gt;&gt; &gt; &gt;   int x = 1;<br>
&gt;&gt; &gt; &gt;   int y = 0;<br>
&gt;&gt; &gt; &gt;<br>
&gt;&gt; &gt; &gt;   printf(&quot;%d\n&quot;, x / y);<br>
&gt;&gt; &gt; &gt;<br>
&gt;&gt; &gt; &gt;   return  0;<br>
&gt;&gt; &gt; &gt; }<br>
&gt;&gt; &gt; &gt;<br>
&gt;&gt; &gt; &gt; Thanks!<br></div></div></blockquote></div></div></div></div></div></div>
 </blockquote></div><br></div></div>
<br></div></div><div>_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@cs.uiuc.edu" target="_blank">cfe-dev@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" \
target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a><br> \
<br></div></blockquote></div><br></div> \
</blockquote></div></div></div><br></div></div></div> </blockquote></div><br></div>



_______________________________________________
cfe-dev mailing list
cfe-dev@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic