[all-commits] [llvm/llvm-project] c88a7a: [llvm][ADT] Fix invalid `reference` type of depth-...

Markus Böck via All-commits all-commits at lists.llvm.org
Tue May 23 10:30:03 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: c88a7a7b8ebf5b08fbbac2d22c07810774af231b
      https://github.com/llvm/llvm-project/commit/c88a7a7b8ebf5b08fbbac2d22c07810774af231b
  Author: Markus Böck <markus.boeck02 at gmail.com>
  Date:   2023-05-23 (Tue, 23 May 2023)

  Changed paths:
    M llvm/include/llvm/ADT/BreadthFirstIterator.h
    M llvm/include/llvm/ADT/DepthFirstIterator.h
    M llvm/include/llvm/ADT/PostOrderIterator.h
    M llvm/unittests/ADT/BreadthFirstIteratorTest.cpp
    M llvm/unittests/ADT/DepthFirstIteratorTest.cpp
    M llvm/unittests/ADT/PostOrderIteratorTest.cpp

  Log Message:
  -----------
  [llvm][ADT] Fix invalid `reference` type of depth-first, breadth-first and post order iterators

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.

Differential Revision: https://reviews.llvm.org/D151198




More information about the All-commits mailing list