Add relocation types for Hexagon processor; patch by Sidney Manning <sidneym@codeauro...
[oota-llvm.git] / include / llvm / Support / YAMLParser.h
index 85ecc13d964c512fd476fd4ddba7ff90c9173540..98910eb7578f9d558d63fff6bbdb899d3384b7ae 100644 (file)
@@ -130,7 +130,7 @@ public:
   void setError(const Twine &Message, Token &Location) const;
   bool failed() const;
 
-  virtual void skip() {};
+  virtual void skip() {}
 
   unsigned int getType() const { return TypeID; }
   static inline bool classof(const Node *) { return true; }
@@ -149,7 +149,9 @@ protected:
   OwningPtr<Document> &Doc;
   SMRange SourceRange;
 
-  virtual ~Node();
+  void operator delete(void *) throw() {}
+
+  virtual ~Node() {}
 
 private:
   unsigned int TypeID;
@@ -168,9 +170,6 @@ public:
   static inline bool classof(const Node *N) {
     return N->getType() == NK_Null;
   }
-
-protected:
-  virtual ~NullNode();
 };
 
 /// @brief A scalar node is an opaque datum that can be presented as a
@@ -205,9 +204,6 @@ public:
     return N->getType() == NK_Scalar;
   }
 
-protected:
-  virtual ~ScalarNode();
-
 private:
   StringRef Value;
 
@@ -255,9 +251,6 @@ public:
     return N->getType() == NK_KeyValue;
   }
 
-protected:
-  virtual ~KeyValueNode();
-
 private:
   Node *Key;
   Node *Value;
@@ -343,7 +336,7 @@ public:
   enum MappingType {
     MT_Block,
     MT_Flow,
-    MT_Inline //< An inline mapping node is used for "[key: value]".
+    MT_Inline ///< An inline mapping node is used for "[key: value]".
   };
 
   MappingNode(OwningPtr<Document> &D, StringRef Anchor, MappingType MT)
@@ -374,9 +367,6 @@ public:
     return N->getType() == NK_Mapping;
   }
 
-protected:
-  virtual ~MappingNode();
-
 private:
   MappingType Type;
   bool IsAtBeginning;
@@ -440,9 +430,6 @@ public:
     return N->getType() == NK_Sequence;
   }
 
-protected:
-  virtual ~SequenceNode();
-
 private:
   SequenceType SeqType;
   bool IsAtBeginning;
@@ -468,9 +455,6 @@ public:
     return N->getType() == NK_Alias;
   }
 
-protected:
-  virtual ~AliasNode();
-
 private:
   StringRef Name;
 };
@@ -529,34 +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) {
+    if (isAtEnd() || Other.isAtEnd())
+      return isAtEnd() && Other.isAtEnd();
+
+    return *Doc == *Other.Doc;
+  }
   bool operator !=(const document_iterator &Other) {
-    return Doc != Other.Doc;
+    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;
 };
 
 }