Revision: 126769
Author:   clattner
Date:     2007-05-01 11:46:41 -0700 (Tue, 01 May 2007)

Log Message:
-----------
>From Duncan Sands:

According to the documentation, the handler for a TRY_CATCH_EXPR can be:

- A sequence of statements to execute.  When an exception occurs,
these statements are executed, and then the exception is rethrown.

- A sequence of CATCH_EXPR expressions.  Each CATCH_EXPR
has a list of applicable exception types and handler code.  If the
thrown exception matches one of the caught types, the associated
handler code is executed.  If the handler code falls off the bottom,
execution continues after the original TRY_CATCH_EXPR.

- An EH_FILTER_EXPR expression.  This has a list of
permitted exception types, and code to handle a match failure.  If the
thrown exception does not match one of the allowed types, the
associated match failure code is executed.  If the thrown exception
does match, it continues unwinding the stack looking for the next
handler.

However GatherTypeInfo wasn't expecting the first case, causing a crash
when building the C++ runtime.  Fix and testcase attached.

Testcase here: C++Frontend/2007-04-31-TryCatch.cpp

Modified Paths:
--------------
    apple-local/branches/llvm/gcc/llvm-convert.cpp

Modified: apple-local/branches/llvm/gcc/llvm-convert.cpp
===================================================================
--- apple-local/branches/llvm/gcc/llvm-convert.cpp      2007-05-01 17:59:57 UTC 
(rev 126768)
+++ apple-local/branches/llvm/gcc/llvm-convert.cpp      2007-05-01 18:46:41 UTC 
(rev 126769)
@@ -1868,11 +1868,12 @@
         TypeInfos.push_back(TypeInfo);
       }
     }
-  } else {
-    assert(TREE_CODE(exp) == STATEMENT_LIST && "Need an exp with typeinfo");
-    // Each statement in the statement list will be a catch.
+  } else if (TREE_CODE(exp) == STATEMENT_LIST) {
+    // Each statement in the statement list will be a catch, or none will.
     for (tree_stmt_iterator I = tsi_start(exp); !tsi_end_p(I); tsi_next(&I))
       GatherTypeInfo(tsi_stmt(I), TypeInfos);
+  } else {
+    assert(TypeInfos.empty() && "Need an exp with typeinfo");
   }
 }
 


_______________________________________________
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits

Reply via email to