Issue |
146179
|
Summary |
[clang-tidy] Check request: performance-use-inline-constexpr-in-headers
|
Labels |
|
Assignees |
|
Reporter |
denzor200
|
C++17 suggests us the possibility to use `inline` on `constexpr` variables, but pre-C++17 codebases (or code unaware of this rule) often omit inline in headers. This can silently bloat binaries and harm performance due to multiple symbol definitions.
Need a check to enforce `inline` on `constexpr` variables in header files.
BEFORE:
```
// header.h
constexpr int MAX_SIZE = 1024;
```
AFTER:
```
// header.h
inline constexpr int MAX_SIZE = 1024;
```
**Scope**
- Applies only to headers (.h, .hpp, etc.), ignoring .cpp files.
- Targets `constexpr` variables in global/namespace scope (not function locals).
**Why `performance-`?**
- Binary size (reduces duplicate symbols).
- Cache behavior (fewer redundant constants in memory).
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs