[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:04:31 PDT 2024
https://github.com/aaryanshukla created https://github.com/llvm/llvm-project/pull/102527
- add_function now adds the function by alphabetical order
>From 0e1ae0c00878fd730901a7bdf58117c0cf532dcf Mon Sep 17 00:00:00 2001
From: Aaryan Shukla <aaryanshukla at google.com>
Date: Thu, 8 Aug 2024 20:02:53 +0000
Subject: [PATCH] [libc][newhdrgen] add_function by alpha order
- add_function now adds the function by alphabetical order
---
libc/newhdrgen/yaml_to_classes.py | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
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):
More information about the libc-commits
mailing list