[PATCH] D151198: [llvm][ADT] Fix invlid `reference` type of depth-first, breadth-first and post order iterators
Markus Böck via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue May 23 03:49:25 PDT 2023
zero9178 created this revision.
zero9178 added reviewers: kuhar, dblaikie.
Herald added a project: All.
zero9178 requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
C++s iterator concept requires `operator*` to return the same type as is specified by the iterators `reference` type. This functionality is especially important for older generic code that did not yet make use of `auto`.
An example from within LLVM is `iterator_adaptor_base` which uses the `reference` type of the iterator it is wrapping as its return type for `operator*` (this class is used as base for a lot of other functionality like filter iterators and so on).
Using any of the graph traversal iterators listed above with it would previously fail to compile due to `reference` being non-const while `operator*` returned a const reference.
This patch fixes that by correctly specifying `reference` and using it as the return type of `operator*` explicitly to prevent further issues in the future.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D151198
Files:
llvm/include/llvm/ADT/BreadthFirstIterator.h
llvm/include/llvm/ADT/DepthFirstIterator.h
llvm/include/llvm/ADT/PostOrderIterator.h
llvm/unittests/ADT/BreadthFirstIteratorTest.cpp
llvm/unittests/ADT/DepthFirstIteratorTest.cpp
llvm/unittests/ADT/PostOrderIteratorTest.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D151198.524639.patch
Type: text/x-patch
Size: 4177 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230523/c8fbbe6b/attachment.bin>
More information about the llvm-commits
mailing list