[clang-tidy] Check request: suggest usage of `llvm::dyn_cast_if_present`, `llvm::cast_if_present` and `llvm::isa_and_present`
Open
check-request
clang-tidy
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
before:
```
const auto *ICE = S ? dyn_cast(S) : nullptr;
const bool IsParen = S ? isa(S) : false;
auto *Inst = Val ? cast(Val) : nullptr;
```
after:
```
const auto *ICE = dyn_cast_if_present(S);
const bool IsParen = isa_and_present(S);
auto *Inst = cast_if_present(Val);
```
Contributor guide
Research direction
The issue names clang-tidy and provides before/after examples, but no files or tests. Start by locating the clang-tidy check registry and related LLVM cast helper usage, then determine where this check belongs. Done means the check suggests the three *_if_present or isa_and_present forms for the shown conditional patterns, with tests covering the transformations.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- compilers, tooling
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100