[clang-tools-extra] [clang-tidy] Update llvmlibc-implementation-in-namespace to new rules (PR #66504)

Piotr Zegar via cfe-commits cfe-commits at lists.llvm.org
Mon Sep 18 08:29:24 PDT 2023


================
@@ -30,15 +32,18 @@ void ImplementationInNamespaceCheck::check(
     return;
 
   if (const auto *NS = dyn_cast<NamespaceDecl>(MatchedDecl)) {
-    if (NS->getName() != RequiredNamespace) {
-      diag(NS->getLocation(), "'%0' needs to be the outermost namespace")
-          << RequiredNamespace;
-    }
+    if (!Result.SourceManager->isMacroBodyExpansion(NS->getLocation()))
+      diag(NS->getLocation(),
+           "the outermost namespace should be the '%0' macro")
+          << RequiredNamespaceMacroName;
+    else if (!NS->getName().starts_with(RequiredNamespaceStart))
+      diag(NS->getLocation(), "the outermost namespace should start with '%0'")
+          << RequiredNamespaceStart;
     return;
   }
   diag(MatchedDecl->getLocation(),
----------------
PiotrZSL wrote:

This looks to be triggered even if declaration is declared with RequiredNamespaceStart.
I'm blind or i'm not see a check for a RequiredNamespaceStart .

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


More information about the cfe-commits mailing list