================
@@ -82,11 +82,19 @@ static constexpr StringRef Message =
 
 void UseInternalLinkageCheck::check(const MatchFinder::MatchResult &Result) {
   if (const auto *FD = Result.Nodes.getNodeAs<FunctionDecl>("fn")) {
-    diag(FD->getLocation(), Message) << "function" << FD;
+    DiagnosticBuilder DB = diag(FD->getLocation(), Message) << "function" << 
FD;
+    SourceLocation FixLoc = FD->getTypeSpecStartLoc();
+    if (FixLoc.isInvalid() || FixLoc.isMacroID())
+      return;
+    DB << FixItHint::CreateInsertion(FixLoc, "static ");
     return;
   }
   if (const auto *VD = Result.Nodes.getNodeAs<VarDecl>("var")) {
-    diag(VD->getLocation(), Message) << "variable" << VD;
+    DiagnosticBuilder DB = diag(VD->getLocation(), Message) << "variable" << 
VD;
+    SourceLocation FixLoc = VD->getTypeSpecStartLoc();
+    if (FixLoc.isInvalid() || FixLoc.isMacroID())
+      return;
+    DB << FixItHint::CreateInsertion(FixLoc, "static ");
----------------
5chmidti wrote:

I think that this fix should be behind an option, so that projects that want to 
use anonymous namespaces have the choice to leave the option off or disable it 
(depending on the default).

https://github.com/llvm/llvm-project/pull/96203
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to