[libc-commits] [libc] 45b1594 - [libc][hdrgen] Fix hdrgen when using macros as guards in stdlib.yaml. (#152732)

via libc-commits libc-commits at lists.llvm.org
Fri Aug 8 08:39:50 PDT 2025


Author: Muhammad Bassiouni
Date: 2025-08-08T18:39:47+03:00
New Revision: 45b15946b1259bba654bdd96bd6fa23f7754f3ca

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

LOG: [libc][hdrgen] Fix hdrgen when using macros as guards in stdlib.yaml. (#152732)

Added: 
    

Modified: 
    libc/utils/hdrgen/hdrgen/header.py

Removed: 
    


################################################################################
diff  --git a/libc/utils/hdrgen/hdrgen/header.py b/libc/utils/hdrgen/hdrgen/header.py
index b054ed4e03bd0..2118db6e5fb75 100644
--- a/libc/utils/hdrgen/hdrgen/header.py
+++ b/libc/utils/hdrgen/hdrgen/header.py
@@ -204,7 +204,7 @@ def relpath(file):
 
         current_guard = None
         for function in self.functions:
-            if function.guard == None:
+            if function.guard == None and current_guard == None:
                 content.append(str(function) + " __NOEXCEPT;")
                 content.append("")
             else:
@@ -221,7 +221,8 @@ def relpath(file):
                     content.append(f"#endif // {current_guard}")
                     content.append("")
                     current_guard = function.guard
-                    content.append(f"#ifdef {current_guard}")
+                    if current_guard is not None:
+                        content.append(f"#ifdef {current_guard}")
                     content.append(str(function) + " __NOEXCEPT;")
                     content.append("")
         if current_guard != None:


        


More information about the libc-commits mailing list