[clang-tidy][NFC]remove deps of clang in clang tidy test (#116588)
[llvm-project.git] / libc / newhdrgen / class_implementation / classes / function.py
blobd97df7f8a50ec5ffa53a54462859e20f1d5c6d1f
1 # ====-- Function class for libc function headers -------------*- python -*--==#
3 # Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 # See https://llvm.org/LICENSE.txt for license information.
5 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 # ==-------------------------------------------------------------------------==#
10 class Function:
11 def __init__(
12 self, return_type, name, arguments, standards, guard=None, attributes=[]
14 self.return_type = return_type
15 self.name = name
16 self.arguments = [
17 arg if isinstance(arg, str) else arg["type"] for arg in arguments
19 self.standards = standards
20 self.guard = guard
21 self.attributes = attributes or ""
23 def __str__(self):
24 attributes_str = " ".join(self.attributes)
25 arguments_str = ", ".join(self.arguments)
26 if attributes_str == "":
27 result = f"{self.return_type} {self.name}({arguments_str})"
28 else:
29 result = f"{attributes_str} {self.return_type} {self.name}({arguments_str})"
30 return result