I may not fully understand your point. Here are my thoughts:
First, In think changing the CFG::iterator to be in line with Function::iterator is too intrusive to clang, and not very necessary. I actually tried to do this. It involved so many changes that I finally gave up.
Just to be sure we are on the same page, I was suggesting to change the type, not the internal implementation of the CFG. Ex: you could create an iterator adapter. In any case, there will be less dependencies if we go with the GraphTraits solution.
Second, on your comment on the approach I took. Even the current implementation of the recalculate function does not solely depend on GraphTraits. It also depends on Function::getEntryBlock or Function::front(), Function.size(), etc. Why do you think a clean implementation should only depend on GraphTraits?
That is the general idea behind GraphTraits. Each class which represents a graph implements the traits interface. The graph algorithms (dominators is one of them) rely only on that interface. I am not sure why the current implementation of dominators relies directly on the Function class methods instead of using the traits. I suspect it was just the matter of someone not having the time to implement that…
In addition, I actually have such a concern: is it reasonable enough to fill in GraphTraits more stuff only because dominators implementation needs this?
We should ask on the LLVM developers mailing list. getEntryBlock() is already in the GraphTraits, so we would only need to add size() (or something similar to that, which would satisfy the dominators implementation).
I believe it should be possible to change the recalculate function to only depend on GraphTraits. But I am not sure if this will be viewed as too intrusive to LLVM. In thinking of these I finally made that compromise.
This would require a non-trivial patch to LLVM. I’d suggest running the idea by the llvm-dev list/sending the LLVM patch there for review.
Regarding the time, I am willing to do further refactoring until this code will finally become good enough, although I can only work on weekend on this. I just want to understand clearly the reasonable motivation behind each refactoring step.
Great! Thanks for all the work you are doing.