diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2007-11-01 21:12:44 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2007-11-01 21:12:44 +0000 |
commit | b210bd0404f84b99259c9987d347a44d3c202238 (patch) | |
tree | bc50b0a7a1b9aef32a527e5f1c5bca7ab0381131 /include | |
parent | 88a981b47c7face1b1fdaa9074256245107b9ca9 (diff) |
Bunch of class declarations for objective-c's @try-catch statement.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43623 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r-- | include/clang/AST/Stmt.h | 90 | ||||
-rw-r--r-- | include/clang/AST/StmtNodes.def | 8 | ||||
-rw-r--r-- | include/clang/Parse/Parser.h | 2 |
3 files changed, 97 insertions, 3 deletions
diff --git a/include/clang/AST/Stmt.h b/include/clang/AST/Stmt.h index fa0dc9d234..580b3d6dbd 100644 --- a/include/clang/AST/Stmt.h +++ b/include/clang/AST/Stmt.h @@ -657,7 +657,95 @@ public: virtual child_iterator child_begin(); virtual child_iterator child_end(); }; - + +/// ObjcAtCatchStmt - This represents objective-c's @catch statement. +class ObjcAtCatchStmt : public Stmt { +private: + // Points to next @catch statement, or null + ObjcAtCatchStmt *NextAtCatchStmt; + ScopedDecl *AtCatchDeclarator; + Stmt *AtCatchStmt; + + SourceLocation AtCatchLoc, RParenLoc; +public: + ObjcAtCatchStmt(SourceLocation atCatchLoc, SourceLocation rparenloc, + ScopedDecl *atCatchDeclarator, Stmt *atCatchStmt) + : Stmt(ObjcAtCatchStmtClass), NextAtCatchStmt(0), + AtCatchDeclarator(atCatchDeclarator), AtCatchStmt(atCatchStmt), + AtCatchLoc(atCatchLoc), RParenLoc(rparenloc) {} + + virtual SourceRange getSourceRange() const { + return SourceRange(AtCatchLoc, AtCatchStmt->getLocEnd()); + } + + static bool classof(const Stmt *T) { + return T->getStmtClass() == ObjcAtCatchStmtClass; + } + static bool classof(const ObjcAtCatchStmt *) { return true; } + + virtual child_iterator child_begin(); + virtual child_iterator child_end(); + +}; + +/// ObjcAtFinallyStmt - This represent objective-c's @finally Statement +class ObjcAtFinallyStmt : public Stmt { + private: + Stmt *AtFinallyStmt; + SourceLocation AtFinallyLoc; + + public: + ObjcAtFinallyStmt(SourceLocation atFinallyLoc, Stmt *atFinallyStmt) + : Stmt(ObjcAtFinallyStmtClass), + AtFinallyStmt(atFinallyStmt), AtFinallyLoc(atFinallyLoc) {} + + virtual SourceRange getSourceRange() const { + return SourceRange(AtFinallyLoc, AtFinallyStmt->getLocEnd()); + } + + static bool classof(const Stmt *T) { + return T->getStmtClass() == ObjcAtFinallyStmtClass; + } + static bool classof(const ObjcAtFinallyStmt *) { return true; } + + virtual child_iterator child_begin(); + virtual child_iterator child_end(); + +}; + +/// ObjcAtTryStmt - This represent objective-c's over-all +/// @try ... @catch ... @finally statement. +class ObjcAtTryStmt : public Stmt { +private: + enum { TRY, CATCH, FINALLY, END_TRY }; + Stmt* SubStmts[END_TRY]; + + SourceLocation AtTryLoc; + +public: + ObjcAtTryStmt(SourceLocation atTryLoc, Stmt *atTryStmt, + ObjcAtCatchStmt *atCatchStmt, + ObjcAtFinallyStmt *atFinallyStmt) + : Stmt(ObjcAtTryStmtClass), AtTryLoc(atTryLoc) { + SubStmts[TRY] = atTryStmt; + SubStmts[CATCH] = atCatchStmt; + SubStmts[FINALLY] = atFinallyStmt; + SubStmts[END_TRY] = NULL; + } + + virtual SourceRange getSourceRange() const { + return SourceRange(AtTryLoc, SubStmts[TRY]->getLocEnd()); + } + + static bool classof(const Stmt *T) { + return T->getStmtClass() == ObjcAtTryStmtClass; + } + static bool classof(const ObjcAtTryStmt *) { return true; } + + virtual child_iterator child_begin(); + virtual child_iterator child_end(); + +}; } // end namespace clang diff --git a/include/clang/AST/StmtNodes.def b/include/clang/AST/StmtNodes.def index 469f0a8c2c..b94e6c3db2 100644 --- a/include/clang/AST/StmtNodes.def +++ b/include/clang/AST/StmtNodes.def @@ -43,7 +43,13 @@ STMT(17, SwitchCase , Stmt) // GNU Stmt Extensions STMT(18, AsmStmt , Stmt) -LAST_STMT(17) + +// Obj-C statements +STMT(19, ObjcAtTryStmt , Stmt) +STMT(20, ObjcAtCatchStmt , Stmt) +STMT(21, ObjcAtFinallyStmt , Stmt) + +LAST_STMT(21) FIRST_EXPR(31) // Expressions. diff --git a/include/clang/Parse/Parser.h b/include/clang/Parse/Parser.h index 1345fe99dd..aeffdc69a4 100644 --- a/include/clang/Parse/Parser.h +++ b/include/clang/Parse/Parser.h @@ -275,7 +275,6 @@ private: DeclTy *ParseObjCAtAliasDeclaration(SourceLocation atLoc); DeclTy *ParseObjCPropertySynthesize(SourceLocation atLoc); DeclTy *ParseObjCPropertyDynamic(SourceLocation atLoc); - DeclTy *ParseObjCTryStmt(SourceLocation atLoc); DeclTy *ParseObjCThrowStmt(SourceLocation atLoc); IdentifierInfo *ParseObjCSelector(SourceLocation &MethodLocation); @@ -389,6 +388,7 @@ private: StmtResult ParseBreakStatement(); StmtResult ParseReturnStatement(); StmtResult ParseAsmStatement(); + StmtResult ParseObjCTryStmt(SourceLocation atLoc); void ParseAsmOperandsOpt(); //===--------------------------------------------------------------------===// |