]> granicus.if.org Git - clang/commitdiff
When generating cleanup blocks for Obj-C @finally, mark them as catch all blocks
authorDaniel Dunbar <daniel@zuster.org>
Mon, 3 Aug 2009 21:20:07 +0000 (21:20 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Mon, 3 Aug 2009 21:20:07 +0000 (21:20 +0000)
from the perspective of LLVM exception handling. Otherwise the C++ personality
function may decide not to run them, if it only detects cleanup handlers.
 - Test case for this is exceptions.m in llvm-test.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@77999 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGObjCMac.cpp

index cc1a4392ce4545c2ef55fc3844154c4e2c863624..3c61cb8f7f70c00a1d6c09aa53a8554dc0b10b8b 100644 (file)
@@ -5470,7 +5470,10 @@ CGObjCNonFragileABIMac::EmitTryOrSynchronizedStmt(CodeGen::CodeGenFunction &CGF,
 
   // We use a cleanup unless there was already a catch all.
   if (!HasCatchAll) {
-    SelectorArgs.push_back(llvm::ConstantInt::get(llvm::Type::Int32Ty, 0));
+    // Even though this is a cleanup, treat it as a catch all to avoid the C++
+    // personality behavior of terminating the process if only cleanups are
+    // found in the exception handling stack.
+    SelectorArgs.push_back(llvm::Constant::getNullValue(ObjCTypes.Int8PtrTy));
     Handlers.push_back(std::make_pair((const ParmVarDecl*) 0, (const Stmt*) 0));
   }