void print(llvm::raw_ostream& OS) const;
void printStdErr() const;
- typedef const SymbolID* symbol_iterator;
+ class symbol_iterator {
+ const enum { One, Many } HowMany;
+ union { uintptr_t sym; const SymbolID* sptr; };
+ public:
+
+ bool operator==(const symbol_iterator& X) {
+ return X.sym == sym;
+ }
+
+ bool operator!=(const symbol_iterator& X) {
+ return X.sym != sym;
+ }
+
+ symbol_iterator& operator++() {
+ if (HowMany == Many)
+ ++sptr;
+ else
+ sym = ~0x0;
+
+ return *this;
+ }
+
+ SymbolID operator*() const {
+ if (HowMany)
+ return *sptr;
+
+ return SymbolID(sym);
+ }
+
+ symbol_iterator(SymbolID x) : HowMany(One), sym(x.getNumber()) {}
+ symbol_iterator() : HowMany(One), sym(~0x0) {}
+ symbol_iterator(const SymbolID* x) : HowMany(Many), sptr(x) {}
+ };
+
symbol_iterator symbol_begin() const;
- symbol_iterator symbol_end() const;
+ symbol_iterator symbol_end() const;
// Implement isa<T> support.
static inline bool classof(const SVal*) { return true; }
//===----------------------------------------------------------------------===//
SVal::symbol_iterator SVal::symbol_begin() const {
-
// FIXME: This is a rat's nest. Cleanup.
if (isa<loc::SymbolVal>(this))
- return (symbol_iterator) (&Data);
+ return symbol_iterator(SymbolID((uintptr_t)Data));
else if (isa<nonloc::SymbolVal>(this))
- return (symbol_iterator) (&Data);
+ return symbol_iterator(SymbolID((uintptr_t)Data));
else if (isa<nonloc::SymIntConstraintVal>(this)) {
const SymIntConstraint& C =
- cast<nonloc::SymIntConstraintVal>(this)->getConstraint();
-
- return (symbol_iterator) &C.getSymbol();
+ cast<nonloc::SymIntConstraintVal>(this)->getConstraint();
+ return symbol_iterator(C.getSymbol());
}
else if (isa<nonloc::LocAsInteger>(this)) {
const nonloc::LocAsInteger& V = cast<nonloc::LocAsInteger>(*this);
return V.getPersistentLoc().symbol_begin();
}
+ else if (isa<loc::MemRegionVal>(this)) {
+ const MemRegion* R = cast<loc::MemRegionVal>(this)->getRegion();
+ if (const SymbolicRegion* S = dyn_cast<SymbolicRegion>(R))
+ return symbol_iterator(S->getSymbol());
+ }
- // FIXME: We need to iterate over the symbols of regions.
-
- return NULL;
+ return symbol_iterator();
}
SVal::symbol_iterator SVal::symbol_end() const {
- symbol_iterator X = symbol_begin();
- return X ? X+1 : NULL;
+ return symbol_iterator();
}
//===----------------------------------------------------------------------===//