[cfe-dev] [Clang Static Analyzer] CheckDeadSymbol Callback not received

Anna Zaks ganna at apple.com
Tue Jun 18 10:02:58 PDT 2013


On Jun 18, 2013, at 2:51 AM, Karthik Bhat <blitz.opensource at gmail.com> wrote:

> Hi,
> I'm working with SimpleStreamChecker (3.2 Version). 
> 

It's best to work with TOT.

> For a code like -
> 
> void dummyClose(FILE* fp) {
>   return;
> }
> 
> int main() {
>  FILE* fp = fopen("myfile","w");
>  dummyClose(fp);
>  return 0;
> }
> 
> i'm unable to get checkDeadSymbol callback when symbol corresponding to FILE* fp dies. 
> 
> Could anyone please let me know if something is going wrong?
> 
> I'm running  clang++ -cc1 -analyze -analyzer-checker=alpha.unix.SimpleStream test.cpp
> 

Do you see a warning issued?

When analyzing this code with TOT clang, I get:
clang -cc1 -analyze -analyzer-checker=core,alpha.unix.SimpleStream ~/tmp/ex.c
/Users/zaks/tmp/ex.c:9:2: warning: Opened file is never closed; potential resource leak
 return 0;
 ^~~~~~~~
1 warning generated.


Also, even though it might not be relevant in this case, it is useful to always include core in the list of checkers you are running.

Cheers,
Anna.

> Thanks and Regards
> Karthik
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20130618/84a292cb/attachment.html>


More information about the cfe-dev mailing list