diff options
author | Akira Hatanaka <ahatanaka@apple.com> | 2018-07-26 16:51:21 +0000 |
---|---|---|
committer | Akira Hatanaka <ahatanaka@apple.com> | 2018-07-26 16:51:21 +0000 |
commit | cb6a933c9bd010f06b0ae50893afb3f821bd5fe0 (patch) | |
tree | a8d4d01d376436d9211d8ae6d7c213b42770854b /clang/lib/CodeGen/CodeGenFunction.h | |
parent | 6fcc7d703b571f456f662a0be1ec6f449d55fdb9 (diff) | |
download | bcm5719-llvm-cb6a933c9bd010f06b0ae50893afb3f821bd5fe0.tar.gz bcm5719-llvm-cb6a933c9bd010f06b0ae50893afb3f821bd5fe0.zip |
[CodeGen][ObjC] Make block copy/dispose helper functions exception-safe.
When an exception is thrown in a block copy helper function, captured
objects that have previously been copied should be destructed or
released. Similarly, captured objects that are yet to be released should
be released when an exception is thrown in a dispose helper function.
rdar://problem/42410255
Differential Revision: https://reviews.llvm.org/D49718
llvm-svn: 338041
Diffstat (limited to 'clang/lib/CodeGen/CodeGenFunction.h')
-rw-r--r-- | clang/lib/CodeGen/CodeGenFunction.h | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/clang/lib/CodeGen/CodeGenFunction.h b/clang/lib/CodeGen/CodeGenFunction.h index 752d670a5f2..79870ed59c9 100644 --- a/clang/lib/CodeGen/CodeGenFunction.h +++ b/clang/lib/CodeGen/CodeGenFunction.h @@ -1758,7 +1758,25 @@ public: class AutoVarEmission; void emitByrefStructureInit(const AutoVarEmission &emission); - void enterByrefCleanup(const AutoVarEmission &emission); + + /// Enter a cleanup to destroy a __block variable. Note that this + /// cleanup should be a no-op if the variable hasn't left the stack + /// yet; if a cleanup is required for the variable itself, that needs + /// to be done externally. + /// + /// \param Kind Cleanup kind. + /// + /// \param Addr When \p LoadBlockVarAddr is false, the address of the __block + /// structure that will be passed to _Block_object_dispose. When + /// \p LoadBlockVarAddr is true, the address of the field of the block + /// structure that holds the address of the __block structure. + /// + /// \param Flags The flag that will be passed to _Block_object_dispose. + /// + /// \param LoadBlockVarAddr Indicates whether we need to emit a load from + /// \p Addr to get the address of the __block structure. + void enterByrefCleanup(CleanupKind Kind, Address Addr, BlockFieldFlags Flags, + bool LoadBlockVarAddr); void setBlockContextParameter(const ImplicitParamDecl *D, unsigned argNum, llvm::Value *ptr); |