<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/146179>146179</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[clang-tidy] Check request: performance-use-inline-constexpr-in-headers
</td>
</tr>
<tr>
<th>Labels</th>
<td>
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
denzor200
</td>
</tr>
</table>
<pre>
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).
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJycVMGOpDYQ_Rr3pQQypoHmwIGeGaQckki7IyXKJTKmACfGJi57Nr1fH5np2RnlECWRkFxGVa_8Xj1bEunFInasurLq8SRjWJ3vJrRfnRecn0Y33boHJq5MXIsGKC4LUiCIBGFF2B2RHrXR4QbBQSQEVnNtjbbIag7Opr1ylgL-ufv060V6LUeDxMQDjDHA7jF776DchKMkJGDi4vyxh2jlF-kR3Axh1QQ-GmSiBTcHtOA2HeC1J2gLK8oJPeXwnFKVtEDaoA3mBqNxMsCorfQaCaSdYJV-gx397PwmrUKYIiYqWzRB7waBbtvoDEw4a6uDdpZyxvsfECeQoFZUv6d0tLPz6j-wfz8pzNrgAcp4f30afvz0xMoUs5rfP94zMTAx3CvylfH-GyxoG-D7_udfP3_3yxOw8hEKLs6svMLfMXjfD89Pn_4N-l3O_9WEifR9Vm7H15DxPoN-300S3VlzeOU-pjTmfE1eyNd9TysGlTPRplAv1nltF8jVvr_rlMGz9AsG-md5F-NGaZgYrNyQdqkQKB0qtbQuwBytSgMF45Q0xESbfyTw03pL-B-8kSWK5fCB1DVZ6Qakvx6oHqeokGCKu9FKhjf3vGFn8CDVijDiKl-086lmxi_oIVXaSdrwKrm04aCw4eb87V59mrpyastWnrArmqrgDa8acVq7GkvR1NPcCl5yvFzmWTVjJYt2roqyqpuT7gQXFa_FhXPRliJvLvV4acZCFTiNE57ZmeMmtcmNedly55eTJorYFee6aNqTkSMaenskfJeysjEuxM7caAr0Xhd0MMdzooy0Sxb0dGPVIzwcF8XjHxEpsLL_eOWySJi9Gi77Ns1M2-xukVP0pltD2Ck597DqosMax1y5jYkh9b4v2e7db6gCE8NBgJgY7hxeOvFXAAAA__9AepER">