[clang-tools-extra] [clang-tidy] add modernize-use-constexpr check (PR #162741)

Julian Schmidt via cfe-commits cfe-commits at lists.llvm.org
Wed Dec 3 14:09:41 PST 2025


5chmidti wrote:

> Will this recommend constexpr for arrays? What about globals?

@shafik Yes, this does support globals and arrays. Check out [this part of tests](https://github.com/llvm/llvm-project/blob/5c78e2a5e2cbd8357eab9fb524dba2f398da8543/clang-tools-extra/test/clang-tidy/checkers/modernize/use-constexpr.cpp#L316-L334) for some globals and arrays. For arrays, I am checking if the array type itself supports being used in a constexpr context, and each element in the initializing expression is also checked. E.g., in these tests there are functions called in the initializer list that are not constexpr and therefore the array can not be constexpr.

https://github.com/llvm/llvm-project/pull/162741


More information about the cfe-commits mailing list