]> granicus.if.org Git - clang/commit
[analyzer] pr32088: Don't destroy the temporary if its initializer causes return.
authorDevin Coughlin <dcoughlin@apple.com>
Wed, 1 Mar 2017 17:48:39 +0000 (17:48 +0000)
committerDevin Coughlin <dcoughlin@apple.com>
Wed, 1 Mar 2017 17:48:39 +0000 (17:48 +0000)
commit162132fe03c8c2b02735f2adfd4e2dc421488006
tree990bbf60d0e3c30a3166ae26cf902505d30c8804
parenta3101dbac2a5eac07a9d844bc19d0a0e5bdafd45
[analyzer] pr32088: Don't destroy the temporary if its initializer causes return.

In the following code involving GNU statement-expression extension:
  struct S {
    ~S();
  };

  void foo() {
    const S &x = ({ return; S(); });
  }
function 'foo()' returns before reference x is initialized. We shouldn't call
the destructor for the temporary object lifetime-extended by 'x' in this case,
because the object never gets constructed in the first place.

The real problem is probably in the CFG somewhere, so this is a quick-and-dirty
hotfix rather than the perfect solution.

A patch by Artem Dergachev!

rdar://problem/30759076

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

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