Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

bassiounix
Copy link
Contributor

No description provided.

Copy link
Contributor Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@bassiounix bassiounix marked this pull request as ready for review August 8, 2025 14:35
@llvmbot llvmbot added the libc label Aug 8, 2025
@llvmbot
Copy link
Member

llvmbot commented Aug 8, 2025

@llvm/pr-subscribers-libc

Author: Muhammad Bassiouni (bassiounix)

Changes

Full diff: https://github.com/llvm/llvm-project/pull/152732.diff

1 Files Affected:

  • (modified) libc/utils/hdrgen/hdrgen/header.py (+3-2)
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:

Copy link
Contributor Author

bassiounix commented Aug 8, 2025

Merge activity

  • Aug 8, 3:37 PM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Aug 8, 3:39 PM UTC: @bassiounix merged this pull request with Graphite.

@bassiounix bassiounix merged commit 45b1594 into main Aug 8, 2025
23 checks passed
@bassiounix bassiounix deleted the users/bassiounix/spr/08-08-_libc_hdrgen_fix_hdrgen_when_using_macros_as_guards_in_stdlib.yaml branch August 8, 2025 15:39
Copy link
Contributor

@lntue lntue left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants