diff options
author | Vedant Kumar <vsk@apple.com> | 2018-05-10 23:01:54 +0000 |
---|---|---|
committer | Vedant Kumar <vsk@apple.com> | 2018-05-10 23:01:54 +0000 |
commit | e0b5f86b3083747beaf5d7639333af0109c9e6ef (patch) | |
tree | f76486dec408880ad53ce624064ccb10f2b9faea /llvm/lib/Analysis/LazyCallGraph.cpp | |
parent | 4855c5f717fde5207033e97989b20b273298a57b (diff) | |
download | bcm5719-llvm-e0b5f86b3083747beaf5d7639333af0109c9e6ef.tar.gz bcm5719-llvm-e0b5f86b3083747beaf5d7639333af0109c9e6ef.zip |
[STLExtras] Add distance() for ranges, pred_size(), and succ_size()
This commit adds a wrapper for std::distance() which works with ranges.
As it would be a common case to write `distance(predecessors(BB))`, this
also introduces `pred_size()` and `succ_size()` helpers to make that
easier to write.
Differential Revision: https://reviews.llvm.org/D46668
llvm-svn: 332057
Diffstat (limited to 'llvm/lib/Analysis/LazyCallGraph.cpp')
-rw-r--r-- | llvm/lib/Analysis/LazyCallGraph.cpp | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/llvm/lib/Analysis/LazyCallGraph.cpp b/llvm/lib/Analysis/LazyCallGraph.cpp index 3bfacee3824..420a71c9ffe 100644 --- a/llvm/lib/Analysis/LazyCallGraph.cpp +++ b/llvm/lib/Analysis/LazyCallGraph.cpp @@ -1272,8 +1272,7 @@ LazyCallGraph::RefSCC::removeInternalRefEdge(Node &SourceN, // the removal hasn't changed the structure at all. This is an important // special case and we can directly exit the entire routine more // efficiently as soon as we discover it. - if (std::distance(RefSCCNodes.begin(), RefSCCNodes.end()) == - NumRefSCCNodes) { + if (distance(RefSCCNodes) == NumRefSCCNodes) { // Clear out the low link field as we won't need it. for (Node *N : RefSCCNodes) N->LowLink = -1; @@ -1739,7 +1738,7 @@ static void printNode(raw_ostream &OS, LazyCallGraph::Node &N) { } static void printSCC(raw_ostream &OS, LazyCallGraph::SCC &C) { - ptrdiff_t Size = std::distance(C.begin(), C.end()); + ptrdiff_t Size = distance(C); OS << " SCC with " << Size << " functions:\n"; for (LazyCallGraph::Node &N : C) @@ -1747,7 +1746,7 @@ static void printSCC(raw_ostream &OS, LazyCallGraph::SCC &C) { } static void printRefSCC(raw_ostream &OS, LazyCallGraph::RefSCC &C) { - ptrdiff_t Size = std::distance(C.begin(), C.end()); + ptrdiff_t Size = distance(C); OS << " RefSCC with " << Size << " call SCCs:\n"; for (LazyCallGraph::SCC &InnerC : C) |