diff options
Diffstat (limited to 'clang/include')
-rw-r--r-- | clang/include/clang/AST/ExprCXX.h | 32 | ||||
-rw-r--r-- | clang/include/clang/AST/StmtNodes.def | 1 | ||||
-rw-r--r-- | clang/include/clang/Parse/Action.h | 6 | ||||
-rw-r--r-- | clang/include/clang/Parse/Parser.h | 4 |
4 files changed, 43 insertions, 0 deletions
diff --git a/clang/include/clang/AST/ExprCXX.h b/clang/include/clang/AST/ExprCXX.h index 0fa38374c05..357fb9538f2 100644 --- a/clang/include/clang/AST/ExprCXX.h +++ b/clang/include/clang/AST/ExprCXX.h @@ -95,6 +95,38 @@ namespace clang { virtual child_iterator child_end(); }; + /// CXXThrowExpr - [C++ 15] C++ Throw Expression. This handles + /// 'throw' and 'throw' assignment-expression. When + /// assignment-expression isn't present, Op will be null. + /// + class CXXThrowExpr : public Expr { + Expr *Op; + SourceLocation ThrowLoc; + public: + // Ty is the void type which is used as the result type of the + // exepression. The l is the location of the throw keyword. expr + // can by null, if the optional expression to throw isn't present. + CXXThrowExpr(Expr *expr, QualType Ty, SourceLocation l) : + Expr(CXXThrowExprClass, Ty), Op(expr), ThrowLoc(l) {} + const Expr *getSubExpr() const { return Op; } + Expr *getSubExpr() { return Op; } + + virtual SourceRange getSourceRange() const { + if (getSubExpr() == 0) + return SourceRange(ThrowLoc, ThrowLoc); + return SourceRange(ThrowLoc, getSubExpr()->getSourceRange().getEnd()); + } + + static bool classof(const Stmt *T) { + return T->getStmtClass() == CXXThrowExprClass; + } + static bool classof(const CXXThrowExpr *) { return true; } + + // Iterators + virtual child_iterator child_begin(); + virtual child_iterator child_end(); + }; + } // end namespace clang #endif diff --git a/clang/include/clang/AST/StmtNodes.def b/clang/include/clang/AST/StmtNodes.def index a8083e6adbe..4c0fd7a242d 100644 --- a/clang/include/clang/AST/StmtNodes.def +++ b/clang/include/clang/AST/StmtNodes.def @@ -90,6 +90,7 @@ STMT(58, ChooseExpr , Expr) // C++ Expressions. STMT(60, CXXCastExpr , Expr) STMT(61, CXXBoolLiteralExpr , Expr) +STMT(62, CXXThrowExpr , Expr) // Obj-C Expressions. STMT(70, ObjCStringLiteral , Expr) diff --git a/clang/include/clang/Parse/Action.h b/clang/include/clang/Parse/Action.h index 281b9b7be8e..63d9a72c909 100644 --- a/clang/include/clang/Parse/Action.h +++ b/clang/include/clang/Parse/Action.h @@ -519,6 +519,12 @@ public: tok::TokenKind Kind) { return 0; } + + /// ActOnCXXThrow - Parse throw expressions. + virtual ExprResult ActOnCXXThrow(SourceLocation OpLoc, + ExprTy *Op = 0) { + return 0; + } //===----------------------- Obj-C Declarations -------------------------===// // ActOnStartClassInterface - this action is called immdiately after parsing diff --git a/clang/include/clang/Parse/Parser.h b/clang/include/clang/Parse/Parser.h index 68c7457a51a..860e5d700fb 100644 --- a/clang/include/clang/Parse/Parser.h +++ b/clang/include/clang/Parse/Parser.h @@ -354,6 +354,10 @@ private: ExprResult ParseCXXCasts(); //===--------------------------------------------------------------------===// + // C++ 15: C++ Throw Expression + ExprResult ParseThrowExpression(); + + //===--------------------------------------------------------------------===// // C++ 2.13.5: C++ Boolean Literals ExprResult ParseCXXBoolLiteral(); |