]> granicus.if.org Git - clang/commit
[analyzer] Improve modeling for returning an object from the top frame with RVO.
authorArtem Dergachev <artem.dergachev@gmail.com>
Wed, 19 Dec 2018 23:14:06 +0000 (23:14 +0000)
committerArtem Dergachev <artem.dergachev@gmail.com>
Wed, 19 Dec 2018 23:14:06 +0000 (23:14 +0000)
commit61c52cbbb1d80578ae77658f4049fda7c5b7edfd
tree4a5f2d1add702e6f2c5e84d79398b45acd80f008
parenta2c62be9195ddfa400c07810c03a11f9325f37e7
[analyzer] Improve modeling for returning an object from the top frame with RVO.

Static Analyzer processes the program function-by-function, sometimes diving
into other functions ("inlining" them). When an object is returned from an
inlined function, Return Value Optimization is modeled, and the returned object
is constructed at its return location directly.

When an object is returned from the function from which the analysis has started
(the top stack frame of the analysis), the return location is unknown. Model it
with a SymbolicRegion based on a conjured symbol that is specifically tagged for
that purpose, because this is generally the correct way to symbolicate
unknown locations in Static Analyzer.

Fixes leak false positives when an object is returned from top frame in C++17:
objects that are put into a SymbolicRegion-based memory region automatically
"escape" and no longer get reported as leaks. This only applies to C++17 return
values with destructors, because it produces a redundant CXXBindTemporaryExpr
in the call site, which confuses our liveness analysis. The actual fix
for liveness analysis is still pending, but it is no longer causing problems.

Additionally, re-enable temporary destructor tests in C++17.

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

rdar://problem/46217550

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@349696 91177308-0d34-0410-b5e6-96231b3b80d8
lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
test/Analysis/temporaries.cpp