llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
29.24k stars 12.07k forks source link

[clang-tidy] suggest adding `constexpr` when it is possible #115622

Open 5chmidti opened 1 week ago

5chmidti commented 1 week ago

Add a check to suggest adding constexpr to variables and functions to the extent that each standard version allows. Using constexpr can, e.g., potentially uncover UB in code, as that is not permitted in a constexpr context.

I'm refactoring my prototype that ran successfully on the clang and clang-tools-extra targets (using a more restrictive mode than the standard permits) with working fixits. I need to finish the implementation, add more tests, and evaluate the check against some code-bases before posting the PR though.

llvmbot commented 1 week ago

@llvm/issue-subscribers-clang-tidy

Author: Julian Schmidt (5chmidti)

Add a check to suggest adding `constexpr` to variables and functions to the extent that each standard version allows. Using `constexpr` can, e.g., potentially uncover UB in code, as that is not permitted in a `constexpr` context. I'm refactoring my prototype that ran successfully on the `clang` and `clang-tools-extra` targets (using a more restrictive mode than the standard permits) with working fixits. I need to finish the implementation, add more tests, and evaluate the check against some code-bases before posting the PR though.