You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Support][Casting] Add predicates for isa* functions
Expose function objects that call into `llvm::isa` and
`llvm::isa_and_present`, such that these type checks can be used as
predicates in generic algorithms.
Before this change, `llvm::isa*` functions cannot be easily used without
knowing both the argument type and the checked types, which leads to
them being wrapped in lambdas. For example:
```c++
llvm::all_of(myTypes,
[](auto type) { return llvm::isa<VectorType>(type); });
```
With this PR the example above becomes:
```c++
llvm::all_of(myTypes, llvm::IsaPred<VectorType>);
```
As an alternative solution, I considered redefining `isa*` as function
objects, but I decided against doing that because it would create
assymetry with other cast *functions* and could break code that depends
on them being actual functions.
0 commit comments