[libc-commits] [libc] [libc] Make GpuHeaderFile a subclass (PR #121445)

Roland McGrath via libc-commits libc-commits at lists.llvm.org
Wed Jan 1 17:06:16 PST 2025


https://github.com/frobtech created https://github.com/llvm/llvm-project/pull/121445

Replace copy&paste from HeaderFile to GpuHeaderFile with
subclassing.  Only the __str__ method differs.


>From 8f5e42f7e79c8d1cae597ef71977fb0a43dda249 Mon Sep 17 00:00:00 2001
From: Roland McGrath <mcgrathr at google.com>
Date: Wed, 1 Jan 2025 15:26:08 -0800
Subject: [PATCH] [libc] Make GpuHeaderFile a subclass

Replace copy&paste from HeaderFile to GpuHeaderFile with
subclassing.  Only the __str__ method differs.
---
 libc/utils/hdrgen/gpu_headers.py | 26 ++------------------------
 1 file changed, 2 insertions(+), 24 deletions(-)

diff --git a/libc/utils/hdrgen/gpu_headers.py b/libc/utils/hdrgen/gpu_headers.py
index b26b3a88557b4a..8c4ff6e08b1126 100644
--- a/libc/utils/hdrgen/gpu_headers.py
+++ b/libc/utils/hdrgen/gpu_headers.py
@@ -6,31 +6,9 @@
 #
 # ==-------------------------------------------------------------------------==#
 
+from header import HeaderFile
 
-class GpuHeaderFile:
-    def __init__(self, name):
-        self.name = name
-        self.macros = []
-        self.types = []
-        self.enumerations = []
-        self.objects = []
-        self.functions = []
-
-    def add_macro(self, macro):
-        self.macros.append(macro)
-
-    def add_type(self, type_):
-        self.types.append(type_)
-
-    def add_enumeration(self, enumeration):
-        self.enumerations.append(enumeration)
-
-    def add_object(self, object):
-        self.objects.append(object)
-
-    def add_function(self, function):
-        self.functions.append(function)
-
+class GpuHeaderFile(HeaderFile):
     def __str__(self):
         content = []
 



More information about the libc-commits mailing list