summaryrefslogtreecommitdiff
path: root/lib/sanitizer_common/sanitizer_list.h
diff options
context:
space:
mode:
authorAlexander Potapenko <glider@google.com>2014-03-20 13:49:21 +0000
committerAlexander Potapenko <glider@google.com>2014-03-20 13:49:21 +0000
commit320df21abd9e4bbad44dc329d9980c2fb83c4014 (patch)
tree3cc5f1aecc59816aff9c5b7aa223cba1072145df /lib/sanitizer_common/sanitizer_list.h
parent67f263e168c535b5667e26d1391f27bf04e51d42 (diff)
downloadcompiler-rt-320df21abd9e4bbad44dc329d9980c2fb83c4014.tar.gz
[libsanitizer] Implement IntrusiveList<T>::Iterator, use IntrusiveList in sanitizer_flags.cc
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@204342 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/sanitizer_common/sanitizer_list.h')
-rw-r--r--lib/sanitizer_common/sanitizer_list.h17
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/sanitizer_common/sanitizer_list.h b/lib/sanitizer_common/sanitizer_list.h
index f61d28f3d..a47bc7d45 100644
--- a/lib/sanitizer_common/sanitizer_list.h
+++ b/lib/sanitizer_common/sanitizer_list.h
@@ -26,6 +26,8 @@ namespace __sanitizer {
// non-zero-initialized objects before using.
template<class Item>
struct IntrusiveList {
+ friend class Iterator;
+
void clear() {
first_ = last_ = 0;
size_ = 0;
@@ -113,6 +115,21 @@ struct IntrusiveList {
}
}
+ class Iterator {
+ public:
+ explicit Iterator(IntrusiveList<Item> *list)
+ : list_(list), current_(list->first_) { }
+ Item *next() {
+ Item *ret = current_;
+ if (current_) current_ = current_->next;
+ return ret;
+ }
+ bool hasNext() const { return current_ != 0; }
+ private:
+ IntrusiveList<Item> *list_;
+ Item *current_;
+ };
+
// private, don't use directly.
uptr size_;
Item *first_;