[PATCH] D18914: [clang-tidy] new readability-redundant-inline
Evgeny Shulgin via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sun Jan 16 12:23:56 PST 2022
Izaron added a comment.
In D18914#2399705 <https://reviews.llvm.org/D18914#2399705>, @chfast wrote:
> This check can be useful in other case like this:
>
> inline constexpr const int x = 1;
>
> where `inline` and `const` are redundant.
In your case `inline` is not actually redundant (at least for a global variable). `const` (therefore `constexpr`) means internal linkage, so every translation unit will just get itself an unique internal copy of this variable. We can see it if we print the address of `x` in different translation units. The addresses will be different without `inline` and the same with `inline`.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D18914/new/
https://reviews.llvm.org/D18914
More information about the cfe-commits
mailing list