summaryrefslogtreecommitdiffstats
path: root/clang/lib/Analysis
diff options
context:
space:
mode:
authorKristof Umann <dkszelethus@gmail.com>2019-08-14 17:05:55 +0000
committerKristof Umann <dkszelethus@gmail.com>2019-08-14 17:05:55 +0000
commit92541e359e4bdd2e9a149a2bb7d1519f77244655 (patch)
treeee3645445d174d689e9c5ba60bfe51d11d266b5d /clang/lib/Analysis
parent619172a8184ee6a1326588d916579fcabcfcf43a (diff)
downloadbcm5719-llvm-92541e359e4bdd2e9a149a2bb7d1519f77244655.tar.gz
bcm5719-llvm-92541e359e4bdd2e9a149a2bb7d1519f77244655.zip
[CFG] Introduce CFGElementRef, a wrapper that knows it's position in a CFGBlock
Previously, collecting CFGElements in a set was practially impossible, because both CFGBlock::operator[] and both the iterators returned it by value. One workaround would be to collect the iterators instead, but they don't really capture the concept of an element, and elements from different iterator types are incomparable. This patch introduces CFGElementRef, a wrapper around a (CFGBlock, Index) pair, and a variety of new iterators and iterator ranges to solve this problem. I guess you could say that this patch took a couple iterations to get right :^) Differential Revision: https://reviews.llvm.org/D65196 llvm-svn: 368883
Diffstat (limited to 'clang/lib/Analysis')
-rw-r--r--clang/lib/Analysis/CFG.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/clang/lib/Analysis/CFG.cpp b/clang/lib/Analysis/CFG.cpp
index b050347826e..fb643464fa9 100644
--- a/clang/lib/Analysis/CFG.cpp
+++ b/clang/lib/Analysis/CFG.cpp
@@ -5615,6 +5615,10 @@ void CFG::print(raw_ostream &OS, const LangOptions &LO, bool ShowColors) const {
OS.flush();
}
+size_t CFGBlock::getIndexInCFG() const {
+ return llvm::find(*getParent(), this) - getParent()->begin();
+}
+
/// dump - A simply pretty printer of a CFGBlock that outputs to stderr.
void CFGBlock::dump(const CFG* cfg, const LangOptions &LO,
bool ShowColors) const {
OpenPOWER on IntegriCloud