Skip to content

Commit

Permalink
[libc] Update libc namespace clang-tidy checks
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Prabhuk committed Jul 8, 2024
1 parent 97dc508 commit 56fb8b7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down
2 changes: 2 additions & 0 deletions clang-tools-extra/clang-tidy/llvmlibc/NamespaceConstants.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 56fb8b7

Please sign in to comment.