[cfe-dev] clang analyzer: exit of CompoundStmt

Matthias Gehre via cfe-dev cfe-dev at lists.llvm.org
Sun Oct 18 15:39:39 PDT 2015


Hi,

I'm currently trying to implement a clang analyzer check
to detect dangling pointers to a local (that went out of scope), like in:

void pointer_leaves_scope(bool bb) {
    int* p;
    {
        int i = 0;
        p = &i;
    } // need to get a callback here
    *p = 1; // should produce warning: i went out-of-scope
}

I first though that checkDeadSymbols(..) will be called when i goes out of
scope,
but it does not. Seems that I don't understand what checkDeadSymbols is
supposed to do.

I also tried checkPostStmt(CompoundStmt*,..), but that is not called either.

Now I'm looking how to implement this callback (could be named
checkSymbolLeavesScope).
Or something like checkEndFunction() but for all local scopes.

Could anyone please give me some hints where to add this to the analyzer
core?
I'm I missing something obvious?

Thanks,

Matthias
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20151019/2bf6605c/attachment.html>


More information about the cfe-dev mailing list