OSDN Git Service

[LCG] Replace an implicit bool operator with a named function. (NFC)
authorChandler Carruth <chandlerc@gmail.com>
Sat, 5 Aug 2017 04:04:06 +0000 (04:04 +0000)
committerChandler Carruth <chandlerc@gmail.com>
Sat, 5 Aug 2017 04:04:06 +0000 (04:04 +0000)
The definition of 'false' here was already pretty vague and debatable,
and I'm about to add another potential 'false' that would actually make
much more sense in a bool operator. Especially given how rarely this is
used, a nicely named method seems better.

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

include/llvm/Analysis/LazyCallGraph.h
lib/Analysis/LazyCallGraph.cpp

index a025f22..f2918cb 100644 (file)
@@ -329,7 +329,7 @@ public:
     bool operator!=(const Node &N) const { return !operator==(N); }
 
     /// Tests whether the node has been populated with edges.
-    operator bool() const { return Edges.hasValue(); }
+    bool isPopulated() const { return Edges.hasValue(); }
 
     // We allow accessing the edges by dereferencing or using the arrow
     // operator, essentially wrapping the internal optional.
index 7d38dd9..46e2982 100644 (file)
@@ -212,7 +212,7 @@ void LazyCallGraph::SCC::verify() {
     assert(N->LowLink == -1 &&
            "Must set low link to -1 when adding a node to an SCC!");
     for (Edge &E : **N)
-      assert(E.getNode() && "Can't have an unpopulated node!");
+      assert(E.getNode().isPopulated() && "Can't have an unpopulated node!");
   }
 }
 #endif
@@ -1649,7 +1649,7 @@ void LazyCallGraph::removeDeadFunction(Function &F) {
   for (RefSCC &ParentRC : RC.parents())
     for (SCC &ParentC : ParentRC)
       for (Node &ParentN : ParentC)
-        if (ParentN)
+        if (ParentN.isPopulated())
           ParentN->removeEdgeInternal(N);
 
   // Now remove this RefSCC from any parents sets and the leaf list.