[llvm] r206375 - [LCG] Stop playing fast and loose with reference members and assignment.

Chandler Carruth chandlerc at gmail.com
Wed Apr 16 04:14:28 PDT 2014


Author: chandlerc
Date: Wed Apr 16 06:14:28 2014
New Revision: 206375

URL: http://llvm.org/viewvc/llvm-project?rev=206375&view=rev
Log:
[LCG] Stop playing fast and loose with reference members and assignment.
It doesn't work. I'm still cleaning up all the places where I blindly
followed this pattern. There are more to come in this code too.

As a benefit, this lets the default copy and move operations Just Work.

Modified:
    llvm/trunk/include/llvm/Analysis/LazyCallGraph.h

Modified: llvm/trunk/include/llvm/Analysis/LazyCallGraph.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/LazyCallGraph.h?rev=206375&r1=206374&r2=206375&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Analysis/LazyCallGraph.h (original)
+++ llvm/trunk/include/llvm/Analysis/LazyCallGraph.h Wed Apr 16 06:14:28 2014
@@ -119,25 +119,18 @@ public:
     /// \brief Nonce type to select the constructor for the end iterator.
     struct IsAtEndT {};
 
-    LazyCallGraph &G;
+    LazyCallGraph *G;
     NodeVectorImplT::iterator NI;
 
     // Build the begin iterator for a node.
     explicit iterator(LazyCallGraph &G, NodeVectorImplT &Nodes)
-        : G(G), NI(Nodes.begin()) {}
+        : G(&G), NI(Nodes.begin()) {}
 
     // Build the end iterator for a node. This is selected purely by overload.
     iterator(LazyCallGraph &G, NodeVectorImplT &Nodes, IsAtEndT /*Nonce*/)
-        : G(G), NI(Nodes.end()) {}
+        : G(&G), NI(Nodes.end()) {}
 
   public:
-    iterator(const iterator &Arg) : G(Arg.G), NI(Arg.NI) {}
-    iterator(iterator &&Arg) : G(Arg.G), NI(std::move(Arg.NI)) {}
-    iterator &operator=(iterator Arg) {
-      std::swap(Arg, *this);
-      return *this;
-    }
-
     bool operator==(const iterator &Arg) { return NI == Arg.NI; }
     bool operator!=(const iterator &Arg) { return !operator==(Arg); }
 
@@ -146,7 +139,7 @@ public:
         return NI->get<Node *>();
 
       Function *F = NI->get<Function *>();
-      Node *ChildN = G.get(*F);
+      Node *ChildN = G->get(*F);
       *NI = ChildN;
       return ChildN;
     }





More information about the llvm-commits mailing list