Implement function-try-blocks. However, there's a very subtle bug that I can't track down.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70155 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/CGObjC.cpp b/lib/CodeGen/CGObjC.cpp
index df49c70..de89f0d 100644
--- a/lib/CodeGen/CGObjC.cpp
+++ b/lib/CodeGen/CGObjC.cpp
@@ -129,7 +129,7 @@
DebugInfo = CGM.getDebugInfo();
StartObjCMethod(OMD, OMD->getClassInterface());
EmitStmt(OMD->getBody(getContext()));
- FinishFunction(cast<CompoundStmt>(OMD->getBody(getContext()))->getRBracLoc());
+ FinishFunction(OMD->getBodyRBrace(getContext()));
}
// FIXME: I wasn't sure about the synthesis approach. If we end up
diff --git a/lib/CodeGen/CodeGenFunction.cpp b/lib/CodeGen/CodeGenFunction.cpp
index c05ead5..c74f834 100644
--- a/lib/CodeGen/CodeGenFunction.cpp
+++ b/lib/CodeGen/CodeGenFunction.cpp
@@ -225,12 +225,13 @@
FProto->getArgType(i)));
}
- const CompoundStmt *S = FD->getBody(getContext());
+ // FIXME: Support CXXTryStmt here, too.
+ if (const CompoundStmt *S = FD->getCompoundBody(getContext())) {
+ StartFunction(FD, FD->getResultType(), Fn, Args, S->getLBracLoc());
+ EmitStmt(S);
+ FinishFunction(S->getRBracLoc());
+ }
- StartFunction(FD, FD->getResultType(), Fn, Args, S->getLBracLoc());
- EmitStmt(S);
- FinishFunction(S->getRBracLoc());
-
// Destroy the 'this' declaration.
if (CXXThisDecl)
CXXThisDecl->Destroy(getContext());