]> granicus.if.org Git - clang/commit
[analyzer] Introduce correct lifetime extension behavior in simple cases.
authorArtem Dergachev <artem.dergachev@gmail.com>
Tue, 27 Feb 2018 19:47:49 +0000 (19:47 +0000)
committerArtem Dergachev <artem.dergachev@gmail.com>
Tue, 27 Feb 2018 19:47:49 +0000 (19:47 +0000)
commitb4b42d682156c989482f9c03c0eb52e2c1b8aa90
tree4a12377a2253fbd3cd9f8c060812b0469a4994c5
parent9be874366e5e965a2d3b77dee6f2e0fa7bd40a81
[analyzer] Introduce correct lifetime extension behavior in simple cases.

This patch uses the reference to MaterializeTemporaryExpr stored in the
construction context since r326014 in order to model that expression correctly.

When modeling MaterializeTemporaryExpr, instead of copying the raw memory
contents from the sub-expression's rvalue to a completely new temporary region,
that we conjure up for the lack of better options, we now have the better
option to recall the region into which the object was originally constructed
and declare that region to be the value of the expression, which is semantically
correct.

This only works when the construction context is available, which is worked on
independently.

The temporary region's liveness (in the sense of removeDeadBindings) is extended
until the MaterializeTemporaryExpr is resolved, in order to keep the store
bindings around, because it wouldn't be referenced from anywhere else in the
program state.

Differential Revision: https://reviews.llvm.org/D43497

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@326236 91177308-0d34-0410-b5e6-96231b3b80d8
include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
lib/StaticAnalyzer/Core/ExprEngine.cpp
lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
test/Analysis/lifetime-extension.cpp
test/Analysis/temporaries.cpp