From 53061c842d287b73500c47141f0059792631ed89 Mon Sep 17 00:00:00 2001 From: Ted Kremenek Date: Mon, 6 Oct 2008 20:56:19 +0000 Subject: [PATCH] Use DeclStmt::decl_iterator to walk a group of Decl*'s instead of using the ScopedDecl chain. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57206 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/AST/CFG.cpp | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/lib/AST/CFG.cpp b/lib/AST/CFG.cpp index 8e9c3fb10b..2eea6492cd 100644 --- a/lib/AST/CFG.cpp +++ b/lib/AST/CFG.cpp @@ -69,11 +69,10 @@ public: return Ex ? &Ex + 1 : 0; } virtual decl_iterator decl_begin() { - return getDecl(); + return TheDecl; } virtual decl_iterator decl_end() { - ScopedDecl* D = getDecl(); - return D ? D->getNextDeclarator() : 0; + return TheDecl ? TheDecl->getNextDeclarator() : 0; } }; @@ -379,17 +378,22 @@ CFGBlock* CFGBuilder::WalkAST(Stmt* Terminator, bool AlwaysAddStmt = false) { } case Stmt::DeclStmtClass: { - ScopedDecl* D = cast(Terminator)->getDecl(); - - if (!D->getNextDeclarator()) { + DeclStmt *DS = cast(Terminator); + if (DS->hasSolitaryDecl()) { Block->appendStmt(Terminator); - return WalkAST_VisitDeclSubExpr(D); + return WalkAST_VisitDeclSubExpr(DS->getSolitaryDecl()); } else { typedef llvm::SmallVector BufTy; BufTy Buf; CFGBlock* B = 0; - do { Buf.push_back(D); D = D->getNextDeclarator(); } while (D); + + // 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); + for (BufTy::reverse_iterator I=Buf.rbegin(), E=Buf.rend(); I!=E; ++I) { // Get the alignment of UnaryDeclStmt, padding out to >=8 bytes. unsigned A = llvm::AlignOf::Alignment < 8 -- 2.40.0