Added iterators to nonloc::CompoundSVal.
Added pretty-printing for nonloc::CompoundSVal.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58442 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/clang/Analysis/PathSensitive/BasicValueFactory.h b/include/clang/Analysis/PathSensitive/BasicValueFactory.h
index 82ed855..a8995b1 100644
--- a/include/clang/Analysis/PathSensitive/BasicValueFactory.h
+++ b/include/clang/Analysis/PathSensitive/BasicValueFactory.h
@@ -33,6 +33,10 @@
CompoundValData(QualType t, llvm::ImmutableList<SVal> 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,
llvm::ImmutableList<SVal> L);
diff --git a/include/clang/Analysis/PathSensitive/SVals.h b/include/clang/Analysis/PathSensitive/SVals.h
index 8cc993e..91fb71e 100644
--- a/include/clang/Analysis/PathSensitive/SVals.h
+++ b/include/clang/Analysis/PathSensitive/SVals.h
@@ -324,9 +324,13 @@
CompoundVal(const CompoundValData* D) : NonLoc(CompoundValKind, D) {}
public:
- const CompoundValData* getValue() {
+ const CompoundValData* getValue() const {
return static_cast<CompoundValData*>(Data);
}
+
+ typedef llvm::ImmutableList<SVal>::iterator iterator;
+ iterator begin() const;
+ iterator end() const;
static bool classof(const SVal* V) {
return V->getBaseKind() == NonLocKind && V->getSubKind() == CompoundValKind;
diff --git a/lib/Analysis/SVals.cpp b/lib/Analysis/SVals.cpp
index 1fb5875..bba0bde 100644
--- a/lib/Analysis/SVals.cpp
+++ b/lib/Analysis/SVals.cpp
@@ -55,6 +55,18 @@
}
//===----------------------------------------------------------------------===//
+// Other Iterators.
+//===----------------------------------------------------------------------===//
+
+nonloc::CompoundVal::iterator nonloc::CompoundVal::begin() const {
+ return getValue()->begin();
+}
+
+nonloc::CompoundVal::iterator nonloc::CompoundVal::end() const {
+ return getValue()->end();
+}
+
+//===----------------------------------------------------------------------===//
// Useful predicates.
//===----------------------------------------------------------------------===//
@@ -484,6 +496,15 @@
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:
assert (false && "Pretty-printed not implemented for this NonLoc.");
break;