Fix const ilist_node::get{Prev,Next}Node() to actually compile. Picky, picky.
authorDaniel Dunbar <daniel@zuster.org>
Thu, 13 May 2010 18:35:02 +0000 (18:35 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Thu, 13 May 2010 18:35:02 +0000 (18:35 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@103723 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/ADT/ilist_node.h
unittests/ADT/ilistTest.cpp

index 3de4f156d20e60629457aee7929152522fdfef6e..f0080035cb885157e0a80b9e0300227e21ad3300 100644 (file)
@@ -67,7 +67,7 @@ public:
 
   /// \brief Get the previous node, or 0 for the list head.
   const NodeTy *getPrevNode() const {
-    NodeTy *Prev = this->getPrev();
+    const NodeTy *Prev = this->getPrev();
 
     // Check for sentinel.
     if (!Prev->getNext())
@@ -89,7 +89,7 @@ public:
 
   /// \brief Get the next node, or 0 for the list tail.
   const NodeTy *getNextNode() const {
-    NodeTy *Next = getNext();
+    const NodeTy *Next = getNext();
 
     // Check for sentinel.
     if (!Next->getNext())
index 3bf04dccc2c6855944f76ab10361cda243a8605f..09a699a9624640983b36e6fe82c632eccc2cec6f 100644 (file)
@@ -34,6 +34,11 @@ TEST(ilistTest, Basic) {
   EXPECT_EQ(2, List.back().Value);
   EXPECT_EQ(2, List.front().getNextNode()->Value);
   EXPECT_EQ(1, List.back().getPrevNode()->Value);
+
+  const ilist<Node> &ConstList = List;
+  EXPECT_EQ(2, ConstList.back().Value);
+  EXPECT_EQ(2, ConstList.front().getNextNode()->Value);
+  EXPECT_EQ(1, ConstList.back().getPrevNode()->Value);
 }
 
 }