Skip to content

[libc][newhdrgen] add_function by alphabetical order #102527

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

Merged
merged 1 commit into from
Aug 8, 2024

Conversation

aaryanshukla
Copy link
Contributor

  • add_function now adds the function by alphabetical order

- add_function now adds the function by alphabetical order
@llvmbot llvmbot added the libc label Aug 8, 2024
@llvmbot
Copy link
Member

llvmbot commented Aug 8, 2024

@llvm/pr-subscribers-libc

Author: None (aaryanshukla)

Changes
  • 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 --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):

@aaryanshukla aaryanshukla changed the title [libc][newhdrgen] add_function by alpha order [libc][newhdrgen] add_function by alphabetical order Aug 8, 2024
@lntue
Copy link
Contributor

lntue commented Aug 8, 2024

can we also sort the current yaml files in the PR?

@aaryanshukla
Copy link
Contributor Author

@lntue yes! I am making another patch for cleanup of all yaml files.

@aaryanshukla aaryanshukla merged commit 86cf67f into llvm:main Aug 8, 2024
7 of 8 checks passed
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.

4 participants