[all-commits] [llvm/llvm-project] 49fd85: [ADT] Add make_isa_range to filter and downcast a ...

Florian Hahn via All-commits all-commits at lists.llvm.org
Wed Sep 16 02:32:14 PDT 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 49fd850587bf7d6f235687f348a1e0b201738dba
      https://github.com/llvm/llvm-project/commit/49fd850587bf7d6f235687f348a1e0b201738dba
  Author: Florian Hahn <flo at fhahn.com>
  Date:   2026-09-16 (Wed, 16 Sep 2026)

  Changed paths:
    M llvm/include/llvm/ADT/STLExtras.h
    M llvm/unittests/ADT/STLExtrasTest.cpp

  Log Message:
  -----------
  [ADT] Add make_isa_range to filter and downcast a range by type (NFC) (#223414)

Add a range adaptor that keeps only the elements of a range that isa<T>
holds for, casting each of them to T.

This replaces the common idiom of filtering by type in the loop body

```
  for (Instruction &I : *BB) {
    auto *PN = dyn_cast<PHINode>(&I);
    if (!PN)
      continue;
    ... use PN ...
  }
```

with

```
  for (PHINode &PN : make_isa_range<PHINode>(*BB))
    ... use PN ...
```

This pattern is quite widespread in the LLVM codebase, and follow-up
commits will migrate use-sites step-by-step.

This is the helper from
https://github.com/llvm/llvm-project/pull/222770, moved to STL.

PR: https://github.com/llvm/llvm-project/pull/223414



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list