[libc-commits] [libc] [libc] Establish clean baseline for implementation-in-namespace (PR #231639)

Jeff Bailey via libc-commits libc-commits at lists.llvm.org
Tue Oct 13 12:58:49 PDT 2026


https://github.com/kaladron created https://github.com/llvm/llvm-project/pull/231639

Scope libc/src/.clang-tidy down to llvmlibc-implementation-in-namespace with WarningsAsErrors to establish a 100% green baseline.

Add NOLINT comments to replaceable global allocation functions in new.cpp which must reside in the global namespace. Disable default clang-analyzer checks in libc/.clang-tidy with a leading '-*'.

Assisted-by: Automated tooling, human reviewed.

>From 6a5c7af5e8daec3f76400309cc71de06d4a3997a Mon Sep 17 00:00:00 2001
From: Jeff Bailey <jbailey at raspberryginger.com>
Date: Tue, 13 Oct 2026 15:46:42 +0100
Subject: [PATCH] [libc] Establish clean baseline for
 implementation-in-namespace

Scope libc/src/.clang-tidy down to llvmlibc-implementation-in-namespace
with WarningsAsErrors to establish a 100% green baseline.

Add NOLINT comments to replaceable global allocation functions in
new.cpp which must reside in the global namespace. Disable default
clang-analyzer checks in libc/.clang-tidy with a leading '-*'.

Assisted-by: Automated tooling, human reviewed.
---
 libc/.clang-tidy               |  2 +-
 libc/src/.clang-tidy           |  7 ++-----
 libc/src/__support/CPP/new.cpp | 10 +++++++++-
 3 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/libc/.clang-tidy b/libc/.clang-tidy
index dbde88928ee636..1b10533953f265 100644
--- a/libc/.clang-tidy
+++ b/libc/.clang-tidy
@@ -1,5 +1,5 @@
 InheritParentConfig: false
-Checks: 'readability-identifier-naming'
+Checks: '-*,readability-identifier-naming'
 HeaderFilterRegex: '.*'
 CheckOptions:
   - key:             readability-identifier-naming.ClassCase
diff --git a/libc/src/.clang-tidy b/libc/src/.clang-tidy
index 1c79b1cf6aae6f..e38038fa826eeb 100644
--- a/libc/src/.clang-tidy
+++ b/libc/src/.clang-tidy
@@ -1,7 +1,4 @@
 InheritParentConfig: true
-Checks: '-*,llvmlibc-*,readability-identifier-naming,llvm-header-guard'
+Checks: '-*,llvmlibc-implementation-in-namespace'
 HeaderFilterRegex: '.*'
-WarningsAsErrors: 'llvmlibc-*'
-CheckOptions:
-  - key:             llvmlibc-restrict-system-libc-headers.Includes
-    value:           '-*, linux/*, asm/*.h, asm-generic/*.h'
+WarningsAsErrors: '*'
diff --git a/libc/src/__support/CPP/new.cpp b/libc/src/__support/CPP/new.cpp
index 65f80de3734851..345811181878be 100644
--- a/libc/src/__support/CPP/new.cpp
+++ b/libc/src/__support/CPP/new.cpp
@@ -8,13 +8,17 @@
 
 #include "new.h"
 #include "hdr/func/free.h"
-
+// Replaceable global allocation functions must live in the global namespace.
+// NOLINTNEXTLINE(llvmlibc-implementation-in-namespace): global namespace
 void operator delete(void *mem) noexcept { ::free(mem); }
 
+// NOLINTNEXTLINE(llvmlibc-implementation-in-namespace): global namespace
 void operator delete(void *mem, std::align_val_t) noexcept { ::free(mem); }
 
+// NOLINTNEXTLINE(llvmlibc-implementation-in-namespace): global namespace
 void operator delete(void *mem, size_t) noexcept { ::free(mem); }
 
+// NOLINTNEXTLINE(llvmlibc-implementation-in-namespace): global namespace
 void operator delete(void *mem, size_t, std::align_val_t) noexcept {
 #ifdef LIBC_TARGET_OS_IS_WINDOWS
   ::_aligned_free(mem);
@@ -23,8 +27,10 @@ void operator delete(void *mem, size_t, std::align_val_t) noexcept {
 #endif
 }
 
+// NOLINTNEXTLINE(llvmlibc-implementation-in-namespace): global namespace
 void operator delete[](void *mem) noexcept { ::free(mem); }
 
+// NOLINTNEXTLINE(llvmlibc-implementation-in-namespace): global namespace
 void operator delete[](void *mem, std::align_val_t) noexcept {
 #ifdef LIBC_TARGET_OS_IS_WINDOWS
   ::_aligned_free(mem);
@@ -33,8 +39,10 @@ void operator delete[](void *mem, std::align_val_t) noexcept {
 #endif
 }
 
+// NOLINTNEXTLINE(llvmlibc-implementation-in-namespace): global namespace
 void operator delete[](void *mem, size_t) noexcept { ::free(mem); }
 
+// NOLINTNEXTLINE(llvmlibc-implementation-in-namespace): global namespace
 void operator delete[](void *mem, size_t, std::align_val_t) noexcept {
 #ifdef LIBC_TARGET_OS_IS_WINDOWS
   ::_aligned_free(mem);



More information about the libc-commits mailing list