]> granicus.if.org Git - clang/commit
[analyzer] Track temporaries without construction contexts for destruction.
authorArtem Dergachev <artem.dergachev@gmail.com>
Tue, 27 Feb 2018 21:02:58 +0000 (21:02 +0000)
committerArtem Dergachev <artem.dergachev@gmail.com>
Tue, 27 Feb 2018 21:02:58 +0000 (21:02 +0000)
commit0dacdd09c3ba4749c17fffe90c98e959b88badfa
tree3d767d86febbcea19df481dc93a2d3ea251150ba
parente11b115b52b525756931b0d7f125a28166702791
[analyzer] Track temporaries without construction contexts for destruction.

Sometimes it is not known at compile time which temporary objects will be
constructed, eg. 'x ? A() : B()' or 'C() || D()'. In this case we track which
temporary was constructed to know how to properly call the destructor.

Once the construction context for temporaries was introduced, we moved the
tracking code to the code that investigates the construction context.

Bring back the old mechanism because construction contexts are not always
available yet - eg. in the case where a temporary is constructed without a
constructor expression, eg. returned from a function by value. The mechanism
should still go away eventually.

Additionally, fix a bug in the temporary cleanup code for the case when
construction contexts are not available, which could lead to temporaries
staying in the program state and increasing memory consumption.

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

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