Added iterators to nonloc::CompoundSVal.

Added pretty-printing for nonloc::CompoundSVal.

llvm-svn: 58442
This commit is contained in:
Ted Kremenek 2008-10-30 18:01:28 +00:00
parent 0e19c03382
commit cbdce2e53a
3 changed files with 30 additions and 1 deletions

View File

@ -33,6 +33,10 @@ public:
CompoundValData(QualType t, llvm::ImmutableList<SVal> l) CompoundValData(QualType t, llvm::ImmutableList<SVal> l)
: T(t), L(l) {} : T(t), L(l) {}
typedef llvm::ImmutableList<SVal>::iterator iterator;
iterator begin() const { return L.begin(); }
iterator end() const { return L.end(); }
static void Profile(llvm::FoldingSetNodeID& ID, QualType T, static void Profile(llvm::FoldingSetNodeID& ID, QualType T,
llvm::ImmutableList<SVal> L); llvm::ImmutableList<SVal> L);

View File

@ -324,9 +324,13 @@ class CompoundVal : public NonLoc {
CompoundVal(const CompoundValData* D) : NonLoc(CompoundValKind, D) {} CompoundVal(const CompoundValData* D) : NonLoc(CompoundValKind, D) {}
public: public:
const CompoundValData* getValue() { const CompoundValData* getValue() const {
return static_cast<CompoundValData*>(Data); return static_cast<CompoundValData*>(Data);
} }
typedef llvm::ImmutableList<SVal>::iterator iterator;
iterator begin() const;
iterator end() const;
static bool classof(const SVal* V) { static bool classof(const SVal* V) {
return V->getBaseKind() == NonLocKind && V->getSubKind() == CompoundValKind; return V->getBaseKind() == NonLocKind && V->getSubKind() == CompoundValKind;

View File

@ -54,6 +54,18 @@ SVal::symbol_iterator SVal::symbol_end() const {
return symbol_iterator(); return symbol_iterator();
} }
//===----------------------------------------------------------------------===//
// Other Iterators.
//===----------------------------------------------------------------------===//
nonloc::CompoundVal::iterator nonloc::CompoundVal::begin() const {
return getValue()->begin();
}
nonloc::CompoundVal::iterator nonloc::CompoundVal::end() const {
return getValue()->end();
}
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// Useful predicates. // Useful predicates.
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
@ -484,6 +496,15 @@ void NonLoc::print(llvm::raw_ostream& Out) const {
break; break;
} }
case nonloc::CompoundValKind: {
const nonloc::CompoundVal& C = *cast<nonloc::CompoundVal>(this);
Out << " { ";
for (nonloc::CompoundVal::iterator I=C.begin(), E=C.end(); I!=E; ++I)
(*I).print(Out);
Out << " }";
break;
}
default: default:
assert (false && "Pretty-printed not implemented for this NonLoc."); assert (false && "Pretty-printed not implemented for this NonLoc.");
break; break;