[all-commits] [llvm/llvm-project] 17faae: [ADT] Introduce `map_to_vector` helper

Laszlo Kindrat via All-commits all-commits at lists.llvm.org
Thu May 4 04:25:54 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 17faae95d799e5b4cf8344589641efcb1c740454
      https://github.com/llvm/llvm-project/commit/17faae95d799e5b4cf8344589641efcb1c740454
  Author: Laszlo Kindrat <laszlo at modular.com>
  Date:   2023-05-04 (Thu, 04 May 2023)

  Changed paths:
    A llvm/include/llvm/ADT/SmallVectorExtras.h
    M mlir/lib/Conversion/GPUCommon/GPUOpsLowering.cpp
    M mlir/lib/Dialect/Affine/IR/AffineOps.cpp

  Log Message:
  -----------
  [ADT] Introduce `map_to_vector` helper

The following pattern is common in the llvm codebase, as well as in downstream projects:
```
llvm::to_vector(llvm::map_range(container, lambda))
```
This patch introduces a shortcut for this called `map_to_vector`.

This template depends on both `llvm/ADT/SmallVector.h` and `llvm/ADT/STLExtras.h`, and since these are both relatively large and do not depend on each other, the `map_to_vector` helper is placed in a new header under `llvm/ADT/SmallVectorExtras.h`. Only a handful of use cases have been updated to use the new helper.

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




More information about the All-commits mailing list