]> granicus.if.org Git - clang/commitdiff
Add block information for ObjC @catch blocks.
authorEric Christopher <echristo@apple.com>
Wed, 19 Oct 2011 00:44:01 +0000 (00:44 +0000)
committerEric Christopher <echristo@apple.com>
Wed, 19 Oct 2011 00:44:01 +0000 (00:44 +0000)
Fixes rdar://10282889

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

lib/CodeGen/CGObjCRuntime.cpp
test/CodeGenObjC/catch-lexical-block.m [new file with mode: 0644]

index ef426ce6ed9bef828f98ef60ef364b8c287d0f28..bcacb8ea467702b7926633495ef149fc9f242b15 100644 (file)
@@ -229,7 +229,7 @@ void CGObjCRuntime::EmitTryCatchStmt(CodeGenFunction &CGF,
       cast<llvm::CallInst>(Exn)->setDoesNotThrow();
     }
 
-    CodeGenFunction::RunCleanupsScope cleanups(CGF);
+    CodeGenFunction::LexicalScope cleanups(CGF, Handler.Body->getSourceRange());
 
     if (endCatchFn) {
       // Add a cleanup to leave the catch.
diff --git a/test/CodeGenObjC/catch-lexical-block.m b/test/CodeGenObjC/catch-lexical-block.m
new file mode 100644 (file)
index 0000000..f4a6a22
--- /dev/null
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -g -fobjc-exceptions -emit-llvm %s -o - | FileCheck %s
+@interface Foo @end
+void f0() {
+  @try {
+    @throw @"a";
+  } @catch(Foo *e) {
+  }
+}
+
+// We should have 4 lexical blocks here at the moment, including one
+// for the catch block.
+// CHECK: lexical_block
+// CHECK: lexical_block
+// CHECK: lexical_block
+// CHECK: auto_variable
+// CHECK: lexical_block