[llvm] r310165 - [LCG] Replace an implicit bool operator with a named function. (NFC)

Chandler Carruth via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 4 21:04:06 PDT 2017


Author: chandlerc
Date: Fri Aug  4 21:04:06 2017
New Revision: 310165

URL: http://llvm.org/viewvc/llvm-project?rev=310165&view=rev
Log:
[LCG] Replace an implicit bool operator with a named function. (NFC)

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.

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

Modified: llvm/trunk/include/llvm/Analysis/LazyCallGraph.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/LazyCallGraph.h?rev=310165&r1=310164&r2=310165&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Analysis/LazyCallGraph.h (original)
+++ llvm/trunk/include/llvm/Analysis/LazyCallGraph.h Fri Aug  4 21:04:06 2017
@@ -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.

Modified: llvm/trunk/lib/Analysis/LazyCallGraph.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/LazyCallGraph.cpp?rev=310165&r1=310164&r2=310165&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/LazyCallGraph.cpp (original)
+++ llvm/trunk/lib/Analysis/LazyCallGraph.cpp Fri Aug  4 21:04:06 2017
@@ -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(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.




More information about the llvm-commits mailing list