This is an archive of the discontinued LLVM Phabricator instance.

[analyzer] ScopeContext - initial implementation
Needs ReviewPublic

Authored by a.sidorin on May 5 2016, 9:05 AM.

Details

Summary

This patch enables ScopeContext to track variable lifetime. It is RFC mostly since the work on its dependencies is still not finished and it lacks some tests.
Pre-discussion took place in cfe-dev:

StackLocalsSpaceRegion is still present to preserve current behaviour because 'cfg-scope-info' is false by default.

Diff Detail

Event Timeline

a.sidorin updated this revision to Diff 56296.May 5 2016, 9:05 AM
a.sidorin retitled this revision from to [analyzer] ScopeContext - initial implementation.
a.sidorin updated this object.
a.sidorin added a subscriber: cfe-commits.
NoQ added a subscriber: NoQ.May 6 2016, 7:58 AM
NoQ added a comment.Nov 2 2016, 8:15 AM

https://llvm.org/bugs/show_bug.cgi?id=28450
^Another impressing test case for variable scopes, which should ideally be fixed by scope contexts, even though i doubt this patch (or the CFG patch) addresses this issue. Variable-length arrays might actually mess up things quite a bit.

Long story short, every time a goto jumps to before VLA was declared, it gets re-allocated. And we need to represent it as a different VarRegion for the same declaration. We could extend the region hierarchy to treat VLAs specially, but ideally it seems saner to me to make a VarRegion on top of a different scope memspace every time VLA is re-allocated.

Hm. A pretty nice example. But we should check if the initial patch supports gotos; afair, it doesn't.

What is the status of this?
Aleksei, could you upload a new patch with the context available?
(And also with a testcase added for jumps/gotos and VLA.)

You modified the malloc checker but I did not see a test for that.

szepet added a subscriber: szepet.Jun 22 2017, 9:09 AM

This patch still depends on scope implementation in CFG. There is no final implementation; after initial implementation is done, I'll update the patch.