[libc-commits] [libc] [libc][docs] Fix docgen macro lookup for underscored headers (PR #194367)

Petter Berntsson via libc-commits libc-commits at lists.llvm.org
Mon Apr 27 06:31:32 PDT 2026


https://github.com/petbernt created https://github.com/llvm/llvm-project/pull/194367

While adding implementation status for nl_types.h, I noticed docgen resolves it to nl-types.h instead of nl_types.h. As a result, headers with underscores are not matched correctly and their implementation status is not marked.

This patch fixes the handling of underscored header names in docgen so they are processed consistently.

>From a1e12c0a20ef7e0c18d085e24042f1ebe22f599b Mon Sep 17 00:00:00 2001
From: Petter Berntsson <petter.berntsson at arm.com>
Date: Mon, 27 Apr 2026 14:04:05 +0100
Subject: [PATCH] [libc][docs] Fix docgen macro lookup for underscored headers

---
 libc/utils/docgen/header.py | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/libc/utils/docgen/header.py b/libc/utils/docgen/header.py
index 8885db42f0a5b..d43831eb48af8 100644
--- a/libc/utils/docgen/header.py
+++ b/libc/utils/docgen/header.py
@@ -112,5 +112,7 @@ def __get_macro_files(self) -> Generator[Path, None, None]:
         instead use a hyphen in the name.
         libc/include/llvm-libc-macros/sys-mman-macros.h
         """
-        stem = self.stem.replace("/", "-")
+        # Some POSIX headers use underscores in the header name but hyphens in
+        # the macro file name, e.g. nl_types.h -> nl-types-macros.h.
+        stem = self.stem.replace("/", "-").replace("_", "-")
         return self.macros_dir.glob(f"**/{stem}-macros.h")



More information about the libc-commits mailing list