summaryrefslogtreecommitdiff
path: root/include/llvm/Support/YAMLParser.h
diff options
context:
space:
mode:
authorBenjamin Kramer <benny.kra@googlemail.com>2012-05-01 10:19:59 +0000
committerBenjamin Kramer <benny.kra@googlemail.com>2012-05-01 10:19:59 +0000
commit34df1600e003bf83678b308f7aa63522dfbd4f4a (patch)
tree7a13103e9ce31dc2ae06c4f7fa0f32133ee7e051 /include/llvm/Support/YAMLParser.h
parent7c4ce30ea6a9d0410f306e805403dd224c3df65c (diff)
downloadllvm-34df1600e003bf83678b308f7aa63522dfbd4f4a.tar.gz
llvm-34df1600e003bf83678b308f7aa63522dfbd4f4a.tar.bz2
llvm-34df1600e003bf83678b308f7aa63522dfbd4f4a.tar.xz
YAMLParser: get rid of global ctors & dtors.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@155907 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/Support/YAMLParser.h')
-rw-r--r--include/llvm/Support/YAMLParser.h29
1 files changed, 18 insertions, 11 deletions
diff --git a/include/llvm/Support/YAMLParser.h b/include/llvm/Support/YAMLParser.h
index 87117fdd4d..10239958f3 100644
--- a/include/llvm/Support/YAMLParser.h
+++ b/include/llvm/Support/YAMLParser.h
@@ -513,37 +513,44 @@ private:
/// @brief Iterator abstraction for Documents over a Stream.
class document_iterator {
public:
- document_iterator() : Doc(NullDoc) {}
- document_iterator(OwningPtr<Document> &D) : Doc(D) {}
+ document_iterator() : Doc(0) {}
+ document_iterator(OwningPtr<Document> &D) : Doc(&D) {}
bool operator ==(const document_iterator &Other) {
- return Doc == Other.Doc;
+ if (isAtEnd() || Other.isAtEnd())
+ return isAtEnd() && Other.isAtEnd();
+
+ return *Doc == *Other.Doc;
}
bool operator !=(const document_iterator &Other) {
return !(*this == Other);
}
document_iterator operator ++() {
- if (!Doc->skip()) {
- Doc.reset(0);
+ assert(Doc != 0 && "incrementing iterator past the end.");
+ if (!(*Doc)->skip()) {
+ Doc->reset(0);
} else {
- Stream &S = Doc->stream;
- Doc.reset(new Document(S));
+ Stream &S = (*Doc)->stream;
+ Doc->reset(new Document(S));
}
return *this;
}
Document &operator *() {
- return *Doc;
+ return *Doc->get();
}
OwningPtr<Document> &operator ->() {
- return Doc;
+ return *Doc;
}
private:
- static OwningPtr<Document> NullDoc;
- OwningPtr<Document> &Doc;
+ bool isAtEnd() const {
+ return Doc == 0 || *Doc == 0;
+ }
+
+ OwningPtr<Document> *Doc;
};
}