[libc-commits] [libc] [libc] Fix LLVM_LIBC_ADD_FUNCTION_C_ALIAS lint namespace error (PR #240751)

via libc-commits libc-commits at lists.llvm.org
Tue Nov 10 00:31:42 PST 2026


llvmorg-github-actions[bot] wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-libc

Author: Jeff Bailey (kaladron)

<details>
<summary>Changes</summary>

When LIBC_COPT_PUBLIC_PACKAGING is disabled, as in internal object targets linted by libc-lint, LLVM_LIBC_ADD_FUNCTION_C_ALIAS expanded to static_assert(true, "Require semicolon.").  Because callers place this macro at translation-unit scope outside LIBC_NAMESPACE_DECL, llvmlibc-implementation-in-namespace rejected the static_assert declaration in libc/src/errno/libc_errno.cpp and the scanf sources.

Replace that stub with an extern "C" type alias referring to LIBC_NAMESPACE::name.  ImplementationInNamespaceCheck already exempts extern "C" linkage specifications at file scope, the semicolon requirement is preserved, and the referenced internal symbol is still verified at compile time.

Assisted-by: Automated tooling, human reviewed.

---
Full diff: https://github.com/llvm/llvm-project/pull/240751.diff


1 Files Affected:

- (modified) libc/src/__support/common.h (+4-1) 


``````````diff
diff --git a/libc/src/__support/common.h b/libc/src/__support/common.h
index 8ad3d22aa4948..d1d52c3b50e61 100644
--- a/libc/src/__support/common.h
+++ b/libc/src/__support/common.h
@@ -87,8 +87,11 @@
 #define LLVM_LIBC_FUNCTION_IMPL_4(type, name, arglist, c_alias)                \
   type name arglist
 
+// Add an extra C alias `c_alias` for `LIBC_NAMESPACE::name` at file scope when
+// a function needs multiple exported names (omitted in non-packaging builds).
 #define LLVM_LIBC_ADD_FUNCTION_C_ALIAS(name, c_alias)                          \
-  static_assert(true, "Require semicolon.")
+  extern "C" using __llvm_libc_unused_alias_##c_alias =                        \
+      decltype(LIBC_NAMESPACE::name)
 
 #endif // LIBC_COPT_PUBLIC_PACKAGING
 

``````````

</details>


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


More information about the libc-commits mailing list