Skip to content

[docs] remove some out-of-date content in LLVM Programmer's Manual. #119565

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 0 additions & 30 deletions llvm/docs/ProgrammersManual.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2747,24 +2747,6 @@ pointer from an iterator is very straight-forward. Assuming that ``i`` is a
Instruction* pinst = &*i; // Grab pointer to instruction reference
const Instruction& inst = *j;

However, the iterators you'll be working with in the LLVM framework are special:
they will automatically convert to a ptr-to-instance type whenever they need to.
Instead of dereferencing the iterator and then taking the address of the result,
you can simply assign the iterator to the proper pointer type and you get the
dereference and address-of operation as a result of the assignment (behind the
scenes, this is a result of overloading casting mechanisms). Thus the second
line of the last example,

.. code-block:: c++

Instruction *pinst = &*i;

is semantically equivalent to

.. code-block:: c++

Instruction *pinst = i;

It's also possible to turn a class pointer into the corresponding iterator, and
this is a constant time operation (very efficient). The following code snippet
illustrates use of the conversion constructors provided by LLVM iterators. By
Expand All @@ -2779,18 +2761,6 @@ obtaining it via iteration over some structure:
if (it != inst->getParent()->end()) errs() << *it << "\n";
}

Unfortunately, these implicit conversions come at a cost; they prevent these
iterators from conforming to standard iterator conventions, and thus from being
usable with standard algorithms and containers. For example, they prevent the
following code, where ``B`` is a ``BasicBlock``, from compiling:

.. code-block:: c++

llvm::SmallVector<llvm::Instruction *, 16>(B->begin(), B->end());

Because of this, these implicit conversions may be removed some day, and
``operator*`` changed to return a pointer instead of a reference.

.. _iterate_complex:

Finding call sites: a slightly more complex example
Expand Down
Loading