Hello, I think there's a rather subtle problem with the inst_iterator. It
declares its iterator category as std::bidirectional_iterator_tag but C++
standard requirements for forward iterator (which are included in
requirements for bidirection iterator), say that the type of expression
*r;
should be T&, where 'r' is the iterator and T is its value type. The
inst_iterator, though, returns pointer to Instruction, not a reference to a
pointer to instruction.
The above might sound like I've gone crazy reading C++ standard, but my real
reason is that with the current code the following:
for_each(inst_begin(f), inst_end(f), boost::bind(
apply_phi_semantics, result, _1, instruction2vertex));
does not compile, where 'apply_phi_semantics' is my function and boost::bind
is a tool for binding function arguments described in
Chapter 1. Boost.Bind - 1.80.0
The reason it does not compile is somewhat contrived. for_each passes the
result of *it to functional object returned by boost::bind. The operator() of
that object has the following signature:
template<class Arg1>
.... operator()(Arg& a1)
and since result of *it is considered to be rvalue it can't be accepted by
this operator. The complete discussion is in
http://std.dkuug.dk/jtc1/sc22/wg21/docs/papers/2002/n1385.htm
I'd suggest to apply the following patch which makes operator* return
reference to pointer. It makes my code compile and the rest of LLVM compiles
too. Comments?
- Volodya
iterator.diff (1.22 KB)