This is an archive of the discontinued LLVM Phabricator instance.

[CFG] Introduce CFGElementRef, a wrapper that knows it's position in a CFGBlock
ClosedPublic

Authored by Szelethus on Jul 24 2019, 3:20 AM.

Details

Summary

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 :^)

Diff Detail

Repository
rL LLVM

Event Timeline

Szelethus created this revision.Jul 24 2019, 3:20 AM
Szelethus edited the summary of this revision. (Show Details)Jul 24 2019, 3:23 AM
NoQ accepted this revision.Jul 24 2019, 4:27 PM

Oof.

Someone had to do it.

clang/include/clang/Analysis/CFG.h
617 ↗(On Diff #211455)

Yeah, kinda shocking that you needed to go that far >.<

I suggest CFGElementRefBase or CFGElementRefImpl or something like that, because otherwise it looks to me as if it's some sort of a generic reference to an element of arbitrary collection.

648–650 ↗(On Diff #211455)

For lexicographic comparisons i personally enjoy std::make_pair(Parent, Index) < std::make_pair(Other.Parent, Other.Index).

This revision is now accepted and ready to land.Jul 24 2019, 4:27 PM
This revision was automatically updated to reflect the committed changes.
Szelethus marked an inline comment as done.
Herald added a project: Restricted Project. · View Herald TranscriptAug 14 2019, 10:05 AM