"inline constexpr" and "inline consteval" function declarations are redundant and shall be written rather as "constexpr" and "consteval".
Diff Detail
- Repository
- rG LLVM Github Monorepo
Unit Tests
Event Timeline
I will provide more context in this comment.
Why this patch?
Clang currently has a warning for duplicating specifiers (inline inline, extern extern, consteval consteval, etc.), but has no warnings for redundant weaker specifiers.
I suggest to add such a group of warnings, starting from inline constexpr/inline consteval functions.
The Standard says (dcl.constexpr) that constexpr/consteval functions are implicitly inline. But Clang doesn't tell programmers that.
The volume of affected code can be seen in GitHub Search: inline constexpr, inline consteval.
What about the other meaning of inline?
Some years ago, the inline keyword meant not only "there may be multiple definitions", but also "there will be inlinehint attribute added in LLVM IR".
Fortunately, this is no more since Clang 3.3 release.
constexpr and inline constexpr functions emit the same LLVM IR attributes. (consteval function aren't even emitted to LLVM IR, executing exclusively at compile-time)
I don't remember if this is written up anywhere, but clang has a longstanding policy that style enforcement belongs in a linter rather than the compiler. One programmer's "redundant" is another programmer's "clear and explicit". I don't think this warning is consistent with that.
clang/test/Headers/x86-intrinsics-headers-clean.cpp | ||
---|---|---|
4–5 | Honestly I have a doubt for this "fix" (just ignoring the new diagnostic), but I couldn't change the included file. |
Thanks, didn't know this. Hope I'll make it to clang-tidy then.
(There was an abandoned review back in time when "inline" meant "inlinehint" for LLVM IR. https://reviews.llvm.org/D18914)
Honestly I have a doubt for this "fix" (just ignoring the new diagnostic), but I couldn't change the included file.