Make BlockDataRegion::referenced_vars_iterator an actual class that enforces that all MemRegions iterated over are VarRegions.

llvm-svn: 90430
This commit is contained in:
Ted Kremenek 2009-12-03 08:09:21 +00:00
parent f05330a5c8
commit 4a815fc82e
2 changed files with 29 additions and 3 deletions

View File

@ -340,7 +340,31 @@ public:
const BlockTextRegion *getCodeRegion() const { return BC; }
typedef const MemRegion * const * referenced_vars_iterator;
class referenced_vars_iterator {
const MemRegion * const *R;
public:
explicit referenced_vars_iterator(const MemRegion * const *r) : R(r) {}
operator const MemRegion * const *() const {
return R;
}
const VarRegion* operator*() const {
return cast<VarRegion>(*R);
}
bool operator==(const referenced_vars_iterator &I) const {
return I.R == R;
}
bool operator!=(const referenced_vars_iterator &I) const {
return I.R != R;
}
referenced_vars_iterator& operator++() {
++R;
return *this;
}
};
referenced_vars_iterator referenced_vars_begin() const;
referenced_vars_iterator referenced_vars_end() const;

View File

@ -573,7 +573,8 @@ BlockDataRegion::referenced_vars_begin() const {
BumpVector<const MemRegion*> *Vec =
static_cast<BumpVector<const MemRegion*>*>(ReferencedVars);
return Vec == (void*) 0x1 ? NULL : Vec->begin();
return BlockDataRegion::referenced_vars_iterator(Vec == (void*) 0x1 ?
NULL : Vec->begin());
}
BlockDataRegion::referenced_vars_iterator
@ -583,5 +584,6 @@ BlockDataRegion::referenced_vars_end() const {
BumpVector<const MemRegion*> *Vec =
static_cast<BumpVector<const MemRegion*>*>(ReferencedVars);
return Vec == (void*) 0x1 ? NULL : Vec->end();
return BlockDataRegion::referenced_vars_iterator(Vec == (void*) 0x1 ?
NULL : Vec->end());
}