Make typedefs in ilist public (Visual C++ errors out when they are private).
[oota-llvm.git] / include / llvm / ADT / FoldingSet.h
index 0efe78d7bd4ba97d45a97b09fb060726326d0f48..f34a62d4f4c6be1076dc3752d13402212105aa36 100644 (file)
@@ -32,7 +32,7 @@ namespace llvm {
 /// 
 /// This class is implemented as a single-link chained hash table, where the
 /// "buckets" are actually the nodes themselves (the next pointer is in the
-/// node).  The last node points back to the bucket to simplified node removal.
+/// node).  The last node points back to the bucket to simplify node removal.
 ///
 /// Any node that is to be included in the folding set must be a subclass of
 /// FoldingSetNode.  The node class must also define a Profile method used to
@@ -220,6 +220,7 @@ public:
   void AddFloat(float F);
   void AddDouble(double D);
   void AddString(const std::string &String);
+  void AddString(const char* String);
   
   template <typename T>
   inline void Add(const T& x) { FoldingSetTrait<T>::Profile(x, *this); }
@@ -316,7 +317,7 @@ public:
 template<class T>
 class FoldingSetIterator : public FoldingSetIteratorImpl {
 public:
-  FoldingSetIterator(void **Bucket) : FoldingSetIteratorImpl(Bucket) {}
+  explicit FoldingSetIterator(void **Bucket) : FoldingSetIteratorImpl(Bucket) {}
   
   T &operator*() const {
     return *static_cast<T*>(NodePtr);
@@ -344,10 +345,10 @@ class FoldingSetBucketIteratorImpl {
 protected:
   void *Ptr;
 
-  FoldingSetBucketIteratorImpl(void **Bucket);
+  explicit FoldingSetBucketIteratorImpl(void **Bucket);
   
   FoldingSetBucketIteratorImpl(void **Bucket, bool)
-    : Ptr(reinterpret_cast<void*>(Bucket)) {}
+    : Ptr(Bucket) {}
 
   void advance() {
     void *Probe = static_cast<FoldingSetNode*>(Ptr)->getNextInBucket();
@@ -368,7 +369,7 @@ public:
 template<class T>
 class FoldingSetBucketIterator : public FoldingSetBucketIteratorImpl {
 public:
-  FoldingSetBucketIterator(void **Bucket) : 
+  explicit FoldingSetBucketIterator(void **Bucket) : 
     FoldingSetBucketIteratorImpl(Bucket) {}
   
   FoldingSetBucketIterator(void **Bucket, bool) : 
@@ -393,7 +394,7 @@ template <typename T>
 class FoldingSetNodeWrapper : public FoldingSetNode {
   T data;
 public:
-  FoldingSetNodeWrapper(const T& x) : data(x) {}
+  explicit FoldingSetNodeWrapper(const T& x) : data(x) {}
   virtual ~FoldingSetNodeWrapper() {}
   
   template<typename A1>
@@ -426,6 +427,18 @@ public:
 
   operator T&() { return data; }
   operator const T&() const { return data; }
+};  
+  
+//===----------------------------------------------------------------------===//
+// Partial specializations of FoldingSetTrait.
+
+template<typename T> struct FoldingSetTrait<T*> {
+  static inline void Profile(const T* X, FoldingSetNodeID& ID) {
+    ID.AddPointer(X);
+  }
+  static inline void Profile(T* X, FoldingSetNodeID& ID) {
+    ID.AddPointer(X);
+  }
 };
 
 } // End of namespace llvm.