Constify SDNodeIterator an stop its only non-const user being cast stripped
authorRoman Divacky <rdivacky@freebsd.org>
Wed, 5 Sep 2012 22:03:34 +0000 (22:03 +0000)
committerRoman Divacky <rdivacky@freebsd.org>
Wed, 5 Sep 2012 22:03:34 +0000 (22:03 +0000)
of its constness. Found by gcc48 -Wcast-qual.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@163254 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/CodeGen/SelectionDAGNodes.h
lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp

index 119adaa201f0133c4f16ba6aa19539f8ebb46b9f..3bea2ded68d6ac122d3ea55faa78032e2b86cf88 100644 (file)
@@ -1745,10 +1745,10 @@ public:
 
 class SDNodeIterator : public std::iterator<std::forward_iterator_tag,
                                             SDNode, ptrdiff_t> {
-  SDNode *Node;
+  const SDNode *Node;
   unsigned Operand;
 
-  SDNodeIterator(SDNode *N, unsigned Op) : Node(N), Operand(Op) {}
+  SDNodeIterator(const SDNode *N, unsigned Op) : Node(N), Operand(Op) {}
 public:
   bool operator==(const SDNodeIterator& x) const {
     return Operand == x.Operand;
@@ -1779,8 +1779,8 @@ public:
     return Operand - Other.Operand;
   }
 
-  static SDNodeIterator begin(SDNode *N) { return SDNodeIterator(N, 0); }
-  static SDNodeIterator end  (SDNode *N) {
+  static SDNodeIterator begin(const SDNode *N) { return SDNodeIterator(N, 0); }
+  static SDNodeIterator end  (const SDNode *N) {
     return SDNodeIterator(N, N->getNumOperands());
   }
 
index 618da5259f7b816ab1c880fd5f2deed57ccc8077..39216356522fe806385251e59aa1afa1feba3dd4 100644 (file)
@@ -49,7 +49,7 @@ namespace llvm {
 
     template<typename EdgeIter>
     static std::string getEdgeSourceLabel(const void *Node, EdgeIter I) {
-      return itostr(I - SDNodeIterator::begin((SDNode *) Node));
+      return itostr(I - SDNodeIterator::begin((const SDNode *) Node));
     }
 
     /// edgeTargetsEdgeSource - This method returns true if this outgoing edge