[libc-commits] [libc] [libc][hdrgen] Extend guard attribute support for types (PR #189803)

Victor Campos via libc-commits libc-commits at lists.llvm.org
Wed Apr 8 08:07:39 PDT 2026


================
@@ -52,7 +52,21 @@ def yaml_to_classes(yaml_data, header_class, entry_points=None):
     types = yaml_data.get("types", [])
     sorted_types = sorted(types, key=lambda x: x["type_name"])
     for type_data in sorted_types:
-        header.add_type(Type(type_data["type_name"]))
+        type_name = type_data["type_name"]
+        type_guard = type_data.get("guard")
+        # If a type has a guard, the macro it references must exist in
+        # the same yaml file with a macro_header attribute.
+        if type_guard is not None and not any(
+            macro_data["macro_name"] == type_guard
+            and macro_data.get("macro_header") is not None
----------------
vhscampos wrote:

`"macro_header" in macro_data` is more straighforward.

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


More information about the libc-commits mailing list