This is an archive of the discontinued LLVM Phabricator instance.

[GraphTraits] Make nodes_iterator dereference to NodeType*
ClosedPublic

Authored by timshen on Aug 18 2016, 10:29 PM.

Details

Reviewers
dblaikie
Summary

Currently nodes_iterator may dereference to a NodeType* or a NodeType&. Make them all dereference to NodeType*, which is NodeRef later. Corresponding LLVM change: D23704

Diff Detail

Event Timeline

timshen updated this revision to Diff 68649.Aug 18 2016, 10:29 PM
timshen retitled this revision from to [GraphTraits] Make nodes_iterator dereference to NodeRef.
timshen updated this object.
timshen added a reviewer: dblaikie.
timshen added a subscriber: cfe-commits.
timshen retitled this revision from [GraphTraits] Make nodes_iterator dereference to NodeRef to [GraphTraits] Make nodes_iterator dereference to NodeType*.Aug 18 2016, 10:35 PM
dblaikie accepted this revision.Aug 19 2016, 10:13 AM
dblaikie edited edge metadata.

Consider renaming and/or generalizing the handlers.

Also, in a follow-up or preliminary commit, could you remove all the DerefFun stuff. Move the definition of CGdereference (if they remain) above the typedef of nodes_iterator and use decltype(&CGdereference), and you can drop the "DerefFun(...)" around the CGdereference). That way the change only needs to change the deref function and everything else falls out.

(you could also change the calls to map_iterator to just directly call nodes_iterator(...) since you have the specific type, there's no need to call the deduction-powered generic function)

(idle rambling: This is why I really want the ability to decltype stateless lambdas:

typedef mapped_iterator<..., decltype([](PairTy P) { return P.second; })> nodes_iterator

)

include/clang/Analysis/CallGraph.h
219

I don't have enough context - but presumably this name should be changed now that the function doesn't actually dereference? (perhaps this is just get<1, PairTy::first_type, PairTy::second_type> - but could be useful to have a generic utility, something like 'firster' and 'seconder' - I thought there might already be, but couldn't find one. Could generalize it like get<> but just allow the actual tuple/pair type to be passed, rather than having to decompose it)

This revision is now accepted and ready to land.Aug 19 2016, 10:13 AM
timshen added inline comments.Aug 19 2016, 11:36 AM
include/clang/Analysis/CallGraph.h
219

I'll add a GetNthFunctor or something to STLExtras.h in the next patch, so that we don't need to create a specific one.

timshen closed this revision.Aug 19 2016, 2:29 PM

Landed as r279326.