diff options
Diffstat (limited to 'lib/AST')
-rw-r--r-- | lib/AST/Stmt.cpp | 20 | ||||
-rw-r--r-- | lib/AST/StmtPrinter.cpp | 11 | ||||
-rw-r--r-- | lib/AST/StmtSerialization.cpp | 17 |
3 files changed, 48 insertions, 0 deletions
diff --git a/lib/AST/Stmt.cpp b/lib/AST/Stmt.cpp index 2308159f5d..079ed4e0da 100644 --- a/lib/AST/Stmt.cpp +++ b/lib/AST/Stmt.cpp @@ -14,6 +14,7 @@ #include "clang/AST/Stmt.h" #include "clang/AST/ExprCXX.h" #include "clang/AST/ExprObjC.h" +#include "clang/AST/Type.h" using namespace clang; static struct StmtClassNameTable { @@ -333,3 +334,22 @@ Stmt::child_iterator ObjCAtSynchronizedStmt::child_end() { return &SubStmts[0]+END_EXPR; } +// CXXCatchStmt +Stmt::child_iterator CXXCatchStmt::child_begin() { + return &HandlerBlock; +} + +Stmt::child_iterator CXXCatchStmt::child_end() { + return &HandlerBlock + 1; +} + +QualType CXXCatchStmt::getCaughtType() { + if (ExceptionDecl) + return llvm::cast<VarDecl>(ExceptionDecl)->getType(); + return QualType(); +} + +void CXXCatchStmt::Destroy(ASTContext& C) { + ExceptionDecl->Destroy(C); + Stmt::Destroy(C); +} diff --git a/lib/AST/StmtPrinter.cpp b/lib/AST/StmtPrinter.cpp index 81e158e657..61cd89f70f 100644 --- a/lib/AST/StmtPrinter.cpp +++ b/lib/AST/StmtPrinter.cpp @@ -474,6 +474,17 @@ void StmtPrinter::VisitObjCAtSynchronizedStmt(ObjCAtSynchronizedStmt *Node) { OS << "\n"; } +void StmtPrinter::VisitCXXCatchStmt(CXXCatchStmt *Node) { + Indent() << "catch ("; + if (Decl *ExDecl = Node->getExceptionDecl()) + PrintRawDecl(ExDecl); + else + OS << "..."; + OS << ") "; + PrintRawCompoundStmt(cast<CompoundStmt>(Node->getHandlerBlock())); + OS << "\n"; +} + //===----------------------------------------------------------------------===// // Expr printing methods. //===----------------------------------------------------------------------===// diff --git a/lib/AST/StmtSerialization.cpp b/lib/AST/StmtSerialization.cpp index d12ecd0d93..2d6f755719 100644 --- a/lib/AST/StmtSerialization.cpp +++ b/lib/AST/StmtSerialization.cpp @@ -242,6 +242,9 @@ Stmt* Stmt::Create(Deserializer& D, ASTContext& C) { case CXXDependentNameExprClass: return CXXDependentNameExpr::CreateImpl(D, C); + + case CXXCatchStmtClass: + return CXXCatchStmt::CreateImpl(D, C); } } @@ -1523,3 +1526,17 @@ CXXDependentNameExpr::CreateImpl(llvm::Deserializer& D, ASTContext& C) { SourceLocation L = SourceLocation::ReadVal(D); return new CXXDependentNameExpr(N, Ty, L); } + +void CXXCatchStmt::EmitImpl(llvm::Serializer& S) const { + S.Emit(CatchLoc); + S.EmitOwnedPtr(ExceptionDecl); + S.EmitOwnedPtr(HandlerBlock); +} + +CXXCatchStmt * +CXXCatchStmt::CreateImpl(llvm::Deserializer& D, ASTContext& C) { + SourceLocation CatchLoc = SourceLocation::ReadVal(D); + Decl *ExDecl = D.ReadOwnedPtr<Decl>(C); + Stmt *HandlerBlock = D.ReadOwnedPtr<Stmt>(C); + return new CXXCatchStmt(CatchLoc, ExDecl, HandlerBlock); +} |