[cfe-commits] r43455 - in /cfe/trunk: AST/StmtIterator.cpp include/clang/AST/StmtIterator.h
Ted Kremenek
kremenek at apple.com
Mon Oct 29 11:04:41 PDT 2007
Author: kremenek
Date: Mon Oct 29 13:04:38 2007
New Revision: 43455
URL: http://llvm.org/viewvc/llvm-project?rev=43455&view=rev
Log:
Renamed internal variables of StmtIteratorBase to make the code
slightly more succinct.
Introduced VariableArrayType* within StmtIteratorBase to (soon)
support iteration over the size expressions of variable length arrays.
Modified:
cfe/trunk/AST/StmtIterator.cpp
cfe/trunk/include/clang/AST/StmtIterator.h
Modified: cfe/trunk/AST/StmtIterator.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/AST/StmtIterator.cpp?rev=43455&r1=43454&r2=43455&view=diff
==============================================================================
--- cfe/trunk/AST/StmtIterator.cpp (original)
+++ cfe/trunk/AST/StmtIterator.cpp Mon Oct 29 13:04:38 2007
@@ -30,12 +30,12 @@
}
void StmtIteratorBase::NextDecl() {
- assert (FirstDecl && Ptr.D);
+ assert (FirstDecl && decl);
- do Ptr.D = Ptr.D->getNextDeclarator();
- while (Ptr.D != NULL && !declHasExpr(Ptr.D));
+ do decl = decl->getNextDeclarator();
+ while (decl != NULL && !declHasExpr(decl));
- if (Ptr.D == NULL) FirstDecl = NULL;
+ if (decl == NULL) FirstDecl = NULL;
}
StmtIteratorBase::StmtIteratorBase(ScopedDecl* d) {
@@ -45,12 +45,12 @@
d = d->getNextDeclarator();
FirstDecl = d;
- Ptr.D = d;
+ decl = d;
}
void StmtIteratorBase::PrevDecl() {
assert (FirstDecl);
- assert (Ptr.D != FirstDecl);
+ assert (decl != FirstDecl);
// March through the list of decls until we find the decl just before
// the one we currently point
@@ -58,7 +58,7 @@
ScopedDecl* d = FirstDecl;
ScopedDecl* lastVD = d;
- while (d->getNextDeclarator() != Ptr.D) {
+ while (d->getNextDeclarator() != decl) {
if (VarDecl* V = dyn_cast<VarDecl>(d))
if (V->getInit())
lastVD = d;
@@ -66,14 +66,14 @@
d = d->getNextDeclarator();
}
- Ptr.D = lastVD;
+ decl = lastVD;
}
Stmt*& StmtIteratorBase::GetDeclExpr() const {
- if (VarDecl* D = dyn_cast<VarDecl>(Ptr.D))
+ if (VarDecl* D = dyn_cast<VarDecl>(decl))
return reinterpret_cast<Stmt*&>(D->Init);
else {
- EnumConstantDecl* Decl = cast<EnumConstantDecl>(Ptr.D);
+ EnumConstantDecl* Decl = cast<EnumConstantDecl>(decl);
return reinterpret_cast<Stmt*&>(Decl->Init);
}
}
Modified: cfe/trunk/include/clang/AST/StmtIterator.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/StmtIterator.h?rev=43455&r1=43454&r2=43455&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/StmtIterator.h (original)
+++ cfe/trunk/include/clang/AST/StmtIterator.h Mon Oct 29 13:04:38 2007
@@ -20,19 +20,21 @@
class Stmt;
class ScopedDecl;
-
+class VariableArrayType;
+
class StmtIteratorBase {
protected:
- union { Stmt** S; ScopedDecl* D; } Ptr;
+ union { Stmt** stmt; ScopedDecl* decl; };
ScopedDecl* FirstDecl;
+ VariableArrayType* vat;
void NextDecl();
void PrevDecl();
Stmt*& GetDeclExpr() const;
- StmtIteratorBase(Stmt** s) : FirstDecl(NULL) { Ptr.S = s; }
+ StmtIteratorBase(Stmt** s) : stmt(s), FirstDecl(NULL), vat(NULL) {}
StmtIteratorBase(ScopedDecl* d);
- StmtIteratorBase() : FirstDecl(NULL) { Ptr.S = NULL; }
+ StmtIteratorBase() : stmt(NULL), FirstDecl(NULL), vat(NULL) {}
};
@@ -51,7 +53,7 @@
DERIVED& operator++() {
if (FirstDecl) NextDecl();
- else ++Ptr.S;
+ else ++stmt;
return static_cast<DERIVED&>(*this);
}
@@ -64,7 +66,7 @@
DERIVED& operator--() {
if (FirstDecl) PrevDecl();
- else --Ptr.S;
+ else --stmt;
return static_cast<DERIVED&>(*this);
}
@@ -76,15 +78,15 @@
}
bool operator==(const DERIVED& RHS) const {
- return FirstDecl == RHS.FirstDecl && Ptr.S == RHS.Ptr.S;
+ return FirstDecl == RHS.FirstDecl && stmt == RHS.stmt;
}
bool operator!=(const DERIVED& RHS) const {
- return FirstDecl != RHS.FirstDecl || Ptr.S != RHS.Ptr.S;
+ return FirstDecl != RHS.FirstDecl || stmt != RHS.stmt;
}
REFERENCE operator*() const {
- return (REFERENCE) (FirstDecl ? GetDeclExpr() : *Ptr.S);
+ return (REFERENCE) (FirstDecl ? GetDeclExpr() : *stmt);
}
REFERENCE operator->() const { return operator*(); }
More information about the cfe-commits
mailing list