[PATCH] D40560: [analyzer] Get construction into `operator new` running in simple cases.
Artem Dergachev via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Jan 9 19:23:31 PST 2018
NoQ updated this revision to Diff 129210.
NoQ added a comment.
That thing didn't immediately work, because there are a lot of other places where we need to put the value, not just the Store, before entering the constructor - such as our constructor call events for checker callbacks. It'd be hard for the call event to extract the target region by looking at their caller stack frame and program state, and perhaps they shouldn't be doing this, and it's actually fine that they receive the target region directly, because if we want to reconstruct the call event after the fact, we'd anyway be able to do this only from within the constructor call, because later the value would disappear from the program state anyway.
The idea with the new location context class still stands. For now i made a simple map from (`CallerStackFrameContext`, `CXXNewExpr`) pairs to `SVal`. This map can be trivially refactored into a map from `OurNewLocationContext` to `SVal`, because `CallerStackFrame` would be its parent context, and `CXXNewExpr` would be its parameter. Note that it's not possible to use only `CallerStackFrameContext` as the key because multiple `CXXNewExpr`s might be active simultaneously, eg. `new X(new Y())` - respective test case added. But with `CXXNewExpr` as part of the key, the key is indeed unique in the sense that by the time we encounter the same `CXXNewExpr` again we'd be done with the old `CXXNewExpr` - respective assertion added. With these assertions i guess it's more reliable than the stack approach.
I think i'm getting done with these patches, so they can be treated as in sort of final shape, i.e. i have no planned changes for these myself anymore (but i'd definitely gladly address any review comments).
https://reviews.llvm.org/D40560
Files:
include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
lib/StaticAnalyzer/Core/ExprEngine.cpp
lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
test/Analysis/inline.cpp
test/Analysis/new-ctor-conservative.cpp
test/Analysis/new-ctor-inlined.cpp
test/Analysis/new-ctor-recursive.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D40560.129210.patch
Type: text/x-patch
Size: 21228 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180110/8d8969ae/attachment-0001.bin>
More information about the cfe-commits
mailing list