[llvm-commits] [llvm] r57894 - /llvm/trunk/include/llvm/ADT/ImmutableList.h

Ted Kremenek kremenek at apple.com
Mon Oct 20 22:59:33 PDT 2008


Author: kremenek
Date: Tue Oct 21 00:59:33 2008
New Revision: 57894

URL: http://llvm.org/viewvc/llvm-project?rev=57894&view=rev
Log:
constify some methods and variables in ImmutableList.

Modified:
    llvm/trunk/include/llvm/ADT/ImmutableList.h

Modified: llvm/trunk/include/llvm/ADT/ImmutableList.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/ImmutableList.h?rev=57894&r1=57893&r2=57894&view=diff

==============================================================================
--- llvm/trunk/include/llvm/ADT/ImmutableList.h (original)
+++ llvm/trunk/include/llvm/ADT/ImmutableList.h Tue Oct 21 00:59:33 2008
@@ -26,9 +26,9 @@
 template <typename T>
 class ImmutableListImpl : public FoldingSetNode {
   T Head;
-  ImmutableListImpl* Tail;
+  const ImmutableListImpl* Tail;
 
-  ImmutableListImpl(const T& head, ImmutableListImpl* tail = 0)
+  ImmutableListImpl(const T& head, const ImmutableListImpl* tail = 0)
     : Head(head), Tail(tail) {}
   
   friend class ImmutableListFactory<T>;
@@ -39,10 +39,10 @@
   
 public:
   const T& getHead() const { return Head; }
-  ImmutableListImpl* getTail() const { return Tail; }
+  const ImmutableListImpl* getTail() const { return Tail; }
   
   static inline void Profile(FoldingSetNodeID& ID, const T& H,
-                             ImmutableListImpl* L){
+                             const ImmutableListImpl* L){
     ID.AddPointer(L);
     ID.Add(H);
   }
@@ -67,20 +67,20 @@
   typedef ImmutableListFactory<T> Factory;
 
 private:
-  ImmutableListImpl<T>* X;
+  const ImmutableListImpl<T>* X;
 
 public:
   // This constructor should normally only be called by ImmutableListFactory<T>.
   // There may be cases, however, when one needs to extract the internal pointer
   // and reconstruct a list object from that pointer.
-  ImmutableList(ImmutableListImpl<T>* x = 0) : X(x) {}
+  ImmutableList(const ImmutableListImpl<T>* x = 0) : X(x) {}
 
-  ImmutableListImpl<T>* getInternalPointer() const {
+  const ImmutableListImpl<T>* getInternalPointer() const {
     return X;
   }
   
   class iterator {
-    ImmutableListImpl<T>* L;
+    const ImmutableListImpl<T>* L;
   public:
     iterator() : L(0) {}
     iterator(ImmutableList l) : L(l.getInternalPointer()) {}
@@ -157,7 +157,7 @@
     FoldingSetNodeID ID;
     void* InsertPos;
     
-    ListTy* TailImpl = Tail.getInternalPointer();
+    const ListTy* TailImpl = Tail.getInternalPointer();
     ListTy::Profile(ID, Head, TailImpl);
     ListTy* L = Cache.FindNodeOrInsertPos(ID, InsertPos);
     





More information about the llvm-commits mailing list