[clang-tools-extra] [clang-tidy] Removed redundant-inline-specifier warning on static data members (PR #81423)

Félix-Antoine Constantin via cfe-commits cfe-commits at lists.llvm.org
Sun Feb 11 12:53:42 PST 2024


================
@@ -88,12 +91,14 @@ void RedundantInlineSpecifierCheck::registerMatchers(MatchFinder *Finder) {
         this);
 
   if (getLangOpts().CPlusPlus17) {
-    Finder->addMatcher(
-        varDecl(isInlineSpecified(),
-                anyOf(isInternalLinkage(StrictMode),
-                      allOf(isConstexpr(), hasAncestor(recordDecl()))))
-            .bind("var_decl"),
-        this);
+    const auto IsPartOfRecordDecl = hasAncestor(recordDecl());
+    Finder->addMatcher(varDecl(isInlineSpecified(),
+                               anyOf(allOf(isInternalLinkage(StrictMode),
+                                           unless(allOf(hasInitialization(),
----------------
felix642 wrote:

I thought about this, but I can't find an example where a class member would have the inline keyword and not be static.
If you look at the test case I added, the static keyword is required for the code to compile otherwise you will get a compilation error saying that inline can only appear on non-local variable (Which makes sense tbf).

Do you have an example in mind where the inline keyword is used on non-static class member? 

godbolt: https://godbolt.org/z/aEGGvs9Kc

https://github.com/llvm/llvm-project/pull/81423


More information about the cfe-commits mailing list