diff options
| author | John McCall <rjmccall@apple.com> | 2012-01-17 20:16:56 +0000 |
|---|---|---|
| committer | John McCall <rjmccall@apple.com> | 2012-01-17 20:16:56 +0000 |
| commit | 9701731a3e9eaf98af5b4ea1104f727212dc7cf6 (patch) | |
| tree | c9a30d36ada310e814dc46024d71b3a1f509579c /clang/lib/CodeGen/CGException.cpp | |
| parent | 0ae6e671ccd1d1bd16fe7d360e465dcc56473c9b (diff) | |
| download | bcm5719-llvm-9701731a3e9eaf98af5b4ea1104f727212dc7cf6.tar.gz bcm5719-llvm-9701731a3e9eaf98af5b4ea1104f727212dc7cf6.zip | |
When initializing a catch variable in ARC, be sure to emit retains
or whatever else is required for the initialization instead of
assuming it can be done with a simple store.
Fixes PR11732.
llvm-svn: 148325
Diffstat (limited to 'clang/lib/CodeGen/CGException.cpp')
| -rw-r--r-- | clang/lib/CodeGen/CGException.cpp | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/clang/lib/CodeGen/CGException.cpp b/clang/lib/CodeGen/CGException.cpp index 15d8d42fa2c..7600c48bdbc 100644 --- a/clang/lib/CodeGen/CGException.cpp +++ b/clang/lib/CodeGen/CGException.cpp @@ -984,8 +984,23 @@ static void InitCatchParam(CodeGenFunction &CGF, if (CatchType->hasPointerRepresentation()) { llvm::Value *CastExn = CGF.Builder.CreateBitCast(AdjustedExn, LLVMCatchTy, "exn.casted"); - CGF.Builder.CreateStore(CastExn, ParamAddr); - return; + + switch (CatchType.getQualifiers().getObjCLifetime()) { + case Qualifiers::OCL_Strong: + CastExn = CGF.EmitARCRetainNonBlock(CastExn); + // fallthrough + + case Qualifiers::OCL_None: + case Qualifiers::OCL_ExplicitNone: + case Qualifiers::OCL_Autoreleasing: + CGF.Builder.CreateStore(CastExn, ParamAddr); + return; + + case Qualifiers::OCL_Weak: + CGF.EmitARCInitWeak(ParamAddr, CastExn); + return; + } + llvm_unreachable("bad ownership qualifier!"); } // Otherwise, it returns a pointer into the exception object. |

