[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)
commit1e3dbd7a17b3cfbda5a0b83812020122a82a9e0e
tree4bf15a57fc82e5bfddb2479cd126eaea0c9dddd6
parentf01831ebe9fb1a9395318d4f5f854ee9d862a359
[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

llvm-svn: 326246
clang/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
clang/test/Analysis/temporaries.cpp