[libc-commits] [libc] [libc] newheadergen: adding h_def_file arg to test (PR #99397)

via libc-commits libc-commits at lists.llvm.org
Wed Jul 17 15:46:40 PDT 2024


https://github.com/aaryanshukla updated https://github.com/llvm/llvm-project/pull/99397

>From 30a5f918af32da05ee31a38ac8512db746def0ac Mon Sep 17 00:00:00 2001
From: Aaryan Shukla <aaryanshukla at google.com>
Date: Wed, 17 Jul 2024 22:15:49 +0000
Subject: [PATCH 1/3] [libc] newheadergen: adding h_def_file arg to test

- spacing with _NOEXCEPT
---
 libc/newhdrgen/tests/output/test_small.h | 8 ++++----
 libc/newhdrgen/tests/test_integration.py | 1 +
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/libc/newhdrgen/tests/output/test_small.h b/libc/newhdrgen/tests/output/test_small.h
index a777976134b04..a1ed28e391ffd 100644
--- a/libc/newhdrgen/tests/output/test_small.h
+++ b/libc/newhdrgen/tests/output/test_small.h
@@ -28,20 +28,20 @@ enum {
 
 __BEGIN_C_DECLS
 
-CONST_FUNC_A void func_a() __NOEXCEPT;
+CONST_FUNC_A void func_a()__NOEXCEPT;
 
 #ifdef LIBC_TYPES_HAS_FLOAT128
 float128 func_b() __NOEXCEPT;
 #endif // LIBC_TYPES_HAS_FLOAT128
 
 #ifdef LIBC_TYPES_HAS_FLOAT16
-_Float16 func_c(int, float) __NOEXCEPT;
+_Float16 func_c(int, float)__NOEXCEPT;
 
-_Float16 func_d(int, float) __NOEXCEPT;
+_Float16 func_d(int, float)__NOEXCEPT;
 #endif // LIBC_TYPES_HAS_FLOAT16
 
 #ifdef LIBC_TYPES_HAS_FLOAT16_AND_FLOAT128
-_Float16 func_e(float128) __NOEXCEPT;
+_Float16 func_e(float128)__NOEXCEPT;
 #endif // LIBC_TYPES_HAS_FLOAT16_AND_FLOAT128
 
 extern obj object_1;
diff --git a/libc/newhdrgen/tests/test_integration.py b/libc/newhdrgen/tests/test_integration.py
index f12d18bc04a49..628a37b11c309 100644
--- a/libc/newhdrgen/tests/test_integration.py
+++ b/libc/newhdrgen/tests/test_integration.py
@@ -25,6 +25,7 @@ def run_script(self, yaml_file, h_def_file, output_dir):
                 "python3",
                 str(self.source_dir / "libc/newhdrgen/yaml_to_classes.py"),
                 str(yaml_file),
+                "--h_def_file",
                 str(h_def_file),
                 "--output_dir",
                 str(output_dir),

>From 4b78044b6d36d389199104258142b21340a30eb6 Mon Sep 17 00:00:00 2001
From: Aaryan Shukla <aaryanshukla at google.com>
Date: Wed, 17 Jul 2024 22:29:40 +0000
Subject: [PATCH 2/3] spacing for __NOEXCEPT

---
 libc/newhdrgen/class_implementation/classes/function.py | 2 +-
 libc/newhdrgen/header.py                                | 8 ++++----
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/libc/newhdrgen/class_implementation/classes/function.py b/libc/newhdrgen/class_implementation/classes/function.py
index ccfd93547c1d8..845ef1aebf54b 100644
--- a/libc/newhdrgen/class_implementation/classes/function.py
+++ b/libc/newhdrgen/class_implementation/classes/function.py
@@ -26,7 +26,7 @@ def __str__(self):
         attributes_str = " ".join(self.attributes)
         arguments_str = ", ".join(self.arguments)
         if attributes_str == "":
-            result = f"{self.return_type} {self.name}({arguments_str});"
+            result = f"{self.return_type} {self.name}({arguments_str})"
         else:
             result = f"{attributes_str} {self.return_type} {self.name}({arguments_str})"
         return result
diff --git a/libc/newhdrgen/header.py b/libc/newhdrgen/header.py
index 69de81eebb719..141e3c9b2736b 100644
--- a/libc/newhdrgen/header.py
+++ b/libc/newhdrgen/header.py
@@ -60,16 +60,16 @@ def __str__(self):
         current_guard = None
         for function in self.functions:
             if function.guard == None:
-                content.append(str(function) + "__NOEXCEPT")
+                content.append(str(function) + " __NOEXCEPT;")
                 content.append("")
             else:
                 if current_guard == None:
                     current_guard = function.guard
                     content.append(f"#ifdef {current_guard}")
-                    content.append(str(function) + "__NOEXCEPT")
+                    content.append(str(function) + " __NOEXCEPT;")
                     content.append("")
                 elif current_guard == function.guard:
-                    content.append(str(function) + "__NOEXCEPT")
+                    content.append(str(function) + " __NOEXCEPT;")
                     content.append("")
                 else:
                     content.pop()
@@ -77,7 +77,7 @@ def __str__(self):
                     content.append("")
                     current_guard = function.guard
                     content.append(f"#ifdef {current_guard}")
-                    content.append(str(function) + "__NOEXCEPT")
+                    content.append(str(function) + " __NOEXCEPT;")
                     content.append("")
         if current_guard != None:
             content.pop()

>From 57d4bd0707299c2017383c6faabd7f2d1ac0e426 Mon Sep 17 00:00:00 2001
From: Aaryan Shukla <aaryanshukla at google.com>
Date: Wed, 17 Jul 2024 22:46:17 +0000
Subject: [PATCH 3/3] removed file

---
 libc/newhdrgen/tests/output/test_small.h | 52 ------------------------
 1 file changed, 52 deletions(-)
 delete mode 100644 libc/newhdrgen/tests/output/test_small.h

diff --git a/libc/newhdrgen/tests/output/test_small.h b/libc/newhdrgen/tests/output/test_small.h
deleted file mode 100644
index a1ed28e391ffd..0000000000000
--- a/libc/newhdrgen/tests/output/test_small.h
+++ /dev/null
@@ -1,52 +0,0 @@
-//===-- C standard library header test_small-------------------------------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_LIBC_TEST_SMALL_H
-#define LLVM_LIBC_TEST_SMALL_H
-
-#include "__llvm-libc-common.h"
-#include "llvm-libc-macros/float16-macros.h"
-#include "llvm-libc-macros/test_small-macros.h"
-#include "llvm-libc-types/float128.h"
-
-#define MACRO_A 1
-
-#define MACRO_B 2
-
-#include <llvm-libc-types/type_a.h>
-#include <llvm-libc-types/type_b.h>
-
-enum {
-  enum_a = value_1,
-  enum_b = value_2,
-};
-
-__BEGIN_C_DECLS
-
-CONST_FUNC_A void func_a()__NOEXCEPT;
-
-#ifdef LIBC_TYPES_HAS_FLOAT128
-float128 func_b() __NOEXCEPT;
-#endif // LIBC_TYPES_HAS_FLOAT128
-
-#ifdef LIBC_TYPES_HAS_FLOAT16
-_Float16 func_c(int, float)__NOEXCEPT;
-
-_Float16 func_d(int, float)__NOEXCEPT;
-#endif // LIBC_TYPES_HAS_FLOAT16
-
-#ifdef LIBC_TYPES_HAS_FLOAT16_AND_FLOAT128
-_Float16 func_e(float128)__NOEXCEPT;
-#endif // LIBC_TYPES_HAS_FLOAT16_AND_FLOAT128
-
-extern obj object_1;
-extern obj object_2;
-
-__END_C_DECLS
-
-#endif // LLVM_LIBC_TEST_SMALL_H



More information about the libc-commits mailing list