[llvm] 21390ea - [ADT][NFC] SCCIterator: Change hasLoop() to hasCycle()

Stefanos Baziotis via llvm-commits llvm-commits at lists.llvm.org
Sun Mar 1 09:17:49 PST 2020


Author: Stefanos Baziotis
Date: 2020-03-01T19:17:21+02:00
New Revision: 21390eab4c05e0ed7e7d13ada9e85f62b87ea484

URL: https://github.com/llvm/llvm-project/commit/21390eab4c05e0ed7e7d13ada9e85f62b87ea484
DIFF: https://github.com/llvm/llvm-project/commit/21390eab4c05e0ed7e7d13ada9e85f62b87ea484.diff

LOG: [ADT][NFC] SCCIterator: Change hasLoop() to hasCycle()

Added: 
    

Modified: 
    clang-tools-extra/clang-tidy/misc/NoRecursionCheck.cpp
    llvm/include/llvm/ADT/SCCIterator.h
    llvm/lib/IR/ModuleSummaryIndex.cpp
    llvm/tools/opt/PrintSCC.cpp

Removed: 
    


################################################################################
diff  --git a/clang-tools-extra/clang-tidy/misc/NoRecursionCheck.cpp b/clang-tools-extra/clang-tidy/misc/NoRecursionCheck.cpp
index d382501d191e..05007e5d85a3 100644
--- a/clang-tools-extra/clang-tidy/misc/NoRecursionCheck.cpp
+++ b/clang-tools-extra/clang-tidy/misc/NoRecursionCheck.cpp
@@ -264,7 +264,7 @@ void NoRecursionCheck::check(const MatchFinder::MatchResult &Result) {
   for (llvm::scc_iterator<CallGraph *> SCCI = llvm::scc_begin(&CG),
                                        SCCE = llvm::scc_end(&CG);
        SCCI != SCCE; ++SCCI) {
-    if (!SCCI.hasLoop()) // We only care about cycles, not standalone nodes.
+    if (!SCCI.hasCycle()) // We only care about cycles, not standalone nodes.
       continue;
     handleSCC(*SCCI);
   }

diff  --git a/llvm/include/llvm/ADT/SCCIterator.h b/llvm/include/llvm/ADT/SCCIterator.h
index 1e642b9f75d3..8a7c0a78a0fc 100644
--- a/llvm/include/llvm/ADT/SCCIterator.h
+++ b/llvm/include/llvm/ADT/SCCIterator.h
@@ -124,11 +124,11 @@ class scc_iterator : public iterator_facade_base<
     return CurrentSCC;
   }
 
-  /// Test if the current SCC has a loop.
+  /// Test if the current SCC has a cycle.
   ///
   /// If the SCC has more than one node, this is trivially true.  If not, it may
-  /// still contain a loop if the node has an edge back to itself.
-  bool hasLoop() const;
+  /// still contain a cycle if the node has an edge back to itself.
+  bool hasCycle() const;
 
   /// This informs the \c scc_iterator that the specified \c Old node
   /// has been deleted, and \c New is to be used in its place.
@@ -212,7 +212,7 @@ template <class GraphT, class GT> void scc_iterator<GraphT, GT>::GetNextSCC() {
 }
 
 template <class GraphT, class GT>
-bool scc_iterator<GraphT, GT>::hasLoop() const {
+bool scc_iterator<GraphT, GT>::hasCycle() const {
     assert(!CurrentSCC.empty() && "Dereferencing END SCC iterator!");
     if (CurrentSCC.size() > 1)
       return true;

diff  --git a/llvm/lib/IR/ModuleSummaryIndex.cpp b/llvm/lib/IR/ModuleSummaryIndex.cpp
index 13a685e1609e..158369a80aca 100644
--- a/llvm/lib/IR/ModuleSummaryIndex.cpp
+++ b/llvm/lib/IR/ModuleSummaryIndex.cpp
@@ -300,7 +300,7 @@ void ModuleSummaryIndex::dumpSCCs(raw_ostream &O) {
       if (V.getSummaryList().size())
         F = cast<FunctionSummary>(V.getSummaryList().front().get());
       O << " " << (F == nullptr ? "External" : "") << " " << utostr(V.getGUID())
-        << (I.hasLoop() ? " (has loop)" : "") << "\n";
+        << (I.hasCycle() ? " (has cycle)" : "") << "\n";
     }
     O << "}\n";
   }

diff  --git a/llvm/tools/opt/PrintSCC.cpp b/llvm/tools/opt/PrintSCC.cpp
index 419886d6cc60..5ab4a00552f3 100644
--- a/llvm/tools/opt/PrintSCC.cpp
+++ b/llvm/tools/opt/PrintSCC.cpp
@@ -79,7 +79,7 @@ bool CFGSCC::runOnFunction(Function &F) {
     for (std::vector<BasicBlock*>::const_iterator I = nextSCC.begin(),
            E = nextSCC.end(); I != E; ++I)
       errs() << (*I)->getName() << ", ";
-    if (nextSCC.size() == 1 && SCCI.hasLoop())
+    if (nextSCC.size() == 1 && SCCI.hasCycle())
       errs() << " (Has self-loop).";
   }
   errs() << "\n";
@@ -101,7 +101,7 @@ bool CallGraphSCC::runOnModule(Module &M) {
            E = nextSCC.end(); I != E; ++I)
       errs() << ((*I)->getFunction() ? (*I)->getFunction()->getName()
                                      : "external node") << ", ";
-    if (nextSCC.size() == 1 && SCCI.hasLoop())
+    if (nextSCC.size() == 1 && SCCI.hasCycle())
       errs() << " (Has self-loop).";
   }
   errs() << "\n";


        


More information about the llvm-commits mailing list