[clang-tools-extra] [clang-tidy] Add llvm-type-switch-case-types check (PR #177892)
Yanzuo Liu via cfe-commits
cfe-commits at lists.llvm.org
Mon Jan 26 07:15:46 PST 2026
zwuis wrote:
It would be nice to verify diagnostics with "note" level ("warning" level has been verified).
---
An idea about handling `auto`:
```diff
TypeSwitch<Pointer *>(base)
- .Case<T>([](auto x) { ... })
+ .Case([](T *x) { ... })
TypeSwitch<NonPointer>(base)
- .Case<T>([](auto x) { ... })
+ .Case([](T x) { ... })
```
Not sure how complex the implementation is so I'm ok with leaving this PR as is.
<details>
<summary>Two possible implementations</summary>
- Find the token `auto` using lexer facilities.
- Use `DeclaratorDecl::getTypeSourceInfo` and `TypeSourceInfo::getTypeLoc()`, then traverse `TypeLoc` to find `TemplateTypeParmTypeLoc` like traversing `ParamBaseType`.
</details>
https://github.com/llvm/llvm-project/pull/177892
More information about the cfe-commits
mailing list