Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions clang-tools-extra/clang-tidy/llvmlibc/CalleeNamespaceCheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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`)")
<< FuncDecl;

diag(FuncDecl->getLocation(), "resolves to this declaration",
Expand Down