[clang-tools-extra] [libc] Update libc namespace clang-tidy checks (PR #98088)
via cfe-commits
cfe-commits at lists.llvm.org
Mon Jul 8 15:28:57 PDT 2024
https://github.com/Prabhuk created https://github.com/llvm/llvm-project/pull/98088
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.
>From 56fb8b7337b6512adb8dc7f5234f646a48852e9d Mon Sep 17 00:00:00 2001
From: prabhukr <prabhukr at google.com>
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 ae9819ed97502..ed9f020e45083 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 7d4120085b866..9f569e84950b7 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
More information about the cfe-commits
mailing list