aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2011-07-20 23:39:56 +0000
committerFariborz Jahanian <fjahanian@apple.com>2011-07-20 23:39:56 +0000
commitf2dd68fb37a62571a4985c8dd05310ac90d07ef0 (patch)
tree6ac216eb3c6f08a3985e9ebe36b7d308e11ffa9d
parente9b76c11a88d0af98f32d11a6668d03d45be3123 (diff)
objc-arc: Fixes a crash @throw'ing an objc message.
// pr10411 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135638 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Sema/SemaStmt.cpp3
-rw-r--r--test/CodeGenObjC/arc-with-atthrow.m16
2 files changed, 18 insertions, 1 deletions
diff --git a/lib/Sema/SemaStmt.cpp b/lib/Sema/SemaStmt.cpp
index 65f431d460..7acfc985db 100644
--- a/lib/Sema/SemaStmt.cpp
+++ b/lib/Sema/SemaStmt.cpp
@@ -2154,6 +2154,7 @@ Sema::ActOnObjCAtTryStmt(SourceLocation AtLoc, Stmt *Try,
StmtResult Sema::BuildObjCAtThrowStmt(SourceLocation AtLoc,
Expr *Throw) {
if (Throw) {
+ Throw = MaybeCreateExprWithCleanups(Throw);
ExprResult Result = DefaultLvalueConversion(Throw);
if (Result.isInvalid())
return StmtError();
@@ -2188,7 +2189,7 @@ Sema::ActOnObjCAtThrowStmt(SourceLocation AtLoc, Expr *Throw,
if (!AtCatchParent)
return StmtError(Diag(AtLoc, diag::error_rethrow_used_outside_catch));
}
-
+
return BuildObjCAtThrowStmt(AtLoc, Throw);
}
diff --git a/test/CodeGenObjC/arc-with-atthrow.m b/test/CodeGenObjC/arc-with-atthrow.m
new file mode 100644
index 0000000000..b076879bdd
--- /dev/null
+++ b/test/CodeGenObjC/arc-with-atthrow.m
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -fobjc-arc -fobjc-nonfragile-abi -fobjc-exceptions -o - %s | FileCheck %s
+// $CLANG -cc1 -fobjc-arc -fobjc-nonfragile-abi -fobjc-exceptions
+// pr10411
+
+@interface NSException
++ (id)exception;
+@end
+
+void test()
+{
+ @throw [NSException exception];
+}
+
+// CHECK: objc_retainAutoreleasedReturnValue
+// CHECK: call void @objc_release
+// CHECK: call void @objc_exception_throw