diff options
author | Sam Weinig <sam.weinig@gmail.com> | 2010-02-03 02:09:59 +0000 |
---|---|---|
committer | Sam Weinig <sam.weinig@gmail.com> | 2010-02-03 02:09:59 +0000 |
commit | ebcea988c2a20b4edfad7d721f78f31f07a840d6 (patch) | |
tree | 4e2945387c45a60de1ffb0fafe68257d16a68ad5 /clang | |
parent | 92b762e256d62ae85daedcf0af04fbd2dcbecdeb (diff) | |
download | bcm5719-llvm-ebcea988c2a20b4edfad7d721f78f31f07a840d6.tar.gz bcm5719-llvm-ebcea988c2a20b4edfad7d721f78f31f07a840d6.zip |
Remove the SmallVector from CXXTryStmt.
llvm-svn: 95190
Diffstat (limited to 'clang')
-rw-r--r-- | clang/include/clang/AST/StmtCXX.h | 14 | ||||
-rw-r--r-- | clang/lib/AST/Stmt.cpp | 37 | ||||
-rw-r--r-- | clang/lib/Sema/SemaStmt.cpp | 2 |
3 files changed, 33 insertions, 20 deletions
diff --git a/clang/include/clang/AST/StmtCXX.h b/clang/include/clang/AST/StmtCXX.h index 09ea4ca2101..6026707b169 100644 --- a/clang/include/clang/AST/StmtCXX.h +++ b/clang/include/clang/AST/StmtCXX.h @@ -59,12 +59,16 @@ public: /// class CXXTryStmt : public Stmt { SourceLocation TryLoc; + // First place is the guarded CompoundStatement. Subsequent are the handlers. - // More than three handlers should be rare. - llvm::SmallVector<Stmt*, 4> Stmts; + Stmt **Stmts; + unsigned NumHandlers; + +protected: + virtual void DoDestroy(ASTContext &Ctx); public: - CXXTryStmt(SourceLocation tryLoc, Stmt *tryBlock, + CXXTryStmt(ASTContext &C, SourceLocation tryLoc, Stmt *tryBlock, Stmt **handlers, unsigned numHandlers); virtual SourceRange getSourceRange() const { @@ -72,14 +76,14 @@ public: } SourceLocation getTryLoc() const { return TryLoc; } - SourceLocation getEndLoc() const { return Stmts.back()->getLocEnd(); } + SourceLocation getEndLoc() const { return Stmts[NumHandlers]->getLocEnd(); } CompoundStmt *getTryBlock() { return llvm::cast<CompoundStmt>(Stmts[0]); } const CompoundStmt *getTryBlock() const { return llvm::cast<CompoundStmt>(Stmts[0]); } - unsigned getNumHandlers() const { return Stmts.size() - 1; } + unsigned getNumHandlers() const { return NumHandlers; } CXXCatchStmt *getHandler(unsigned i) { return llvm::cast<CXXCatchStmt>(Stmts[i + 1]); } diff --git a/clang/lib/AST/Stmt.cpp b/clang/lib/AST/Stmt.cpp index a0830997dcd..e90eceec1b3 100644 --- a/clang/lib/AST/Stmt.cpp +++ b/clang/lib/AST/Stmt.cpp @@ -339,6 +339,12 @@ unsigned AsmStmt::AnalyzeAsmString(llvm::SmallVectorImpl<AsmStringPiece>&Pieces, } } +QualType CXXCatchStmt::getCaughtType() const { + if (ExceptionDecl) + return ExceptionDecl->getType(); + return QualType(); +} + //===----------------------------------------------------------------------===// // Constructors //===----------------------------------------------------------------------===// @@ -401,6 +407,14 @@ ObjCAtCatchStmt::ObjCAtCatchStmt(SourceLocation atCatchLoc, RParenLoc = rparenloc; } +CXXTryStmt::CXXTryStmt(ASTContext &C, SourceLocation tryLoc, Stmt *tryBlock, + Stmt **handlers, unsigned numHandlers) + : Stmt(CXXTryStmtClass), TryLoc(tryLoc), NumHandlers(numHandlers) { + Stmts = new (C) Stmt*[NumHandlers + 1]; + Stmts[0] = tryBlock; + std::copy(handlers, handlers + NumHandlers, Stmts + 1); +} + //===----------------------------------------------------------------------===// // AST Destruction. //===----------------------------------------------------------------------===// @@ -479,6 +493,14 @@ void AsmStmt::DoDestroy(ASTContext &C) { C.Deallocate((void *)this); } +void CXXTryStmt::DoDestroy(ASTContext& C) { + DestroyChildren(C); + C.Deallocate(Stmts); + + this->~CXXTryStmt(); + C.Deallocate((void *)this); +} + //===----------------------------------------------------------------------===// // Child Iterators for iterating over subexpressions/substatements //===----------------------------------------------------------------------===// @@ -641,19 +663,6 @@ Stmt::child_iterator CXXCatchStmt::child_end() { return &HandlerBlock + 1; } -QualType CXXCatchStmt::getCaughtType() const { - if (ExceptionDecl) - return ExceptionDecl->getType(); - return QualType(); -} - // CXXTryStmt Stmt::child_iterator CXXTryStmt::child_begin() { return &Stmts[0]; } -Stmt::child_iterator CXXTryStmt::child_end() { return &Stmts[0]+Stmts.size(); } - -CXXTryStmt::CXXTryStmt(SourceLocation tryLoc, Stmt *tryBlock, - Stmt **handlers, unsigned numHandlers) - : Stmt(CXXTryStmtClass), TryLoc(tryLoc) { - Stmts.push_back(tryBlock); - Stmts.insert(Stmts.end(), handlers, handlers + numHandlers); -} +Stmt::child_iterator CXXTryStmt::child_end() { return &Stmts[0]+NumHandlers+1; } diff --git a/clang/lib/Sema/SemaStmt.cpp b/clang/lib/Sema/SemaStmt.cpp index 54a892ac560..0fecb8ba868 100644 --- a/clang/lib/Sema/SemaStmt.cpp +++ b/clang/lib/Sema/SemaStmt.cpp @@ -1551,7 +1551,7 @@ Sema::ActOnCXXTryBlock(SourceLocation TryLoc, StmtArg TryBlock, CurFunctionNeedsScopeChecking = true; RawHandlers.release(); - return Owned(new (Context) CXXTryStmt(TryLoc, + return Owned(new (Context) CXXTryStmt(Context, TryLoc, static_cast<Stmt*>(TryBlock.release()), Handlers, NumHandlers)); } |