[libc-commits] [libc] b53e4ee - [libc][docs] Distinguish experimental-gated symbols (#242078)

via libc-commits libc-commits at lists.llvm.org
Thu Nov 12 14:48:59 PST 2026


Author: Jeff Bailey
Date: 2026-11-12T22:48:54Z
New Revision: b53e4eea1879c9a117296b1cf3c1b1c794aa4132

URL: https://github.com/llvm/llvm-project/commit/b53e4eea1879c9a117296b1cf3c1b1c794aa4132
DIFF: https://github.com/llvm/llvm-project/commit/b53e4eea1879c9a117296b1cf3c1b1c794aa4132.diff

LOG: [libc][docs] Distinguish experimental-gated symbols (#242078)

Entrypoints and public headers guarded by
LLVM_LIBC_ENABLE_EXPERIMENTAL_ENTRYPOINTS are disabled in default builds
because their implementations are incomplete, and several placeholder
source files (fnmatch, strptime, swprintf, tzset) omit a TODO comment
while returning dummy values. Counting them alongside production
entrypoints overstates default standard coverage.

Track conditional blocks across entrypoints.txt and headers.txt in
Header so experimental functions, global variables, and header-gated
macros and types report experimental status separately from default
completion percentages, render amber Experimental badges, stacked
progress bar segments, and dashboard filter controls, and classify no-op
placeholder functions as unimplemented stubs.

Assisted-by: Automated tooling, human reviewed.

Added: 
    

Modified: 
    libc/docs/_static/status.css
    libc/docs/_static/status.js
    libc/utils/docgen/docgen.py
    libc/utils/docgen/docgen_test.py
    libc/utils/docgen/header.py

Removed: 
    


################################################################################
diff  --git a/libc/docs/_static/status.css b/libc/docs/_static/status.css
index dc8e400d4688e..c3b9d556f5a31 100644
--- a/libc/docs/_static/status.css
+++ b/libc/docs/_static/status.css
@@ -191,7 +191,8 @@ body[data-theme="dark"] {
   padding: 7px 8px;
 }
 
-.hc-status-ulp {
+.hc-status-ulp,
+.hc-status-exp {
   display: inline-flex;
   align-items: center;
   justify-content: center;
@@ -206,6 +207,12 @@ body[data-theme="dark"] {
   border: 1px solid var(--hc-green-border);
 }
 
+.hc-status-exp {
+  background: var(--hc-amber-bg);
+  color: var(--hc-amber-text);
+  border-color: var(--hc-amber-border);
+}
+
 .hc-status-na {
   font-size: 0.74rem;
   font-weight: 500;
@@ -234,14 +241,18 @@ body[data-theme="dark"] {
 .hc-pill { display: inline-block; font-size: 0.74rem; font-weight: 600; line-height: 1.35; padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
 .hc-pill-c23 { background: var(--hc-blue-bg); color: var(--hc-blue-text); border: 1px solid var(--hc-blue-border); }
 .hc-pill-posix { background: var(--hc-green-bg); color: var(--hc-green-text); border: 1px solid var(--hc-green-border); }
+.hc-pill-exp { background: var(--hc-amber-bg); color: var(--hc-amber-text); border: 1px solid var(--hc-amber-border); }
 .hc-pill-ext { background: var(--color-background-primary, #fff); color: var(--color-foreground-secondary, #57606a); border: 1px solid var(--color-background-border, #d0d7de); }
 .hc-overall-stat { font-size: 0.95rem; font-weight: 700; color: var(--color-foreground-primary, #24292f); }
-.hc-progress-track { background: var(--hc-track-bg); border-radius: 999px; height: 6px; overflow: hidden; }
+.hc-exp-note { font-size: 0.78em; font-weight: 600; color: var(--hc-amber-text); }
+.hc-progress-track { display: flex; background: var(--hc-track-bg); border-radius: 999px; height: 6px; overflow: hidden; }
 .hc-progress-lg { height: 10px; }
-.hc-progress-fill { height: 100%; border-radius: 999px; }
+.hc-progress-fill { height: 100%; }
+.hc-progress-exp { background: var(--hc-amber-text); opacity: 0.85; }
 @media (forced-colors: active) {
   .hc-progress-track { border: 1px solid CanvasText; }
   .hc-progress-fill { background: Highlight !important; }
+  .hc-progress-exp { background: GrayText !important; }
 }
 .hc-grid-cards, .hc-grid-prec { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; margin-top: 14px; }
 .hc-grid-prec { grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 8px; margin-top: 0; }
@@ -255,6 +266,7 @@ body[data-theme="dark"] {
 .hc-std-title { font-size: 0.95rem; font-weight: 600; color: var(--color-foreground-muted, #57606a); }
 .hc-std-val { font-size: 1.85rem; font-weight: 700; margin: 4px 0 8px 0; }
 .hc-std-val span { font-size: 0.52em; font-weight: 500; color: var(--color-foreground-muted, #57606a); }
+.hc-std-val .hc-exp-note { color: var(--hc-amber-text); font-weight: 600; }
 .hc-headers-list { display: flex; flex-direction: column; gap: 8px; margin: 14px 0 24px 0; }
 .header-card { border: 1px solid var(--color-background-border, #e1e4e8); border-radius: 6px; background: var(--color-background-secondary, #f6f8fa); }
 .header-card > summary { list-style: none; display: flex; align-items: center; justify-content: space-between; padding: 9px 14px; gap: 12px; user-select: none; }
@@ -267,7 +279,7 @@ body[data-theme="dark"] {
 .hc-thermometer-col { flex: 1; min-width: 140px; display: flex; align-items: center; gap: 10px; }
 .hc-thermometer-col .hc-progress-track { flex: 1; height: 10px; }
 .hc-row-pct { font-size: 0.85rem; font-weight: 700; width: 48px; text-align: right; }
-.hc-row-frac { font-size: 0.78rem; color: var(--color-foreground-muted, #57606a); width: 64px; text-align: right; }
+.hc-row-frac { font-size: 0.78rem; color: var(--color-foreground-muted, #57606a); min-width: 64px; text-align: right; white-space: nowrap; }
 .hc-action-col { display: flex; align-items: center; flex-shrink: 0; }
 .hc-page-link { display: inline-flex; align-items: center; gap: 3px; padding: 3px 8px; border: 1px solid var(--color-background-border, #d0d7de); border-radius: 4px; font-size: 0.76rem; font-weight: 500; text-decoration: none; color: var(--color-foreground-secondary, #57606a); background: var(--color-background-primary, #fff); white-space: nowrap; }
 .hc-page-link:hover { border-color: var(--hc-blue-border); color: var(--hc-blue-text); text-decoration: none; }
@@ -290,10 +302,11 @@ body[data-theme="dark"] .hc-toggle-btn[aria-pressed="true"] { color: #0d1117; }
 .hc-drawer-prec { margin-bottom: 12px; }
 .hc-chip-row { margin: 8px 0; font-size: 0.8rem; line-height: 1.7; }
 .hc-chip-lbl { font-weight: 700; margin-right: 4px; }
-.hc-chip-missing, .hc-chip-impl { display: inline-block; border-radius: 4px; padding: 1px 6px; margin: 2px; font-family: var(--font-stack--monospace, monospace); font-size: 0.75rem; text-decoration: none; line-height: 1.4; }
-.hc-chip-missing { background: var(--hc-amber-bg); border: 1px solid var(--hc-amber-border); color: var(--hc-amber-text); }
+.hc-chip-missing, .hc-chip-exp, .hc-chip-impl { display: inline-block; border-radius: 4px; padding: 1px 6px; margin: 2px; font-family: var(--font-stack--monospace, monospace); font-size: 0.75rem; text-decoration: none; line-height: 1.4; }
+.hc-chip-exp { background: var(--hc-amber-bg); border: 1px solid var(--hc-amber-border); color: var(--hc-amber-text); }
+.hc-chip-missing { background: var(--color-background-secondary, #f6f8fa); border: 1px solid var(--color-background-border, #d0d7de); color: var(--hc-muted-text); }
 .hc-chip-impl { background: var(--hc-green-bg); border: 1px solid var(--hc-green-border); color: var(--hc-green-text); }
-a.hc-chip-missing:hover, a.hc-chip-impl:hover { text-decoration: underline; }
+a.hc-chip-missing:hover, a.hc-chip-exp:hover, a.hc-chip-impl:hover { text-decoration: underline; }
 .hc-chip-more { font-size: 0.76rem; color: var(--color-foreground-muted, #57606a); margin-left: 4px; }
 .hc-drawer-foot { margin-top: 10px; text-align: right; }
 @media (max-width: 640px) {

diff  --git a/libc/docs/_static/status.js b/libc/docs/_static/status.js
index 43d1e178b21e5..c5d50f0185170 100644
--- a/libc/docs/_static/status.js
+++ b/libc/docs/_static/status.js
@@ -19,11 +19,14 @@ function filterHeaders() {
     const stem = (card.dataset.stem || "").toLowerCase();
     const stds = (card.dataset.standard || "").split(" ");
     const status = card.dataset.status || "";
+    const hasExp = card.dataset.experimental === "true";
     const syms = (card.dataset.symbols || "").toLowerCase();
     const matchQ = !query || name.includes(query) || stem.includes(query) ||
                    syms.includes(query);
     const matchStd = currentStd === "all" || stds.includes(currentStd);
-    const matchStatus = currentStatus === "all" || status === currentStatus;
+    const matchStatus =
+        currentStatus === "all" ||
+        (currentStatus === "experimental" ? hasExp : status === currentStatus);
     const show = matchQ && matchStd && matchStatus;
     card.style.display = show ? "" : "none";
     if (show)

diff  --git a/libc/utils/docgen/docgen.py b/libc/utils/docgen/docgen.py
index e1a98267732c0..5e06502af690f 100755
--- a/libc/utils/docgen/docgen.py
+++ b/libc/utils/docgen/docgen.py
@@ -85,7 +85,7 @@ def check_api(header: Header, api: Dict):
 
     if "macros" in api and (
         not header.macro_file_exists()
-        and not any(header.implements_macro(m) for m in api["macros"])
+        and not any(header.macro_status(m) != "missing" for m in api["macros"])
     ):
         print(
             f"warning: Macro definitions are listed for {header.name}, "
@@ -97,7 +97,7 @@ def check_api(header: Header, api: Dict):
 
     if "functions" in api and (
         not header.fns_dir_exists()
-        and not any(header.implements_fn(f) for f in api["functions"])
+        and not any(header.fn_status(f) != "missing" for f in api["functions"])
     ):
         print(
             f"warning: Function definitions are listed for {header.name}, "
@@ -136,9 +136,9 @@ def check_api(header: Header, api: Dict):
         raise DocgenAPIFormatError("\n".join(errors))
 
 
-def _status_badge_html(implemented: bool, accuracy: str = "", symbol: str = "") -> str:
+def _status_badge_html(status: str, accuracy: str = "", symbol: str = "") -> str:
     prefix = f"{html.escape(symbol, quote=True)}: " if symbol else ""
-    if implemented:
+    if status == "implemented":
         if accuracy:
             esc_acc = html.escape(accuracy)
             return (
@@ -150,6 +150,12 @@ def _status_badge_html(implemented: bool, accuracy: str = "", symbol: str = "")
             '<span aria-hidden="true">✓</span>'
             '<span class="hc-sr-only">Implemented</span></span>'
         )
+    if status == "experimental":
+        return (
+            f'<span class="hc-status-exp" title="{prefix}Experimental '
+            '(requires -DLLVM_LIBC_ENABLE_EXPERIMENTAL_ENTRYPOINTS=ON)">'
+            "Experimental</span>"
+        )
     return (
         f'<span class="hc-status-no" title="{prefix}Not Implemented">'
         '<span aria-hidden="true">–</span>'
@@ -251,7 +257,7 @@ def print_symbol_table_md(
     section_title: str,
     col_label: str,
     items: Dict,
-    is_implemented_fn: Callable[[str], bool],
+    status_fn: Callable[[str], str],
     kind: str,
     api: Optional[Dict] = None,
 ):
@@ -267,7 +273,7 @@ def print_symbol_table_md(
     for name in sorted(items.keys()):
         obj = items[name] or {}
         row_id = html.escape(f"{kind}-{name.replace(' ', '-')}", quote=True)
-        status = _status_badge_html(is_implemented_fn(name))
+        status = _status_badge_html(status_fn(name))
         c_sec = _c_section_html(header, name, kind, obj, api)
         posix = _posix_link_html(header, name, kind, obj)
         print(
@@ -326,7 +332,7 @@ def print_families_md(header: Header, api: Dict):
                     )
                 else:
                     badge = _status_badge_html(
-                        v_info["implemented"],
+                        v_info["status"],
                         v_info["accuracy"],
                         v_info["symbol"],
                     )
@@ -350,32 +356,52 @@ def _tone(pct: float) -> str:
     return "blue" if pct >= 50.0 else ("amber" if pct > 0.0 else "muted")
 
 
-def _progress_bar_html(pct: float, label: str, tone: str, extra_cls: str = "") -> str:
+def _progress_bar_html(
+    pct: float, label: str, tone: str, extra_cls: str = "", exp_pct: float = 0.0
+) -> str:
     cls = f"hc-progress-track {extra_cls}".strip()
     esc = html.escape(label, quote=True)
+    exp_seg = (
+        f'<div class="hc-progress-fill hc-progress-exp" style="width:{exp_pct:.1f}%">'
+        "</div>"
+        if exp_pct > 0
+        else ""
+    )
     return (
         f'<div class="{cls}" role="progressbar" aria-label="{esc}" '
         f'aria-valuenow="{pct:.1f}" aria-valuemin="0" aria-valuemax="100">'
         f'<div class="hc-progress-fill" '
-        f'style="background:var(--hc-{tone}-text);width:{pct:.1f}%"></div></div>'
+        f'style="background:var(--hc-{tone}-text);width:{pct:.1f}%"></div>'
+        f"{exp_seg}</div>"
     )
 
 
-def _mini_card_html(scope: str, title: str, imp: int, tot: int, tone: str = "") -> str:
+def _mini_card_html(
+    scope: str, title: str, imp: int, tot: int, tone: str = "", exp: int = 0
+) -> str:
     pct = (imp / tot * 100.0) if tot else 0.0
+    exp_pct = (exp / tot * 100.0) if tot else 0.0
     t = tone or _tone(pct)
-    bar = _progress_bar_html(pct, f"{scope} {title} completion", t)
+    bar = _progress_bar_html(pct, f"{scope} {title} completion", t, exp_pct=exp_pct)
+    exp_note = f' <span class="hc-exp-note">+{exp:,} exp</span>' if exp else ""
     return (
         f'<div class="hc-mini-card"><div class="hc-mini-title">'
         f"{html.escape(title)}</div>"
         f'<div class="hc-mini-val">{imp:,} / {tot:,} '
-        f'<span style="color:var(--hc-{t}-text)">({pct:.1f}%)</span></div>{bar}</div>'
+        f'<span style="color:var(--hc-{t}-text)">({pct:.1f}%)</span>{exp_note}</div>'
+        f"{bar}</div>"
     )
 
 
 def _precision_grid_html(header_name: str, precisions: List[Dict]) -> str:
     cards = "".join(
-        _mini_card_html(header_name, p["label"], p["implemented"], p["total"])
+        _mini_card_html(
+            header_name,
+            p["label"],
+            p["implemented"],
+            p["total"],
+            exp=p.get("experimental", 0),
+        )
         for p in precisions
     )
     return f'<div class="hc-grid-prec">{cards}</div>'
@@ -398,21 +424,35 @@ def _header_pills_html(stats: Dict, short: bool = False) -> str:
         else:
             lbl = "Ext" if short else "Extension Header"
         pills.append(f'<span class="hc-pill hc-pill-ext">{lbl}</span>')
+    if stats.get("experimental_header"):
+        lbl = "Exp" if short else "Experimental"
+        pills.append(
+            '<span class="hc-pill hc-pill-exp" '
+            'title="Requires -DLLVM_LIBC_ENABLE_EXPERIMENTAL_ENTRYPOINTS=ON">'
+            f"{lbl}</span>"
+        )
     return "".join(pills)
 
 
 def print_summary_card(header: Header, api: Dict):
     stats = header.get_summary_stats(api)
-    imp, tot = stats["overall"]["implemented"], stats["overall"]["total"]
+    ov = stats["overall"]
+    imp, tot, exp = ov["implemented"], ov["total"], ov["experimental"]
     if not tot:
         return
     pct = imp / tot * 100.0
+    exp_pct = exp / tot * 100.0
     tone = _tone(pct)
     pills_html = _header_pills_html(stats)
 
     cards = "".join(
         _mini_card_html(
-            header.name, title, stats[k]["implemented"], stats[k]["total"], c
+            header.name,
+            title,
+            stats[k]["implemented"],
+            stats[k]["total"],
+            c,
+            stats[k]["experimental"],
         )
         for k, title, c in (
             ("c23", "C23 Standard", "green"),
@@ -427,14 +467,22 @@ def print_summary_card(header: Header, api: Dict):
         if stats[k]["total"]
     )
     overall_bar = _progress_bar_html(
-        pct, f"{header.name} overall implementation progress", tone, "hc-progress-lg"
+        pct,
+        f"{header.name} overall implementation progress",
+        tone,
+        "hc-progress-lg",
+        exp_pct,
+    )
+    exp_note = (
+        f' <span class="hc-exp-note">(+{exp:,} experimental)</span>' if exp else ""
     )
     print(
         "```{raw} html\n"
         f'<div class="hc-card"><div class="hc-summary-top">'
         f'<div class="hc-pill-row">{pills_html}</div>'
         f'<div class="hc-overall-stat">{imp:,} / {tot:,} '
-        f'<span style="color:var(--hc-{tone}-text)">({pct:.1f}%)</span></div></div>'
+        f'<span style="color:var(--hc-{tone}-text)">({pct:.1f}%)</span>'
+        f"{exp_note}</div></div>"
         f'{overall_bar}<div class="hc-grid-cards">{cards}</div></div>'
     )
     if stats["precisions"]:
@@ -455,13 +503,7 @@ def print_header_status_md(header: Header, api: Dict):
 
     if api.get("types"):
         print_symbol_table_md(
-            header,
-            "Types",
-            "Type",
-            api["types"],
-            header.implements_type,
-            "type",
-            api,
+            header, "Types", "Type", api["types"], header.type_status, "type", api
         )
 
     if api.get("objects"):
@@ -470,20 +512,14 @@ def print_header_status_md(header: Header, api: Dict):
             "Global Variables",
             "Global Variable",
             api["objects"],
-            header.implements_object,
+            header.object_status,
             "object",
             api,
         )
 
     if api.get("macros"):
         print_symbol_table_md(
-            header,
-            "Macros",
-            "Macro",
-            api["macros"],
-            header.implements_macro,
-            "macro",
-            api,
+            header, "Macros", "Macro", api["macros"], header.macro_status, "macro", api
         )
 
     if api.get("functions"):
@@ -492,7 +528,7 @@ def print_header_status_md(header: Header, api: Dict):
             "Functions",
             "Function",
             api["functions"],
-            header.implements_fn,
+            header.fn_status,
             "function",
             api,
         )
@@ -511,20 +547,29 @@ def get_choices() -> list:
     return sorted(choices)
 
 
-def _std_card_html(title: str, imp: int, tot: int, tone: str) -> str:
+def _std_card_html(title: str, imp: int, tot: int, exp: int, tone: str) -> str:
     pct = (imp / tot * 100.0) if tot else 0.0
-    bar = _progress_bar_html(pct, title, tone, "hc-progress-lg")
+    exp_pct = (exp / tot * 100.0) if tot else 0.0
+    bar = _progress_bar_html(pct, title, tone, "hc-progress-lg", exp_pct)
+    exp_note = (
+        f' <span class="hc-exp-note">(+{exp:,} experimental)</span>' if exp else ""
+    )
     return (
         f'<div class="hc-card"><div class="hc-std-title">{title}</div>'
         f'<div class="hc-std-val" style="color:var(--hc-{tone}-text)">'
-        f"{pct:.1f}% <span>({imp:,} / {tot:,})</span></div>{bar}</div>"
+        f"{pct:.1f}% <span>({imp:,} / {tot:,})</span>{exp_note}</div>{bar}</div>"
     )
 
 
 def _chip_html(
-    header: Header, api: Dict, name: str, kind: str, item: Dict, is_missing: bool
+    header: Header, api: Dict, name: str, kind: str, item: Dict, status: str
 ) -> str:
-    cls = "hc-chip-missing" if is_missing else "hc-chip-impl"
+    cls_map = {
+        "implemented": "hc-chip-impl",
+        "experimental": "hc-chip-exp",
+        "missing": "hc-chip-missing",
+    }
+    cls = cls_map[status]
     esc = html.escape(name)
     cdef = str(item.get("c-definition") or "")
     url, title = "", ""
@@ -534,6 +579,11 @@ def _chip_html(
     if not url:
         url = posix_url(header, name, kind, item)
         title = f"{name} in POSIX"
+    if status == "experimental":
+        suffix = (
+            " (Experimental: requires -DLLVM_LIBC_ENABLE_EXPERIMENTAL_ENTRYPOINTS=ON)"
+        )
+        title = (title or name) + suffix
     if url:
         href = html.escape(url, quote=True)
         esc_t = html.escape(title, quote=True)
@@ -541,16 +591,20 @@ def _chip_html(
             f'<a class="{cls}" href="{href}" target="_blank" rel="noopener" '
             f'title="{esc_t}">{esc}</a>'
         )
+    if title:
+        return (
+            f'<span class="{cls}" title="{html.escape(title, quote=True)}">{esc}</span>'
+        )
     return f'<span class="{cls}">{esc}</span>'
 
 
 def _chip_group_html(
-    header: Header, api: Dict, entries: List, label: str, tone: str, is_missing: bool
+    header: Header, api: Dict, entries: List, label: str, tone: str, status: str
 ) -> str:
     if not entries:
         return ""
     chips = "".join(
-        _chip_html(header, api, n, k, it, is_missing) for n, k, it in entries[:16]
+        _chip_html(header, api, n, k, it, status) for n, k, it in entries[:16]
     )
     rem = len(entries) - 16
     more = f'<span class="hc-chip-more">+{rem} more...</span>' if rem > 0 else ""
@@ -581,6 +635,7 @@ def _toolbar_html(total_headers: int) -> str:
             ("all", "All"),
             ("complete", "Complete (100%)"),
             ("inprogress", "In Progress (1\u201399%)"),
+            ("experimental", "Experimental"),
             ("planned", "Planned (0%)"),
         )
     )
@@ -620,7 +675,7 @@ def _toolbar_html(total_headers: int) -> str:
 def generate_index_md():
     headers_data = []
     totals = {
-        k: [0, 0]
+        k: [0, 0, 0]
         for k in ("c23", "posix_spec", "functions", "macros", "types", "objects")
     }
     for hname in get_choices():
@@ -628,9 +683,10 @@ def generate_index_md():
         check_api(hdr, hdr.api)
         stats = hdr.get_summary_stats(hdr.api)
         headers_data.append((hdr, hdr.api, stats))
-        for k, pair in totals.items():
-            pair[0] += stats[k]["implemented"]
-            pair[1] += stats[k]["total"]
+        for k, triple in totals.items():
+            triple[0] += stats[k]["implemented"]
+            triple[1] += stats[k]["total"]
+            triple[2] += stats[k]["experimental"]
 
     n_c23 = sum(1 for _, _, s in headers_data if s["standard"] == "c23")
     n_posix = sum(1 for _, _, s in headers_data if s["posix"] == "posix-2024")
@@ -639,7 +695,9 @@ def generate_index_md():
         "POSIX.1-2024 Completeness", *totals["posix_spec"], "blue"
     )
     cat_cards = "".join(
-        _mini_card_html("Overall", title, *totals[k], tone)
+        _mini_card_html(
+            "Overall", title, totals[k][0], totals[k][1], tone, totals[k][2]
+        )
         for k, title, tone in (
             ("functions", "Functions", "green"),
             ("macros", "Macros", "blue"),
@@ -652,23 +710,28 @@ def generate_index_md():
         f"Live symbol coverage across {len(headers_data)} headers ({n_c23} C23 "
         f"standard headers, {n_posix} POSIX.1-2024 headers, and extensions), verified "
         "directly against LLVM-libc source files, header generation specifications, "
-        "and exported entrypoints.  Purely compiler-provided freestanding C headers "
-        "(`iso646.h`, `stdalign.h`, `stdarg.h`, `stdatomic.h`, `stdbool.h`, "
-        "`stddef.h`, `stdnoreturn.h`, and `tgmath.h`) come from the host compiler "
-        "(`Clang` or `GCC`) rather than LLVM-libc and are omitted below.\n\n"
+        "and exported entrypoints.  Symbols gated behind "
+        "`LLVM_LIBC_ENABLE_EXPERIMENTAL_ENTRYPOINTS` (off by default) are marked "
+        "separately as experimental and excluded from default completion percentages.  "
+        "Purely compiler-provided freestanding C headers (`iso646.h`, `stdalign.h`, "
+        "`stdarg.h`, `stdatomic.h`, `stdbool.h`, `stddef.h`, `stdnoreturn.h`, and "
+        "`tgmath.h`) come from the host compiler (`Clang` or `GCC`) rather than "
+        "LLVM-libc and are omitted below.\n\n"
         "```{raw} html\n"
         f'<div class="hc-grid-standards">{c23_card}{pos_card}</div>'
         f'<div class="hc-grid-cards">{cat_cards}</div>\n```\n\n'
         "## All Headers\n\n"
         "Filter, search, or click any header to inspect category breakdowns, "
-        "precision coverage, and missing or implemented symbols.\n\n"
+        "precision coverage, and experimental, missing, or implemented symbols.\n\n"
         "```{raw} html\n"
         f"{_toolbar_html(len(headers_data))}"
         '<div id="headers-list" class="hc-headers-list">'
     )
     for hdr, api, stats in headers_data:
-        imp, tot = stats["overall"]["implemented"], stats["overall"]["total"]
+        ov = stats["overall"]
+        imp, tot, exp = ov["implemented"], ov["total"], ov["experimental"]
         pct = (imp / tot * 100.0) if tot else 0.0
+        exp_pct = (exp / tot * 100.0) if tot else 0.0
         std_tags = []
         if stats["standard"] == "c23":
             std_tags.append("c23")
@@ -689,28 +752,31 @@ def generate_index_md():
             for v in ((fd or {}).get("variants") or {}).values()
             if v
         ]
-        missing, impl_syms = [], []
+        by_st: Dict[str, List] = {"experimental": [], "missing": [], "implemented": []}
         sym_sources = [
             (
                 "family",
                 api.get("families") or {},
-                lambda n, d: hdr.evaluate_family(n, d)["implemented"],
+                lambda n, d: hdr.evaluate_family(n, d)["status"],
             ),
-            ("function", api.get("functions") or {}, lambda n, _: hdr.implements_fn(n)),
-            ("macro", api.get("macros") or {}, lambda n, _: hdr.implements_macro(n)),
-            ("type", api.get("types") or {}, lambda n, _: hdr.implements_type(n)),
-            ("object", api.get("objects") or {}, lambda n, _: hdr.implements_object(n)),
+            ("function", api.get("functions") or {}, lambda n, _: hdr.fn_status(n)),
+            ("macro", api.get("macros") or {}, lambda n, _: hdr.macro_status(n)),
+            ("type", api.get("types") or {}, lambda n, _: hdr.type_status(n)),
+            ("object", api.get("objects") or {}, lambda n, _: hdr.object_status(n)),
         ]
-        for kind, entries, check_fn in sym_sources:
+        for kind, entries, st_fn in sym_sources:
             for name in sorted(entries.keys()):
                 item = entries[name] or {}
-                (impl_syms if check_fn(name, item) else missing).append(
-                    (name, kind, item)
-                )
+                by_st[st_fn(name, item)].append((name, kind, item))
 
         mini_cards = "".join(
             _mini_card_html(
-                hdr.name, title, stats[k]["implemented"], stats[k]["total"], c
+                hdr.name,
+                title,
+                stats[k]["implemented"],
+                stats[k]["total"],
+                c,
+                stats[k]["experimental"],
             )
             for k, title, c in (
                 ("families", "Base Families", "green"),
@@ -728,19 +794,37 @@ def generate_index_md():
             if stats["precisions"]
             else ""
         )
+        exp_html = _chip_group_html(
+            hdr,
+            api,
+            by_st["experimental"],
+            "Experimental Symbols",
+            "amber",
+            "experimental",
+        )
         miss_html = _chip_group_html(
-            hdr, api, missing, "Missing Symbols", "amber", True
+            hdr, api, by_st["missing"], "Missing Symbols", "muted", "missing"
         )
         impl_html = _chip_group_html(
-            hdr, api, impl_syms, "Implemented Symbols", "green", False
+            hdr,
+            api,
+            by_st["implemented"],
+            "Implemented Symbols",
+            "green",
+            "implemented",
         )
         stem = html.escape(hdr.stem, quote=True)
         hname = html.escape(hdr.name, quote=True)
         syms_attr = html.escape(" ".join(syms).lower(), quote=True)
-        bar = _progress_bar_html(pct, f"{hdr.name} implementation progress", _tone(pct))
+        bar = _progress_bar_html(
+            pct, f"{hdr.name} implementation progress", _tone(pct), exp_pct=exp_pct
+        )
+        has_exp = "true" if (exp > 0 or stats.get("experimental_header")) else "false"
+        frac_str = f"({imp}/{tot}, +{exp} exp)" if exp else f"({imp}/{tot})"
         print(
             f'<details class="header-card" data-stem="{stem}" data-name="{hname}" '
             f'data-standard="{" ".join(std_tags)}" data-status="{status_attr}" '
+            f'data-experimental="{has_exp}" '
             f'data-pct="{pct:.2f}" data-missing="{tot - imp}" '
             f'data-symbols="{syms_attr}"><summary>'
             '<div class="hc-header-title-col">'
@@ -749,13 +833,13 @@ def generate_index_md():
             f"{_header_pills_html(stats, short=True)}</div>"
             f'<div class="hc-thermometer-col">{bar}'
             f'<span class="hc-row-pct">{pct:.1f}%</span>'
-            f'<span class="hc-row-frac">({imp}/{tot})</span></div>'
+            f'<span class="hc-row-frac">{frac_str}</span></div>'
             f'<div class="hc-action-col"><a class="hc-page-link" href="{stem}.html" '
             f'onclick="event.stopPropagation();" '
             f'aria-label="Open {hname} status page">'
             'Page <span aria-hidden="true">↗</span></a></div></summary>'
             f'<div class="hc-drawer"><div class="hc-grid-cards">{mini_cards}</div>'
-            f"{prec_block}{miss_html}{impl_html}"
+            f"{prec_block}{exp_html}{miss_html}{impl_html}"
             f'<div class="hc-drawer-foot"><a class="hc-page-link" href="{stem}.html">'
             f"View full <{hname}> page →</a></div></div></details>"
         )

diff  --git a/libc/utils/docgen/docgen_test.py b/libc/utils/docgen/docgen_test.py
index 839808160372e..8fe27b136d5b0 100644
--- a/libc/utils/docgen/docgen_test.py
+++ b/libc/utils/docgen/docgen_test.py
@@ -38,7 +38,8 @@ def test_new_c23_and_posix_headers(self):
         self.assertTrue(Header("stdint.h").implements_type("int64_t"))
         self.assertTrue(Header("stdint.h").implements_macro("INT64_MAX"))
         self.assertTrue(Header("stdckdint.h").implements_macro("ckd_add"))
-        self.assertTrue(Header("regex.h").implements_fn("regcomp"))
+        self.assertEqual(Header("regex.h").fn_status("regcomp"), "experimental")
+        self.assertFalse(Header("regex.h").implements_fn("regcomp"))
         self.assertTrue(Header("sys/shm.h").implements_fn("shmget"))
         self.assertFalse(Header("ulimit.h").implements_fn("ulimit"))
 
@@ -105,7 +106,8 @@ def test_implements_type(self):
 
     def test_implements_object(self):
         self.assertTrue(Header("stdio.h").implements_object("stdin"))
-        self.assertTrue(Header("time.h").implements_object("tzname"))
+        self.assertEqual(Header("time.h").object_status("tzname"), "experimental")
+        self.assertFalse(Header("time.h").implements_object("tzname"))
         self.assertTrue(Header("unistd.h").implements_object("optarg"))
         self.assertFalse(Header("time.h").implements_object("getdate_err"))
         self.assertFalse(Header("errno.h").implements_object("errno"))
@@ -407,12 +409,37 @@ def test_index_output_generation(self):
         self.assertIn('data-stem="arpa/inet"', out)
         self.assertIn("acosf128", out)
         self.assertIn('class="dashboard-controls"', out)
+        self.assertIn('class="hc-chip-exp"', out)
         self.assertIn('class="hc-chip-missing"', out)
         self.assertIn('class="hc-chip-impl"', out)
         self.assertIn('href="https://en.cppreference.com/w/c/io/clearerr"', out)
         self.assertIn("```{toctree}\n:hidden: true", out)
         self.assertIn("\npoll\npthread\npwd\n", out)
 
+    def test_experimental_and_stub_classification(self):
+        self.assertEqual(Header("unistd.h").fn_status("setuid"), "experimental")
+        self.assertEqual(Header("unistd.h").fn_status("getuid"), "implemented")
+        self.assertEqual(Header("grp.h").fn_status("initgroups"), "experimental")
+        self.assertEqual(Header("net/if.h").fn_status("if_nameindex"), "experimental")
+        self.assertEqual(Header("fnmatch.h").fn_status("fnmatch"), "missing")
+        self.assertEqual(Header("time.h").fn_status("strptime"), "missing")
+        self.assertEqual(Header("time.h").fn_status("tzset"), "missing")
+        self.assertEqual(Header("wchar.h").fn_status("swprintf"), "missing")
+
+        rx = Header("regex.h")
+        self.assertTrue(rx.is_experimental_header())
+        self.assertEqual(rx.macro_status("REG_EXTENDED"), "experimental")
+        self.assertEqual(rx.type_status("regex_t"), "experimental")
+        rx_stats = rx.get_summary_stats()
+        self.assertEqual(rx_stats["overall"]["implemented"], 0)
+        self.assertGreater(rx_stats["overall"]["experimental"], 0)
+        buf = io.StringIO()
+        with redirect_stdout(buf):
+            print_header_status_md(rx, rx.api)
+        rx_out = buf.getvalue()
+        self.assertIn('class="hc-status-exp"', rx_out)
+        self.assertIn("experimental)", rx_out)
+
 
 if __name__ == "__main__":
     unittest.main()

diff  --git a/libc/utils/docgen/header.py b/libc/utils/docgen/header.py
index a6c020be76193..0728768b7d490 100644
--- a/libc/utils/docgen/header.py
+++ b/libc/utils/docgen/header.py
@@ -15,14 +15,39 @@
 _C_SEC_RE = re.compile(r"^([0-9]+|[FGHJK])\.")
 
 
-def _stat(flags: List[bool]) -> Dict[str, int]:
-    return {"total": len(flags), "implemented": sum(flags)}
-
-
-def _is_stub_file(path: Path) -> bool:
+def _stat(statuses: List[str]) -> Dict[str, int]:
+    return {
+        "total": len(statuses),
+        "implemented": sum(s == "implemented" for s in statuses),
+        "experimental": sum(s == "experimental" for s in statuses),
+    }
+
+
+def _iter_cmake_entries(
+    path: Path, prefix: str
+) -> Generator[Tuple[str, bool], None, None]:
+    stack: List[str] = []
+    for raw in path.read_text(encoding="utf-8").splitlines():
+        line = raw.strip()
+        if line.startswith(("if(", "if (")):
+            stack.append(line)
+        elif line.startswith(("elseif(", "else(")) and stack:
+            stack[-1] = line
+        elif line.startswith("endif(") and stack:
+            stack.pop()
+        elif line.startswith(prefix):
+            yield line[len(prefix) :], any("EXPERIMENTAL" in c for c in stack)
+
+
+def _is_stub_file(path: Path, is_experimental: bool = False) -> bool:
     text = path.read_text(encoding="utf-8")
-    has_todo = "todo" in text.lower() or "unimplemented" in text.lower()
-    if not has_todo and "math" not in path.parts:
+    low = text.lower()
+    has_marker = (
+        any(m in low for m in ("todo", "unimplemented", "for now"))
+        or "ENOSYS" in text
+        or "[[maybe_unused]]" in text
+    )
+    if not has_marker and not is_experimental and "math" not in path.parts:
         return False
 
     idx = text.find("LLVM_LIBC_FUNCTION")
@@ -46,8 +71,8 @@ def _is_stub_file(path: Path) -> bool:
     clean = re.sub(r"/\*.*?\*/", "", clean, flags=re.DOTALL).strip()
     stmts = [s.strip() for s in clean.split(";") if s.strip()]
     if len(stmts) == 0:
-        return has_todo
-    if len(stmts) > 2:
+        return has_marker or is_experimental
+    if len(stmts) > 2 or (not has_marker and "math" not in path.parts):
         return False
 
     for stmt in stmts:
@@ -73,13 +98,29 @@ def _is_stub_file(path: Path) -> bool:
 @lru_cache(maxsize=None)
 def _load_implemented_functions(
     libc_root: Path,
-) -> Tuple[Set[str], Dict[str, Set[str]]]:
+) -> Tuple[Set[str], Dict[str, Set[str]], Set[str], Dict[str, Set[str]], Set[str]]:
+    raw_def_eps: List[str] = []
+    raw_exp_eps: List[str] = []
+    def_hdrs: Set[str] = set()
+    exp_hdrs: Set[str] = set()
+    config_dir = libc_root / "config"
+    if config_dir.exists():
+        for ep_file in config_dir.rglob("entrypoints.txt"):
+            for entry, is_exp in _iter_cmake_entries(ep_file, "libc.src."):
+                (raw_exp_eps if is_exp else raw_def_eps).append(entry)
+        for hdr_file in config_dir.rglob("headers.txt"):
+            for entry, is_exp in _iter_cmake_entries(hdr_file, "libc.include."):
+                (exp_hdrs if is_exp else def_hdrs).add(entry)
+
+    exp_targets = {e.split(".")[-1] for e in raw_exp_eps} - {
+        e.split(".")[-1] for e in raw_def_eps
+    }
     stubs, reals = set(), set()
     vars_by_target: Dict[str, Set[str]] = {}
     src_dir = libc_root / "src"
     if src_dir.exists():
         for p in src_dir.rglob("*.cpp"):
-            if _is_stub_file(p):
+            if _is_stub_file(p, p.stem in exp_targets):
                 stubs.add(p.stem)
             else:
                 reals.add(p.stem)
@@ -87,22 +128,23 @@ def _load_implemented_functions(
                     vars_by_target.setdefault(p.stem, set()).add(var)
 
     stub_only = stubs - reals
-    all_fns: Set[str] = set()
-    by_stem: Dict[str, Set[str]] = {}
-    config_dir = libc_root / "config"
-    if config_dir.exists():
-        for ep_file in config_dir.rglob("entrypoints.txt"):
-            for line in ep_file.read_text(encoding="utf-8").splitlines():
-                line = line.strip()
-                if line.startswith("libc.src."):
-                    parts = line.split(".")
-                    sym = parts[-1]
-                    if sym not in stub_only:
-                        stem = "/".join(parts[2:-1])
-                        exported = {sym} | vars_by_target.get(sym, set())
-                        all_fns |= exported
-                        by_stem.setdefault(stem, set()).update(exported)
-    return all_fns, by_stem
+
+    def _collect(entries: List[str]) -> Tuple[Set[str], Dict[str, Set[str]]]:
+        syms: Set[str] = set()
+        by_stem: Dict[str, Set[str]] = {}
+        for entry in entries:
+            parts = entry.split(".")
+            sym = parts[-1]
+            if sym not in stub_only:
+                stem = "/".join(parts[:-1])
+                exported = {sym} | vars_by_target.get(sym, set())
+                syms |= exported
+                by_stem.setdefault(stem, set()).update(exported)
+        return syms, by_stem
+
+    def_fns, def_by_stem = _collect(raw_def_eps)
+    exp_fns, exp_by_stem = _collect(raw_exp_eps)
+    return def_fns, def_by_stem, exp_fns - def_fns, exp_by_stem, exp_hdrs - def_hdrs
 
 
 def _load_include_yaml(yaml_path: Path) -> Dict:
@@ -178,26 +220,35 @@ def macro_file_exists(self) -> bool:
     def fns_dir_exists(self) -> bool:
         return self.fns_dir.exists() and self.fns_dir.is_dir()
 
-    def implements_fn(self, fn_name: str) -> bool:
-        all_fns, by_stem = _load_implemented_functions(self.libc_root)
+    def is_experimental_header(self) -> bool:
+        _, _, _, _, exp_hdrs = _load_implemented_functions(self.libc_root)
+        return self.stem.replace("/", "_") in exp_hdrs
+
+    def _in_fn_group(
+        self, fn_name: str, all_syms: Set[str], by_stem: Dict[str, Set[str]]
+    ) -> bool:
         if fn_name in by_stem.get(self.stem, set()):
             return True
         if not hasattr(self, "_declared_fns"):
             self._declared_fns = {
                 f["name"] for f in self.include_data.get("functions", []) if "name" in f
             }
-        return fn_name in all_fns and fn_name in self._declared_fns
+        return fn_name in all_syms and fn_name in self._declared_fns
 
-    def implements_macro(self, m_name: str) -> bool:
-        """
-        Some macro files are in, e.g.,
-        ``$LLVM_PROJECT_ROOT/libc/include/llvm-libc-macros/fenv-macros.h``,
-        but others are in subdirectories, e.g., ``signal.h`` has the macro
-        definitions in
-        ``$LLVM_PROJECT_ROOT/libc/include/llvm-libc-macros/linux/signal-macros.h``.
+    def fn_status(self, fn_name: str) -> str:
+        def_fns, def_stem, exp_fns, exp_stem, _ = _load_implemented_functions(
+            self.libc_root
+        )
+        if self._in_fn_group(fn_name, def_fns, def_stem):
+            return "experimental" if self.is_experimental_header() else "implemented"
+        if self._in_fn_group(fn_name, exp_fns, exp_stem):
+            return "experimental"
+        return "missing"
 
-        :param m_name: name of macro, e.g., ``FE_ALL_EXCEPT``
-        """
+    def implements_fn(self, fn_name: str) -> bool:
+        return self.fn_status(fn_name) == "implemented"
+
+    def _has_macro(self, m_name: str) -> bool:
         macro_re = re.compile(rf"^\s*#\s*define\s+{re.escape(m_name)}\b", re.MULTILINE)
         for f in self.__get_macro_files():
             if macro_re.search(f.read_text(encoding="utf-8")):
@@ -219,6 +270,14 @@ def implements_macro(self, m_name: str) -> bool:
 
         return False
 
+    def macro_status(self, m_name: str) -> str:
+        if not self._has_macro(m_name):
+            return "missing"
+        return "experimental" if self.is_experimental_header() else "implemented"
+
+    def implements_macro(self, m_name: str) -> bool:
+        return self.macro_status(m_name) == "implemented"
+
     def _load_exposed_types(self) -> Set[str]:
         hdrgen_dir = str(self.docgen_root.parent / "hdrgen")
         if hdrgen_dir not in sys.path:
@@ -272,21 +331,36 @@ def _load_exposed_types(self) -> Set[str]:
             found.update(typedef_re.findall(mf.read_text(encoding="utf-8")))
         return found
 
-    def implements_type(self, t_name: str) -> bool:
+    def type_status(self, t_name: str) -> str:
         if not hasattr(self, "_exposed_types"):
             self._exposed_types = self._load_exposed_types()
-        return (
+        found = (
             t_name in self._exposed_types
             or t_name.replace(" ", "_") in self._exposed_types
         )
+        if not found:
+            return "missing"
+        return "experimental" if self.is_experimental_header() else "implemented"
 
-    def implements_object(self, o_name: str) -> bool:
+    def implements_type(self, t_name: str) -> bool:
+        return self.type_status(t_name) == "implemented"
+
+    def object_status(self, o_name: str) -> str:
         if not any(
             o.get("object_name") == o_name for o in self.include_data.get("objects", [])
         ):
-            return False
-        all_syms, by_stem = _load_implemented_functions(self.libc_root)
-        return o_name in by_stem.get(self.stem, set()) or o_name in all_syms
+            return "missing"
+        def_syms, def_stem, exp_syms, exp_stem, _ = _load_implemented_functions(
+            self.libc_root
+        )
+        if o_name in def_stem.get(self.stem, set()) or o_name in def_syms:
+            return "experimental" if self.is_experimental_header() else "implemented"
+        if o_name in exp_stem.get(self.stem, set()) or o_name in exp_syms:
+            return "experimental"
+        return "missing"
+
+    def implements_object(self, o_name: str) -> bool:
+        return self.object_status(o_name) == "implemented"
 
     def __get_macro_files(self) -> Generator[Path, None, None]:
         """
@@ -316,17 +390,27 @@ def evaluate_family(self, fam_name: str, fam_data: Dict) -> Dict:
         accuracy = fam_data.get("accuracy") or {}
         results = {}
         implemented_count = 0
+        exp_count = 0
         for prec, sym in variants.items():
-            impl = bool(sym) and self.implements_fn(sym)
-            if impl:
+            st = self.fn_status(sym) if sym else "missing"
+            if st == "implemented":
                 implemented_count += 1
+            elif st == "experimental":
+                exp_count += 1
             results[prec] = {
                 "symbol": sym or "",
-                "implemented": impl,
+                "status": st,
+                "implemented": st == "implemented",
                 "accuracy": accuracy.get(prec, ""),
             }
+        fam_status = (
+            "implemented"
+            if implemented_count > 0
+            else ("experimental" if exp_count > 0 else "missing")
+        )
         return {
             "name": fam_name,
+            "status": fam_status,
             "implemented": implemented_count > 0,
             "variants": results,
             "implemented_count": implemented_count,
@@ -342,7 +426,7 @@ def get_summary_stats(self, api: Optional[Dict] = None) -> Dict:
         precisions = []
         for col in api.get("family-columns") or []:
             vals = [
-                r["variants"][col["key"]]["implemented"]
+                r["variants"][col["key"]]["status"]
                 for r in fam_eval.values()
                 if col["key"] in r["variants"]
             ]
@@ -351,20 +435,20 @@ def get_summary_stats(self, api: Optional[Dict] = None) -> Dict:
                     {"key": col["key"], "label": col["label"], **_stat(vals)}
                 )
 
-        all_items: List[Tuple[Dict, bool]] = [
-            (fd or {}, fam_eval[n]["implemented"]) for n, fd in families.items()
+        all_items: List[Tuple[Dict, str]] = [
+            (fd or {}, fam_eval[n]["status"]) for n, fd in families.items()
         ]
-        counts = {"families": _stat([i for _, i in all_items])}
-        for key, sec_name, check_fn in (
-            ("raw_functions", "functions", self.implements_fn),
-            ("macros", "macros", self.implements_macro),
-            ("types", "types", self.implements_type),
-            ("objects", "objects", self.implements_object),
+        counts = {"families": _stat([s for _, s in all_items])}
+        for key, sec_name, status_fn in (
+            ("raw_functions", "functions", self.fn_status),
+            ("macros", "macros", self.macro_status),
+            ("types", "types", self.type_status),
+            ("objects", "objects", self.object_status),
         ):
             pairs = [
-                (it or {}, check_fn(n)) for n, it in (api.get(sec_name) or {}).items()
+                (it or {}, status_fn(n)) for n, it in (api.get(sec_name) or {}).items()
             ]
-            counts[key] = _stat([i for _, i in pairs])
+            counts[key] = _stat([s for _, s in pairs])
             all_items.extend(pairs)
 
         std = api.get("standard", "")
@@ -373,33 +457,33 @@ def get_summary_stats(self, api: Optional[Dict] = None) -> Dict:
             "header": self.name,
             "standard": std,
             "posix": api.get("posix", ""),
+            "experimental_header": self.is_experimental_header(),
             "removed_posix": not std
             and not api.get("posix")
             and bool(all_items)
             and all(any(k in it for k in removed) for it, _ in all_items),
-            "overall": _stat([i for _, i in all_items]),
+            "overall": _stat([s for _, s in all_items]),
             "functions": {
-                "total": counts["families"]["total"] + counts["raw_functions"]["total"],
-                "implemented": counts["families"]["implemented"]
-                + counts["raw_functions"]["implemented"],
+                k: counts["families"][k] + counts["raw_functions"][k]
+                for k in ("total", "implemented", "experimental")
             },
             **counts,
             "c23": _stat(
                 [
-                    i
-                    for it, i in all_items
+                    s
+                    for it, s in all_items
                     if std == "c23"
                     and _C_SEC_RE.match(str(it.get("c-definition") or ""))
                 ]
             ),
             "tr18037": _stat(
                 [
-                    i
-                    for it, i in all_items
+                    s
+                    for it, s in all_items
                     if std == "iso-tr-18037"
                     and str(it.get("c-definition") or "").startswith("TR 18037")
                 ]
             ),
-            "posix_spec": _stat([i for it, i in all_items if "in-latest-posix" in it]),
+            "posix_spec": _stat([s for it, s in all_items if "in-latest-posix" in it]),
             "precisions": precisions,
         }


        


More information about the libc-commits mailing list