Skip to content

Commit a2691e3

Browse files
authored
[docs] remove some out-of-date content in LLVM Programmer's Manual (#74989)
Remove the part about implicit conversion from an iterator to a pointer. This part of the manual was written 14 years ago, in: 37027c3 There do exist a type casting operator in `ilist` then: https://github.com/llvm/llvm-project/blob/37027c30ec526afe3bb571df6f8701bf0d322f22/llvm/include/llvm/ADT/ilist.h#L192-L194 But it has been remove since 2016: f197b1f So I think it makes sense to remove this part to avoid mislead new contributors.
1 parent b3e1114 commit a2691e3

File tree

1 file changed

+0
-30
lines changed

1 file changed

+0
-30
lines changed

llvm/docs/ProgrammersManual.rst

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2747,24 +2747,6 @@ pointer from an iterator is very straight-forward. Assuming that ``i`` is a
27472747
Instruction* pinst = &*i; // Grab pointer to instruction reference
27482748
const Instruction& inst = *j;
27492749
2750-
However, the iterators you'll be working with in the LLVM framework are special:
2751-
they will automatically convert to a ptr-to-instance type whenever they need to.
2752-
Instead of dereferencing the iterator and then taking the address of the result,
2753-
you can simply assign the iterator to the proper pointer type and you get the
2754-
dereference and address-of operation as a result of the assignment (behind the
2755-
scenes, this is a result of overloading casting mechanisms). Thus the second
2756-
line of the last example,
2757-
2758-
.. code-block:: c++
2759-
2760-
Instruction *pinst = &*i;
2761-
2762-
is semantically equivalent to
2763-
2764-
.. code-block:: c++
2765-
2766-
Instruction *pinst = i;
2767-
27682750
It's also possible to turn a class pointer into the corresponding iterator, and
27692751
this is a constant time operation (very efficient). The following code snippet
27702752
illustrates use of the conversion constructors provided by LLVM iterators. By
@@ -2779,18 +2761,6 @@ obtaining it via iteration over some structure:
27792761
if (it != inst->getParent()->end()) errs() << *it << "\n";
27802762
}
27812763
2782-
Unfortunately, these implicit conversions come at a cost; they prevent these
2783-
iterators from conforming to standard iterator conventions, and thus from being
2784-
usable with standard algorithms and containers. For example, they prevent the
2785-
following code, where ``B`` is a ``BasicBlock``, from compiling:
2786-
2787-
.. code-block:: c++
2788-
2789-
llvm::SmallVector<llvm::Instruction *, 16>(B->begin(), B->end());
2790-
2791-
Because of this, these implicit conversions may be removed some day, and
2792-
``operator*`` changed to return a pointer instead of a reference.
2793-
27942764
.. _iterate_complex:
27952765

27962766
Finding call sites: a slightly more complex example

0 commit comments

Comments
 (0)