[Clang Static Analyzer] CheckDeadSymbol Callback not received

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

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

Thanks and Regards
Karthik

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.