From e66a8cf9117e5fb95a05ff76ec06615e63dd5ade Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Sat, 28 Mar 2009 06:53:40 +0000 Subject: [PATCH] some random cleanups git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67928 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/AST/DeclGroup.h | 1 - include/clang/AST/Stmt.h | 4 +++- lib/AST/CFG.cpp | 10 +++------- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/include/clang/AST/DeclGroup.h b/include/clang/AST/DeclGroup.h index 9b5aa1c58d..c9d0d655cb 100644 --- a/include/clang/AST/DeclGroup.h +++ b/include/clang/AST/DeclGroup.h @@ -57,7 +57,6 @@ public: }; class DeclGroupRef { -protected: enum Kind { SingleDeclKind=0x0, DeclGroupKind=0x1, Mask=0x1 }; Decl* D; diff --git a/include/clang/AST/Stmt.h b/include/clang/AST/Stmt.h index 28822129e1..25217215f5 100644 --- a/include/clang/AST/Stmt.h +++ b/include/clang/AST/Stmt.h @@ -225,7 +225,6 @@ public: /// the first statement can be an expression or a declaration. /// class DeclStmt : public Stmt { -protected: DeclGroupRef DG; SourceLocation StartLoc, EndLoc; public: @@ -243,6 +242,9 @@ public: const Decl *getSingleDecl() const { return DG.getSingleDecl(); } Decl *getSingleDecl() { return DG.getSingleDecl(); } + + const DeclGroupRef getDeclGroup() const { return DG; } + DeclGroupRef getDeclGroup() { return DG; } SourceLocation getStartLoc() const { return StartLoc; } SourceLocation getEndLoc() const { return EndLoc; } diff --git a/lib/AST/CFG.cpp b/lib/AST/CFG.cpp index 297758316a..804c2d2bd5 100644 --- a/lib/AST/CFG.cpp +++ b/lib/AST/CFG.cpp @@ -363,15 +363,12 @@ CFGBlock* CFGBuilder::WalkAST(Stmt* Terminator, bool AlwaysAddStmt = false) { return WalkAST_VisitDeclSubExpr(DS->getSingleDecl()); } - typedef llvm::SmallVector BufTy; - BufTy Buf; CFGBlock* B = 0; // FIXME: Add a reverse iterator for DeclStmt to avoid this // extra copy. - for (DeclStmt::decl_iterator DI=DS->decl_begin(), DE=DS->decl_end(); - DI != DE; ++DI) - Buf.push_back(*DI); + typedef llvm::SmallVector BufTy; + BufTy Buf(DS->decl_begin(), DS->decl_end()); for (BufTy::reverse_iterator I=Buf.rbegin(), E=Buf.rend(); I!=E; ++I) { // Get the alignment of the new DeclStmt, padding out to >=8 bytes. @@ -384,8 +381,7 @@ CFGBlock* CFGBuilder::WalkAST(Stmt* Terminator, bool AlwaysAddStmt = false) { Decl* D = *I; void* Mem = cfg->getAllocator().Allocate(sizeof(DeclStmt), A); - DeclStmt* DS = new (Mem) DeclStmt(DG, D->getLocation(), - GetEndLoc(D)); + DeclStmt* DS = new (Mem) DeclStmt(DG, D->getLocation(), GetEndLoc(D)); // Append the fake DeclStmt to block. Block->appendStmt(DS); -- 2.40.0