diff options
| author | Douglas Gregor <dgregor@apple.com> | 2010-04-23 22:50:49 +0000 |
|---|---|---|
| committer | Douglas Gregor <dgregor@apple.com> | 2010-04-23 22:50:49 +0000 |
| commit | 96c79498fbcc1e7d03cba88725dffafb2b568c53 (patch) | |
| tree | 8c74d92c11e42f011bf0ced629759b8ebdb5b626 /clang/lib/CodeGen/CGObjCGNU.cpp | |
| parent | 11d1df442dfd0f526f659a5447df6dfe7695f41d (diff) | |
| download | bcm5719-llvm-96c79498fbcc1e7d03cba88725dffafb2b568c53.tar.gz bcm5719-llvm-96c79498fbcc1e7d03cba88725dffafb2b568c53.zip | |
Improve the AST representation of Objective-C @try/@catch/@finally
statements. Instead of the @try having a single @catch, where all of
the @catch's were chained (using an O(n^2) algorithm nonetheless),
@try just holds an array of its @catch blocks. The resulting AST is
slightly more compact (not important) and better represents the actual
language semantics (good).
llvm-svn: 102221
Diffstat (limited to 'clang/lib/CodeGen/CGObjCGNU.cpp')
| -rw-r--r-- | clang/lib/CodeGen/CGObjCGNU.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/clang/lib/CodeGen/CGObjCGNU.cpp b/clang/lib/CodeGen/CGObjCGNU.cpp index 36162f7e5e5..a248c5a1be0 100644 --- a/clang/lib/CodeGen/CGObjCGNU.cpp +++ b/clang/lib/CodeGen/CGObjCGNU.cpp @@ -1781,11 +1781,12 @@ void CGObjCGNU::EmitTryOrSynchronizedStmt(CodeGen::CodeGenFunction &CGF, bool HasCatchAll = false; // Only @try blocks are allowed @catch blocks, but both can have @finally if (isTry) { - if (const ObjCAtCatchStmt* CatchStmt = - cast<ObjCAtTryStmt>(S).getCatchStmts()) { + if (cast<ObjCAtTryStmt>(S).getNumCatchStmts()) { + const ObjCAtTryStmt &AtTry = cast<ObjCAtTryStmt>(S); CGF.setInvokeDest(CatchInCatch); - for (; CatchStmt; CatchStmt = CatchStmt->getNextCatchStmt()) { + for (unsigned I = 0, N = AtTry.getNumCatchStmts(); I != N; ++I) { + const ObjCAtCatchStmt *CatchStmt = AtTry.getCatchStmt(I); const ParmVarDecl *CatchDecl = CatchStmt->getCatchParamDecl(); Handlers.push_back(std::make_pair(CatchDecl, CatchStmt->getCatchBody())); |

