return &SubStmts[0]+END_TRY;
}
+// ObjcAtThrowStmt
+Stmt::child_iterator ObjcAtThrowStmt::child_begin() {
+ return &Throw;
+}
+
+Stmt::child_iterator ObjcAtThrowStmt::child_end() {
+ return &Throw+1;
+}
Indent() << "@catch (...) { /* todo */ } \n";
}
+void StmtPrinter::VisitObjcAtThrowStmt (ObjcAtThrowStmt *Node) {
+ Indent() << "@throw";
+ if (Node->getThrowExpr()) {
+ OS << " ";
+ PrintExpr(Node->getThrowExpr());
+ }
+ OS << ";\n";
+}
+
//===----------------------------------------------------------------------===//
// Expr printing methods.
//===----------------------------------------------------------------------===//
/// objc-throw-statement:
/// throw expression[opt];
///
-Parser::DeclTy *Parser::ParseObjCThrowStmt(SourceLocation atLoc) {
+Parser::StmtResult Parser::ParseObjCThrowStmt(SourceLocation atLoc) {
+ ExprResult Res;
ConsumeToken(); // consume throw
if (Tok.isNot(tok::semi)) {
- ExprResult Res = ParseExpression();
+ Res = ParseExpression();
if (Res.isInvalid) {
SkipUntil(tok::semi);
- return 0;
+ return true;
}
}
- return 0;
+ ConsumeToken(); // consume ';'
+ return Actions.ActOnObjcAtThrowStmt(atLoc, Res.Val);
}
/// objc-try-catch-statement:
StmtTy *Try,
StmtTy *Catch, StmtTy *Finally);
+ virtual StmtResult ActOnObjcAtThrowStmt(SourceLocation AtLoc,
+ StmtTy *Throw);
+
//===--------------------------------------------------------------------===//
// Expression Parsing Callbacks: SemaExpr.cpp.
return TS;
}
+Action::StmtResult
+Sema::ActOnObjcAtThrowStmt(SourceLocation AtLoc, StmtTy *Throw) {
+ ObjcAtThrowStmt *TS = new ObjcAtThrowStmt(AtLoc, static_cast<Stmt*>(Throw));
+ return TS;
+}
};
+/// ObjcAtThrowStmt - This represents objective-c's @throw statement.
+class ObjcAtThrowStmt : public Stmt {
+private:
+ Stmt *Throw;
+ SourceLocation AtThrowLoc;
+
+public:
+ ObjcAtThrowStmt(SourceLocation atThrowLoc, Stmt *throwExpr)
+ : Stmt(ObjcAtThrowStmtClass), Throw(throwExpr) {
+ AtThrowLoc = atThrowLoc;
+ }
+
+ Expr *const getThrowExpr() const { return reinterpret_cast<Expr*>(Throw); }
+
+ virtual SourceRange getSourceRange() const {
+ return SourceRange(AtThrowLoc, Throw->getLocEnd());
+ }
+
+ static bool classof(const Stmt *T) {
+ return T->getStmtClass() == ObjcAtThrowStmtClass;
+ }
+ static bool classof(const ObjcAtThrowStmt *) { return true; }
+
+ virtual child_iterator child_begin();
+ virtual child_iterator child_end();
+};
+
} // end namespace clang
#endif
STMT(19, ObjcAtTryStmt , Stmt)
STMT(20, ObjcAtCatchStmt , Stmt)
STMT(21, ObjcAtFinallyStmt , Stmt)
+STMT(22, ObjcAtThrowStmt , Stmt)
-LAST_STMT(21)
+LAST_STMT(22)
FIRST_EXPR(31)
// Expressions.
StmtTy *Catch, StmtTy *Finally) {
return 0;
}
+
+ virtual StmtResult ActOnObjcAtThrowStmt(SourceLocation AtLoc,
+ StmtTy *Throw) {
+ return 0;
+ }
+
//===--------------------------------------------------------------------===//
// Expression Parsing Callbacks.
//===--------------------------------------------------------------------===//
DeclTy *ParseObjCAtAliasDeclaration(SourceLocation atLoc);
DeclTy *ParseObjCPropertySynthesize(SourceLocation atLoc);
DeclTy *ParseObjCPropertyDynamic(SourceLocation atLoc);
- DeclTy *ParseObjCThrowStmt(SourceLocation atLoc);
IdentifierInfo *ParseObjCSelector(SourceLocation &MethodLocation);
// Definitions for Objective-c context sensitive keywords recognition.
StmtResult ParseReturnStatement();
StmtResult ParseAsmStatement();
StmtResult ParseObjCTryStmt(SourceLocation atLoc);
+ StmtResult ParseObjCThrowStmt(SourceLocation atLoc);
void ParseAsmOperandsOpt();
//===--------------------------------------------------------------------===//