[CodeGen] Avoid destructing a callee-destructued struct type in a
authorAkira Hatanaka <ahatanaka@apple.com>
Fri, 27 Apr 2018 04:21:51 +0000 (04:21 +0000)
committerAkira Hatanaka <ahatanaka@apple.com>
Fri, 27 Apr 2018 04:21:51 +0000 (04:21 +0000)
commite712374496147f61ff701ee46bdd9932366521c6
treead3b905195500be4f8400e38a45b6977533793aa
parentfa7fd13cf8b33f879c2f3b80dc7e91ac0cace0bd
[CodeGen] Avoid destructing a callee-destructued struct type in a
function if a function delegates to another function.

Fix a bug introduced in r328731, which caused a struct with ObjC __weak
fields that was passed to a function to be destructed twice, once in the
callee function and once in another function the callee function
delegates to. To prevent this, keep track of the callee-destructed
structs passed to a function and disable their cleanups at the point of
the call to the delegated function.

rdar://problem/39194693

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

llvm-svn: 331016
clang/lib/CodeGen/CGCall.cpp
clang/lib/CodeGen/CGCleanup.cpp
clang/lib/CodeGen/CGDecl.cpp
clang/lib/CodeGen/CodeGenFunction.h
clang/test/CodeGenObjCXX/arc-forwarded-lambda-call.mm
clang/test/CodeGenObjCXX/arc-special-member-functions.mm
clang/test/CodeGenObjCXX/lambda-expressions.mm