From 56fb8b7337b6512adb8dc7f5234f646a48852e9d Mon Sep 17 00:00:00 2001 From: prabhukr Date: Mon, 8 Jul 2024 15:18:10 -0700 Subject: [PATCH] [libc] Update libc namespace clang-tidy checks Namespace macro that should be used to declare a new namespace is updated from LIBC_NAMESPACE to LIBC_NAMESPACE_DECL which by default has hidden visibility (#97109). This commit updates the clang-tidy checks to match the new policy. --- .../clang-tidy/llvmlibc/ImplementationInNamespaceCheck.cpp | 6 +++--- clang-tools-extra/clang-tidy/llvmlibc/NamespaceConstants.h | 2 ++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/clang-tools-extra/clang-tidy/llvmlibc/ImplementationInNamespaceCheck.cpp b/clang-tools-extra/clang-tidy/llvmlibc/ImplementationInNamespaceCheck.cpp index ae9819ed97502e..ed9f020e45083d 100644 --- a/clang-tools-extra/clang-tidy/llvmlibc/ImplementationInNamespaceCheck.cpp +++ b/clang-tools-extra/clang-tidy/llvmlibc/ImplementationInNamespaceCheck.cpp @@ -33,17 +33,17 @@ void ImplementationInNamespaceCheck::check( if (NS == nullptr || NS->isAnonymousNamespace()) { diag(MatchedDecl->getLocation(), "declaration must be enclosed within the '%0' namespace") - << RequiredNamespaceMacroName; + << RequiredNamespaceHiddenMacroName; return; } if (Result.SourceManager->isMacroBodyExpansion(NS->getLocation()) == false) { diag(NS->getLocation(), "the outermost namespace should be the '%0' macro") - << RequiredNamespaceMacroName; + << RequiredNamespaceHiddenMacroName; return; } if (NS->getName().starts_with(RequiredNamespaceStart) == false) { diag(NS->getLocation(), "the '%0' macro should start with '%1'") - << RequiredNamespaceMacroName << RequiredNamespaceStart; + << RequiredNamespaceHiddenMacroName << RequiredNamespaceStart; return; } } diff --git a/clang-tools-extra/clang-tidy/llvmlibc/NamespaceConstants.h b/clang-tools-extra/clang-tidy/llvmlibc/NamespaceConstants.h index 7d4120085b8667..9f569e84950b7f 100644 --- a/clang-tools-extra/clang-tidy/llvmlibc/NamespaceConstants.h +++ b/clang-tools-extra/clang-tidy/llvmlibc/NamespaceConstants.h @@ -11,6 +11,8 @@ namespace clang::tidy::llvm_libc { const static llvm::StringRef RequiredNamespaceStart = "__llvm_libc"; +const static llvm::StringRef RequiredNamespaceHiddenMacroName = + "LIBC_NAMESPACE_DECL"; const static llvm::StringRef RequiredNamespaceMacroName = "LIBC_NAMESPACE"; } // namespace clang::tidy::llvm_libc