[clang-tools-extra] [clang-tidy] add misc-constexpr check (PR #146553)
Julian Schmidt via cfe-commits
cfe-commits at lists.llvm.org
Tue Jul 1 09:25:28 PDT 2025
5chmidti wrote:
> > misc-use-constexpr? :)
>
> modernize-use-constexpr?
Hm. It is indeed also a modernization... +- on which to pick. Let's see what others think.
On one hand, the modernize checks have
- modernize-use-auto
- modernize-use-nodiscard
- modernize-use-noexcept
- modernize-use-override
- modernize-use-using
while the misc category has `misc-const-correctness`, which is also close to this check. Though, `constexpr` also provides additional benefits and not just modernization. It can provide additional safety checks if UB would be encountered at compile-time, e.g.,
```c++
constexpr int div(int a, int b) { return a / b; }
int main() {
constexpr auto res = div(10,0);
return 0;
}
```
, or potential performance improvements.
https://github.com/llvm/llvm-project/pull/146553
More information about the cfe-commits
mailing list