From: Chandler Carruth Date: Fri, 8 Jan 2016 10:50:11 +0000 (+0000) Subject: [LCG] Re-order the lazy node iterator below the node type to make some X-Git-Url: http://plrg.eecs.uci.edu/git/?p=oota-llvm.git;a=commitdiff_plain;h=84a9919b57b7a7d83914a2adf9417d347b34467a [LCG] Re-order the lazy node iterator below the node type to make some subsequent work I'm doing not have its delta obscured by boring code motion. NFC. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@257161 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/llvm/Analysis/LazyCallGraph.h b/include/llvm/Analysis/LazyCallGraph.h index ef3d5e8fe3d..e02f3ab2de1 100644 --- a/include/llvm/Analysis/LazyCallGraph.h +++ b/include/llvm/Analysis/LazyCallGraph.h @@ -104,54 +104,10 @@ class LazyCallGraph { public: class Node; class SCC; + class iterator; typedef SmallVector, 4> NodeVectorT; typedef SmallVectorImpl> NodeVectorImplT; - /// A lazy iterator used for both the entry nodes and child nodes. - /// - /// When this iterator is dereferenced, if not yet available, a function will - /// be scanned for "calls" or uses of functions and its child information - /// will be constructed. All of these results are accumulated and cached in - /// the graph. - class iterator - : public iterator_adaptor_base { - friend class LazyCallGraph; - friend class LazyCallGraph::Node; - - LazyCallGraph *G; - NodeVectorImplT::iterator E; - - // Build the iterator for a specific position in a node list. - iterator(LazyCallGraph &G, NodeVectorImplT::iterator NI, - NodeVectorImplT::iterator E) - : iterator_adaptor_base(NI), G(&G), E(E) { - while (I != E && I->isNull()) - ++I; - } - - public: - iterator() {} - - using iterator_adaptor_base::operator++; - iterator &operator++() { - do { - ++I; - } while (I != E && I->isNull()); - return *this; - } - - reference operator*() const { - if (I->is()) - return *I->get(); - - Function *F = I->get(); - Node &ChildN = G->get(*F); - *I = &ChildN; - return ChildN; - } - }; - /// A node in the call graph. /// /// This represents a single node. It's primary roles are to cache the list of @@ -200,6 +156,51 @@ public: bool operator!=(const Node &N) const { return !operator==(N); } }; + /// A lazy iterator used for both the entry nodes and child nodes. + /// + /// When this iterator is dereferenced, if not yet available, a function will + /// be scanned for "calls" or uses of functions and its child information + /// will be constructed. All of these results are accumulated and cached in + /// the graph. + class iterator + : public iterator_adaptor_base { + friend class LazyCallGraph; + friend class LazyCallGraph::Node; + + LazyCallGraph *G; + NodeVectorImplT::iterator E; + + // Build the iterator for a specific position in a node list. + iterator(LazyCallGraph &G, NodeVectorImplT::iterator NI, + NodeVectorImplT::iterator E) + : iterator_adaptor_base(NI), G(&G), E(E) { + while (I != E && I->isNull()) + ++I; + } + + public: + iterator() {} + + using iterator_adaptor_base::operator++; + iterator &operator++() { + do { + ++I; + } while (I != E && I->isNull()); + return *this; + } + + reference operator*() const { + if (I->is()) + return *I->get(); + + Function *F = I->get(); + Node &ChildN = G->get(*F); + *I = &ChildN; + return ChildN; + } + }; + /// An SCC of the call graph. /// /// This represents a Strongly Connected Component of the call graph as