[clang-tools-extra] [clang-tidy] Teach `misc-use-internal-linkage` to suggest giving classes internal linkage (PR #172797)

Victor Chernyakin via cfe-commits cfe-commits at lists.llvm.org
Wed Dec 17 22:10:33 PST 2025


================
@@ -113,27 +115,37 @@ void UseInternalLinkageCheck::registerMatchers(MatchFinder *Finder) {
       allOf(isFirstDecl(), isAllRedeclsInMainFile(HeaderFileExtensions),
             unless(anyOf(
                 // 1. internal linkage
-                isStaticStorageClass(), isInAnonymousNamespace(),
-                // 2. explicit external linkage
-                isExternStorageClass(), isExternC(),
-                // 3. template
-                isExplicitTemplateSpecialization(),
-                hasAncestor(decl(anyOf(
-                    // 4. friend
-                    friendDecl(),
-                    // 5. module export decl
-                    exportDecl()))))));
+                isInAnonymousNamespace(), hasAncestor(decl(anyOf(
+                                              // 2. friend
+                                              friendDecl(),
+                                              // 3. module export decl
+                                              exportDecl()))))));
----------------
localspook wrote:

I had to take some submatchers out of this `Common` matcher and inline them into the function and variable matchers because those submatcheres were invalid for classes.

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


More information about the cfe-commits mailing list