Add in support for SPIR to LLVM core. This adds a new target and two new calling...
[oota-llvm.git] / include / llvm / ADT / EquivalenceClasses.h
index bed99d3d20573b5b1e954d1b3a4413843403777b..1d81772ee8ae8ea0f8ca246dc2b4eb0ac3555b1d 100644 (file)
@@ -16,6 +16,7 @@
 #define LLVM_ADT_EQUIVALENCECLASSES_H
 
 #include "llvm/Support/DataTypes.h"
+#include <cassert>
 #include <set>
 
 namespace llvm {
@@ -32,6 +33,7 @@ namespace llvm {
 ///
 /// Here is a simple example using integers:
 ///
+/// \code
 ///  EquivalenceClasses<int> EC;
 ///  EC.unionSets(1, 2);                // insert 1, 2 into the same set
 ///  EC.insert(4); EC.insert(5);        // insert 4, 5 into own sets
@@ -45,6 +47,7 @@ namespace llvm {
 ///      cerr << *MI << " ";  // Print member.
 ///    cerr << "\n";   // Finish set.
 ///  }
+/// \endcode
 ///
 /// This example prints:
 ///   4
@@ -168,7 +171,7 @@ public:
   /// getOrInsertLeaderValue - Return the leader for the specified value that is
   /// in the set.  If the member is not in the set, it is inserted, then
   /// returned.
-  const ElemTy &getOrInsertLeaderValue(const ElemTy &V) const {
+  const ElemTy &getOrInsertLeaderValue(const ElemTy &V) {
     member_iterator MI = findLeader(insert(V));
     assert(MI != member_end() && "Value is not in the set!");
     return *MI;
@@ -190,7 +193,7 @@ public:
   /// insert - Insert a new value into the union/find set, ignoring the request
   /// if the value already exists.
   iterator insert(const ElemTy &Data) {
-    return TheMapping.insert(Data).first;
+    return TheMapping.insert(ECValue(Data)).first;
   }
 
   /// findLeader - Given a value in the set, return a member iterator for the
@@ -234,8 +237,9 @@ public:
   }
 
   class member_iterator : public std::iterator<std::forward_iterator_tag,
-                                               ElemTy, ptrdiff_t> {
-    typedef std::iterator<std::forward_iterator_tag, ElemTy, ptrdiff_t> super;
+                                               const ElemTy, ptrdiff_t> {
+    typedef std::iterator<std::forward_iterator_tag,
+                          const ElemTy, ptrdiff_t> super;
     const ECValue *Node;
     friend class EquivalenceClasses;
   public:
@@ -249,7 +253,7 @@ public:
 
     reference operator*() const {
       assert(Node != 0 && "Dereferencing end()!");
-      return const_cast<reference>(Node->getData()); // FIXME
+      return Node->getData();
     }
     reference operator->() const { return operator*(); }