[cfe-commits] r135638 - in /cfe/trunk: lib/Sema/SemaStmt.cpp test/CodeGenObjC/arc-with-atthrow.m

Fariborz Jahanian fjahanian at apple.com
Wed Jul 20 16:39:56 PDT 2011


Author: fjahanian
Date: Wed Jul 20 18:39:56 2011
New Revision: 135638

URL: http://llvm.org/viewvc/llvm-project?rev=135638&view=rev
Log:
objc-arc: Fixes a crash @throw'ing an objc message.
// pr10411

Added:
    cfe/trunk/test/CodeGenObjC/arc-with-atthrow.m
Modified:
    cfe/trunk/lib/Sema/SemaStmt.cpp

Modified: cfe/trunk/lib/Sema/SemaStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaStmt.cpp?rev=135638&r1=135637&r2=135638&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaStmt.cpp (original)
+++ cfe/trunk/lib/Sema/SemaStmt.cpp Wed Jul 20 18:39:56 2011
@@ -2154,6 +2154,7 @@
 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 @@
     if (!AtCatchParent)
       return StmtError(Diag(AtLoc, diag::error_rethrow_used_outside_catch));
   }
-
+  
   return BuildObjCAtThrowStmt(AtLoc, Throw);
 }
 

Added: cfe/trunk/test/CodeGenObjC/arc-with-atthrow.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/arc-with-atthrow.m?rev=135638&view=auto
==============================================================================
--- cfe/trunk/test/CodeGenObjC/arc-with-atthrow.m (added)
+++ cfe/trunk/test/CodeGenObjC/arc-with-atthrow.m Wed Jul 20 18:39:56 2011
@@ -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
+
+ at interface NSException
++ (id)exception;
+ at end
+
+void test() 
+{ 
+  @throw [NSException exception]; 
+}
+
+// CHECK: objc_retainAutoreleasedReturnValue
+// CHECK:   call void @objc_release
+// CHECK:   call void @objc_exception_throw





More information about the cfe-commits mailing list