]> granicus.if.org Git - clang/commit
[CFG] Fix automatic destructors when a member is bound to a reference.
authorArtem Dergachev <artem.dergachev@gmail.com>
Mon, 4 Jun 2018 18:56:25 +0000 (18:56 +0000)
committerArtem Dergachev <artem.dergachev@gmail.com>
Mon, 4 Jun 2018 18:56:25 +0000 (18:56 +0000)
commit51f877dbebe07f539f3f24acb88ef4f3f0737339
tree17fa1db6c0eaace0e27894a2c8cd67b6ee2106dc
parent415982d6f7663fc60802a85d21c658bd534a7b60
[CFG] Fix automatic destructors when a member is bound to a reference.

In code like

    const int &x = A().x;

automatic destructor for the object A() lifetime-extended by reference 'x' was
not present in the clang CFG due to ad-hoc pattern-matching in
getReferenceInitTemporaryType().

Re-use skipRValueSubobjectAdjustments() again to find the lifetime-extended
object in the AST and emit the correct destructor.

Lifetime extension through aggregates with references still needs to be covered.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@333941 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Analysis/CFG.cpp
test/Analysis/auto-obj-dtors-cfg-output.cpp