- Re-use approach used in codegen. MaterializeTemporaryExpr may be positioned in a strange manner, above the member access to the temporary, which makes it a bit tricky to find the expression that actually corresponds to the temporary object. FIXME: Hmm, probably we should re-use this approach in CFG as well (cf. D22419).
- Create the temporary region that corresponds to the full temporary object, rather than to the sub-object. This was a bug.
- If lifetime extension occurs, use the temporary object region's path-sensitive type, rather than reference variable type, in order to call the correct destructor.
Details
- Reviewers
dcoughlin a.sidorin zaks.anna xazax.hun - Commits
- rG28ee2d1b0973: [analyzer] Construct temporary objects of correct types, destroy them properly.
rC288263: [analyzer] Construct temporary objects of correct types, destroy them properly.
rL288263: [analyzer] Construct temporary objects of correct types, destroy them properly.
Diff Detail
Event Timeline
test/Analysis/lifetime-extension.cpp | ||
---|---|---|
12 | what is the role of S in this test ? |
test/Analysis/lifetime-extension.cpp | ||
---|---|---|
12 | I copy-pasted this from the original bug report. The only purpose of S is to provide a non-trivial destructor. I also thought it'd be a nice twist to the test to make the destructor non-obvious, but it doesn't really matter. Removed. |
This is great!
lib/StaticAnalyzer/Core/ExprEngine.cpp | ||
---|---|---|
226–229 | I think it would good to show an AST representation in the comment to make it clear what "out of place" means. This could be a very simplified version of the dumped AST for a temporary with a field access. |
I think it would good to show an AST representation in the comment to make it clear what "out of place" means. This could be a very simplified version of the dumped AST for a temporary with a field access.