[CFG] Introduce CFGElementRef, a wrapper that knows it's position in a CFGBlock
authorKristof Umann <dkszelethus@gmail.com>
Wed, 14 Aug 2019 17:05:55 +0000 (17:05 +0000)
committerKristof Umann <dkszelethus@gmail.com>
Wed, 14 Aug 2019 17:05:55 +0000 (17:05 +0000)
commit92541e359e4bdd2e9a149a2bb7d1519f77244655
treeee3645445d174d689e9c5ba60bfe51d11d266b5d
parent619172a8184ee6a1326588d916579fcabcfcf43a
[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
clang/include/clang/Analysis/CFG.h
clang/lib/Analysis/CFG.cpp
clang/unittests/Analysis/CFGTest.cpp