[clang-tools-extra] [clang-tidy][libc] Fix namespace check with macro (PR #68134)

Piotr Zegar via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 3 22:03:04 PDT 2023


================
@@ -45,18 +45,20 @@ void CalleeNamespaceCheck::check(const MatchFinder::MatchResult &Result) {
   if (FuncDecl->getBuiltinID() != 0)
     return;
 
-  // If the outermost namespace of the function is __llvm_libc, we're good.
+  // If the outermost namespace of the function starts with __llvm_libc, we're
+  // good.
   const auto *NS = dyn_cast<NamespaceDecl>(getOutermostNamespace(FuncDecl));
-  if (NS && NS->getName() == "__llvm_libc")
+  if (NS && NS->getName().starts_with("__llvm_libc"))
     return;
 
   const DeclarationName &Name = FuncDecl->getDeclName();
   if (Name.isIdentifier() &&
       IgnoredFunctions.contains(Name.getAsIdentifierInfo()->getName()))
     return;
 
-  diag(UsageSiteExpr->getBeginLoc(), "%0 must resolve to a function declared "
-                                     "within the '__llvm_libc' namespace")
+  diag(UsageSiteExpr->getBeginLoc(),
+       "%0 must resolve to a function declared "
+       "within the '__llvm_libc' namespace (use macro `LIBC_NAMESPACE`)")
----------------
PiotrZSL wrote:

Macro LIBC_NAMESPACE is not referenced in check documentation.

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


More information about the cfe-commits mailing list