[libc-commits] [libc] 86cf67f - [libc][newhdrgen] add_function by alphabetical order (#102527)
via libc-commits
libc-commits at lists.llvm.org
Thu Aug 8 13:26:49 PDT 2024
Author: aaryanshukla
Date: 2024-08-08T13:26:45-07:00
New Revision: 86cf67ffc1ee62c65bef313bf58ae70f74afb7c1
URL: https://github.com/llvm/llvm-project/commit/86cf67ffc1ee62c65bef313bf58ae70f74afb7c1
DIFF: https://github.com/llvm/llvm-project/commit/86cf67ffc1ee62c65bef313bf58ae70f74afb7c1.diff
LOG: [libc][newhdrgen] add_function by alphabetical order (#102527)
- add_function now adds the function by alphabetical order
Added:
Modified:
libc/newhdrgen/yaml_to_classes.py
Removed:
################################################################################
diff --git a/libc/newhdrgen/yaml_to_classes.py b/libc/newhdrgen/yaml_to_classes.py
index 37a4f78ec4a7b..3eb5e4ef2546c 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):
More information about the libc-commits
mailing list