[PATCH] D29767: GraphTraits: Add range versions of graph traits functions (graph_nodes, graph_children, inverse_graph_nodes, inverse_graph_children).
Daniel Berlin via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 9 08:29:01 PST 2017
dberlin added inline comments.
================
Comment at: include/llvm/Support/GenericDomTreeConstruction.h:203
WInfo.Semi = WInfo.Parent;
- typedef GraphTraits<Inverse<NodeT> > InvTraits;
- for (typename InvTraits::ChildIteratorType CI =
- InvTraits::child_begin(W),
- E = InvTraits::child_end(W); CI != E; ++CI) {
- typename InvTraits::NodeRef N = *CI;
- if (DT.Info.count(N)) { // Only if this predecessor is reachable!
+ for (const auto &N : inverse_graph_children<NodeT>(W))
+ if (DT.Info.count(N)) { // Only if this predecessor is reachable!
----------------
Note that this use of const auto & is required to make clang build, as the iterator type it for CFG blocks ends up returning blocks directly otherwise here.
I'm not sure this is a legal definition of graphtraits, and the definition of CFG inverse graph traits is also definitely broken:
```
template <> struct GraphTraits<Inverse< ::clang::CFGBlock*> > {
typedef ::clang::CFGBlock *NodeRef;
- typedef ::clang::CFGBlock::const_pred_iterator ChildIteratorType;
+ typedef ::clang::CFGBlock::pred_iterator ChildIteratorType;
```
(the constant iterator is being used for the non-constant version of inverse graphtraits, which looks like a paste error)
I don't usually work in clang world, so i added someone who does :)
https://reviews.llvm.org/D29767
More information about the llvm-commits
mailing list