[libc-commits] [libc] [libc][newhdrgen] add_function by alpha order (PR #102527)
via libc-commits
libc-commits at lists.llvm.org
Thu Aug 8 13:05:01 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-libc
Author: None (aaryanshukla)
<details>
<summary>Changes</summary>
- add_function now adds the function by alphabetical order
---
Full diff: https://github.com/llvm/llvm-project/pull/102527.diff
1 Files Affected:
- (modified) libc/newhdrgen/yaml_to_classes.py (+9-1)
``````````diff
diff --git a/libc/newhdrgen/yaml_to_classes.py b/libc/newhdrgen/yaml_to_classes.py
index 37a4f78ec4a7b6..3eb5e4ef2546c1 100644
--- a/libc/newhdrgen/yaml_to_classes.py
+++ b/libc/newhdrgen/yaml_to_classes.py
@@ -190,7 +190,15 @@ def add_function_to_yaml(yaml_file, function_details):
if new_function.attributes:
function_dict["attributes"] = new_function.attributes
- yaml_data["functions"].append(function_dict)
+ insert_index = 0
+ for i, func in enumerate(yaml_data["functions"]):
+ if func["name"] > new_function.name:
+ insert_index = i
+ break
+ else:
+ insert_index = len(yaml_data["functions"])
+
+ yaml_data["functions"].insert(insert_index, function_dict)
class IndentYamlListDumper(yaml.Dumper):
def increase_indent(self, flow=False, indentless=False):
``````````
</details>
https://github.com/llvm/llvm-project/pull/102527
More information about the libc-commits
mailing list