[libc-commits] [libc] [libc] Make hdrgen deduce header type lists from function signatures (PR #127251)
Caslyn Tonelli via libc-commits
libc-commits at lists.llvm.org
Fri Feb 14 12:14:23 PST 2025
================
@@ -6,25 +6,68 @@
#
# ==-------------------------------------------------------------------------==#
+import re
+from type import Type
+
+
+# These are the keywords that appear in C type syntax but are not part of the
+# include file name. This is all of the modifiers, qualifiers, and base types,
+# but not "struct".
+KEYWORDS = [
+ "_Atomic",
+ "_Complex",
+ "_Float16",
+ "_Noreturn",
+ "__restrict",
+ "accum",
+ "char",
+ "const",
+ "double",
+ "float",
+ "fract",
+ "int",
+ "long",
+ "short",
+ "signed",
+ "unsigned",
+ "void",
+ "volatile",
+]
+NONIDENTIFIER = re.compile("[^a-zA-Z0-9_]+")
+
class Function:
def __init__(
self, return_type, name, arguments, standards, guard=None, attributes=[]
):
+ assert return_type
self.return_type = return_type
self.name = name
self.arguments = [
arg if isinstance(arg, str) else arg["type"] for arg in arguments
]
+ assert all(self.arguments)
self.standards = standards
self.guard = guard
- self.attributes = attributes or ""
+ self.attributes = attributes or []
----------------
Caslyn wrote:
Is there a need for the `or []` here, given the default for the parameter?
https://github.com/llvm/llvm-project/pull/127251
More information about the libc-commits
mailing list