2007-10-18 00:24:38 +00:00
|
|
|
//===--- StmtIterator.cpp - Iterators for Statements ------------------------===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file was developed by Ted Kremenek and is distributed under
|
|
|
|
// the University of Illinois Open Source License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file defines internal methods for StmtIterator.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "clang/AST/StmtIterator.h"
|
|
|
|
#include "clang/AST/Stmt.h"
|
|
|
|
#include "clang/AST/Decl.h"
|
|
|
|
|
|
|
|
using namespace clang;
|
|
|
|
|
2007-10-18 16:25:40 +00:00
|
|
|
void StmtIterator::NextDecl() {
|
|
|
|
assert (D);
|
|
|
|
do D = D->getNextDeclarator();
|
|
|
|
while (D != NULL && !isa<VarDecl>(D));
|
|
|
|
|
|
|
|
if (!D) S = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void StmtIterator::PrevDecl() {
|
|
|
|
assert (isa<DeclStmt>(*S));
|
|
|
|
DeclStmt* DS = cast<DeclStmt>(*S);
|
|
|
|
|
|
|
|
ScopedDecl* d = DS->getDecl();
|
|
|
|
assert (d);
|
|
|
|
|
|
|
|
if (d == D) { assert(false) ; return; }
|
|
|
|
|
|
|
|
// March through the list of decls until we find the decl just before
|
|
|
|
// the one we currently point
|
|
|
|
|
|
|
|
while (d->getNextDeclarator() != D)
|
|
|
|
d = d->getNextDeclarator();
|
|
|
|
|
|
|
|
D = d;
|
|
|
|
}
|
2007-10-18 00:24:38 +00:00
|
|
|
|
|
|
|
Stmt*& StmtIterator::GetInitializer() const {
|
|
|
|
assert (D && isa<VarDecl>(D));
|
|
|
|
assert (cast<VarDecl>(D)->Init);
|
|
|
|
return reinterpret_cast<Stmt*&>(cast<VarDecl>(D)->Init);
|
|
|
|
}
|