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

Victor Campos via libc-commits libc-commits at lists.llvm.org
Tue Apr 14 03:20:59 PDT 2026


================
@@ -338,3 +337,14 @@ def json_data(self):
             "standards": self.standards,
             "includes": sorted(str(file) for file in {COMMON_HEADER} | self.includes()),
         }
+
+    def __emit_guard(self, content, current_guard, new_guard):
+        if current_guard != new_guard:
+            if current_guard is not None:
+                if content[-1] == "":
+                    content.pop()
+                content.append(f"#endif // {current_guard}")
+                content.append("")
+            if new_guard is not None:
+                content.append(f"#ifdef {new_guard}")
+        return new_guard
----------------
vhscampos wrote:

The function can only ever return one value, and this value is from one of its inputs. So there's little sense in doing it this way.

I suggest you simply don't return anything from this function, and just use the argument value at the call sites directly.

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


More information about the libc-commits mailing list