diff options
author | Ted Kremenek <kremenek@apple.com> | 2008-10-06 20:56:19 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2008-10-06 20:56:19 +0000 |
commit | 53061c842d287b73500c47141f0059792631ed89 (patch) | |
tree | 7c5de93e4365b3c47ea38766c3dca9b39171caf3 /lib/AST/CFG.cpp | |
parent | 34a673850c80dfff9c701e449bc19c967b50663c (diff) |
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
Diffstat (limited to 'lib/AST/CFG.cpp')
-rw-r--r-- | lib/AST/CFG.cpp | 20 |
1 files 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<DeclStmt>(Terminator)->getDecl(); - - if (!D->getNextDeclarator()) { + DeclStmt *DS = cast<DeclStmt>(Terminator); + if (DS->hasSolitaryDecl()) { Block->appendStmt(Terminator); - return WalkAST_VisitDeclSubExpr(D); + return WalkAST_VisitDeclSubExpr(DS->getSolitaryDecl()); } else { typedef llvm::SmallVector<ScopedDecl*,10> 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<UnaryDeclStmt>::Alignment < 8 |