[libc-commits] [libc] [libc][hdrgen] Extend guard attribute support for types (PR #191663)
via libc-commits
libc-commits at lists.llvm.org
Sat Apr 11 13:58:54 PDT 2026
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {darker}-->
:warning: Python code formatter, darker found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
darker --check --diff -r origin/main...HEAD libc/utils/hdrgen/hdrgen/header.py libc/utils/hdrgen/hdrgen/type.py libc/utils/hdrgen/hdrgen/yaml_to_classes.py libc/utils/hdrgen/tests/test_integration.py
``````````
:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:
</details>
<details>
<summary>
View the diff from darker here.
</summary>
``````````diff
--- hdrgen/header.py 2026-04-11 20:20:23.000000 +0000
+++ hdrgen/header.py 2026-04-11 20:58:25.550630 +0000
@@ -313,13 +313,11 @@
for function in sorted(self.functions):
# If the last function's name was the same after underscores,
# elide the blank line between the declarations.
if last_name == function.name_without_underscores():
content.pop()
- current_guard = self.__emit_guard(
- content, current_guard, function.guard
- )
+ current_guard = self.__emit_guard(content, current_guard, function.guard)
content.append(str(function) + " __NOEXCEPT;")
content.append("")
last_name = function.name_without_underscores()
self.__emit_guard(content, current_guard, None)
--- hdrgen/yaml_to_classes.py 2026-04-11 20:20:23.000000 +0000
+++ hdrgen/yaml_to_classes.py 2026-04-11 20:58:25.637520 +0000
@@ -55,12 +55,11 @@
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_header" in macro_data
+ macro_data["macro_name"] == type_guard and "macro_header" in macro_data
for macro_data in yaml_data.get("macros", [])
):
raise ValueError(
f"Type '{type_name}' has guard '{type_guard}' but no macro with "
f"macro_header '{type_guard}' was found in this file."
``````````
</details>
https://github.com/llvm/llvm-project/pull/191663
More information about the libc-commits
mailing list