[libc-commits] [libc] [libc][stdfix][NFC] Add header guards and update file headers in test headers (PR #239054)

Jaeyong Lee via libc-commits libc-commits at lists.llvm.org
Fri Nov 6 18:21:39 PST 2026


https://github.com/npmania updated https://github.com/llvm/llvm-project/pull/239054

>From 2e5475402b2646a306c93ce587525102925efc62 Mon Sep 17 00:00:00 2001
From: Jaeyong Lee <jay at glendalab.com>
Date: Thu, 5 Nov 2026 10:30:45 +0900
Subject: [PATCH 1/3] [libc][stdfix][NFC] Add header guards and update file
 headers in test headers

---
 libc/test/src/stdfix/AbsTest.h     | 12 +++++++++++-
 libc/test/src/stdfix/BitsFxTest.h  | 12 +++++++++++-
 libc/test/src/stdfix/CountlsTest.h | 12 +++++++++++-
 libc/test/src/stdfix/DiviFxTest.h  | 12 +++++++++++-
 libc/test/src/stdfix/ExpTest.h     | 12 +++++++++++-
 libc/test/src/stdfix/FxBitsTest.h  | 12 +++++++++++-
 libc/test/src/stdfix/FxDiviTest.h  | 12 +++++++++++-
 libc/test/src/stdfix/ISqrtTest.h   | 12 +++++++++++-
 libc/test/src/stdfix/IdivFxTest.h  | 12 +++++++++++-
 libc/test/src/stdfix/RoundTest.h   | 12 +++++++++++-
 libc/test/src/stdfix/SqrtTest.h    | 12 +++++++++++-
 11 files changed, 121 insertions(+), 11 deletions(-)

diff --git a/libc/test/src/stdfix/AbsTest.h b/libc/test/src/stdfix/AbsTest.h
index 3d23a475720c25..94a24d129ac2be 100644
--- a/libc/test/src/stdfix/AbsTest.h
+++ b/libc/test/src/stdfix/AbsTest.h
@@ -1,10 +1,18 @@
-//===-- Utility class to test fixed-point abs -------------------*- C++ -*-===//
+//===----------------------------------------------------------------------===//
 //
 // 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
 //
 //===----------------------------------------------------------------------===//
+///
+/// \file
+/// Utility class to test fixed-point abs.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_TEST_SRC_STDFIX_ABSTEST_H
+#define LLVM_LIBC_TEST_SRC_STDFIX_ABSTEST_H
 
 #include "test/UnitTest/Test.h"
 
@@ -35,3 +43,5 @@ template <typename T> class AbsTest : public LIBC_NAMESPACE::testing::Test {
   using LlvmLibcAbsTest = AbsTest<T>;                                          \
   TEST_F(LlvmLibcAbsTest, SpecialNumbers) { testSpecialNumbers(&func); }       \
   static_assert(true, "Require semicolon.")
+
+#endif // LLVM_LIBC_TEST_SRC_STDFIX_ABSTEST_H
diff --git a/libc/test/src/stdfix/BitsFxTest.h b/libc/test/src/stdfix/BitsFxTest.h
index cdb363f07053b7..0bd6ba01b39d57 100644
--- a/libc/test/src/stdfix/BitsFxTest.h
+++ b/libc/test/src/stdfix/BitsFxTest.h
@@ -1,10 +1,18 @@
-//===-- Utility class to test bitsfx functions ------------------*- C++ -*-===//
+//===----------------------------------------------------------------------===//
 //
 // 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
 //
 //===----------------------------------------------------------------------===//
+///
+/// \file
+/// Utility class to test bitsfx functions.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_TEST_SRC_STDFIX_BITSFXTEST_H
+#define LLVM_LIBC_TEST_SRC_STDFIX_BITSFXTEST_H
 
 #include "test/UnitTest/Test.h"
 
@@ -81,3 +89,5 @@ class BitsFxTest : public LIBC_NAMESPACE::testing::Test {
     testSpecialNumbers(&func);                                                 \
   }                                                                            \
   static_assert(true, "Require semicolon.")
+
+#endif // LLVM_LIBC_TEST_SRC_STDFIX_BITSFXTEST_H
diff --git a/libc/test/src/stdfix/CountlsTest.h b/libc/test/src/stdfix/CountlsTest.h
index a8201acb455b52..455b7e511096ef 100644
--- a/libc/test/src/stdfix/CountlsTest.h
+++ b/libc/test/src/stdfix/CountlsTest.h
@@ -1,10 +1,18 @@
-//===-- Utility class to test countls -------------------*- C++ -*-===//
+//===----------------------------------------------------------------------===//
 //
 // 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
 //
 //===----------------------------------------------------------------------===//
+///
+/// \file
+/// Utility class to test countls.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_TEST_SRC_STDFIX_COUNTLSTEST_H
+#define LLVM_LIBC_TEST_SRC_STDFIX_COUNTLSTEST_H
 
 #include "test/UnitTest/Test.h"
 
@@ -56,3 +64,5 @@ template <typename T> class CountlsTest : public LIBC_NAMESPACE::testing::Test {
   using LlvmLibcCountlsTest = CountlsTest<T>;                                  \
   TEST_F(LlvmLibcCountlsTest, SpecialNumbers) { testSpecialNumbers(&func); }   \
   static_assert(true, "Require semicolon.")
+
+#endif // LLVM_LIBC_TEST_SRC_STDFIX_COUNTLSTEST_H
diff --git a/libc/test/src/stdfix/DiviFxTest.h b/libc/test/src/stdfix/DiviFxTest.h
index c74285692e1083..2a1674de256770 100644
--- a/libc/test/src/stdfix/DiviFxTest.h
+++ b/libc/test/src/stdfix/DiviFxTest.h
@@ -1,10 +1,18 @@
-//===-- Utility class to test divifx functions ------------------*- C++ -*-===//
+//===----------------------------------------------------------------------===//
 //
 // 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
 //
 //===----------------------------------------------------------------------===//
+///
+/// \file
+/// Utility class to test divifx functions.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_TEST_SRC_STDFIX_DIVIFXTEST_H
+#define LLVM_LIBC_TEST_SRC_STDFIX_DIVIFXTEST_H
 
 #include "test/UnitTest/Test.h"
 
@@ -176,3 +184,5 @@ class DiviFxTest : public LIBC_NAMESPACE::testing::Test {
   TEST_F(LlvmLibcDivi##Name##Test, EdgeCases) { testEdgeCases(&func); }        \
   static_assert(true, "Require semicolon.")
 #endif // LIBC_ADD_NULL_CHECKS
+
+#endif // LLVM_LIBC_TEST_SRC_STDFIX_DIVIFXTEST_H
diff --git a/libc/test/src/stdfix/ExpTest.h b/libc/test/src/stdfix/ExpTest.h
index e588cebf621b90..6fa5ae583ec7d4 100644
--- a/libc/test/src/stdfix/ExpTest.h
+++ b/libc/test/src/stdfix/ExpTest.h
@@ -1,10 +1,18 @@
-//===-- Utility class to test integer sqrt ----------------------*- C++ -*-===//
+//===----------------------------------------------------------------------===//
 //
 // 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
 //
 //===----------------------------------------------------------------------===//
+///
+/// \file
+/// Utility class to test integer sqrt.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_TEST_SRC_STDFIX_EXPTEST_H
+#define LLVM_LIBC_TEST_SRC_STDFIX_EXPTEST_H
 
 #include "test/UnitTest/FPMatcher.h"
 #include "test/UnitTest/Test.h"
@@ -75,3 +83,5 @@ template <typename T> class ExpTest : public LIBC_NAMESPACE::testing::Test {
     test_negative_range(&func);                                                \
   }                                                                            \
   static_assert(true, "Require semicolon.")
+
+#endif // LLVM_LIBC_TEST_SRC_STDFIX_EXPTEST_H
diff --git a/libc/test/src/stdfix/FxBitsTest.h b/libc/test/src/stdfix/FxBitsTest.h
index 18dacadf08b033..78a42c1d05ff3c 100644
--- a/libc/test/src/stdfix/FxBitsTest.h
+++ b/libc/test/src/stdfix/FxBitsTest.h
@@ -1,10 +1,18 @@
-//===-- Utility class to test int to fixed point conversions ----*- C++ -*-===//
+//===----------------------------------------------------------------------===//
 //
 // 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
 //
 //===----------------------------------------------------------------------===//
+///
+/// \file
+/// Utility class to test int to fixed point conversions.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_TEST_SRC_STDFIX_FXBITSTEST_H
+#define LLVM_LIBC_TEST_SRC_STDFIX_FXBITSTEST_H
 
 #include "test/UnitTest/Test.h"
 
@@ -52,3 +60,5 @@ class FxBitsTest : public LIBC_NAMESPACE::testing::Test {
     test_special_numbers(&func);                                               \
   }                                                                            \
   static_assert(true, "Require semicolon.")
+
+#endif // LLVM_LIBC_TEST_SRC_STDFIX_FXBITSTEST_H
diff --git a/libc/test/src/stdfix/FxDiviTest.h b/libc/test/src/stdfix/FxDiviTest.h
index 4ff14c41b621d0..960ec341626e42 100644
--- a/libc/test/src/stdfix/FxDiviTest.h
+++ b/libc/test/src/stdfix/FxDiviTest.h
@@ -1,10 +1,18 @@
-//===-- Utility class to test fxdivi functions ------------------*- C++ -*-===//
+//===----------------------------------------------------------------------===//
 //
 // 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
 //
 //===----------------------------------------------------------------------===//
+///
+/// \file
+/// Utility class to test fxdivi functions.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_TEST_SRC_STDFIX_FXDIVITEST_H
+#define LLVM_LIBC_TEST_SRC_STDFIX_FXDIVITEST_H
 
 #include "src/__support/CPP/type_traits/conditional.h"
 #include "test/UnitTest/Test.h"
@@ -250,3 +258,5 @@ class FxDiviTest : public LIBC_NAMESPACE::testing::Test {
   }                                                                            \
   static_assert(true, "Require semicolon.")
 #endif // LIBC_ADD_NULL_CHECKS
+
+#endif // LLVM_LIBC_TEST_SRC_STDFIX_FXDIVITEST_H
diff --git a/libc/test/src/stdfix/ISqrtTest.h b/libc/test/src/stdfix/ISqrtTest.h
index 692488b383551c..a789f2d766dabc 100644
--- a/libc/test/src/stdfix/ISqrtTest.h
+++ b/libc/test/src/stdfix/ISqrtTest.h
@@ -1,10 +1,18 @@
-//===-- Utility class to test integer sqrt ----------------------*- C++ -*-===//
+//===----------------------------------------------------------------------===//
 //
 // 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
 //
 //===----------------------------------------------------------------------===//
+///
+/// \file
+/// Utility class to test integer sqrt.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_TEST_SRC_STDFIX_ISQRTTEST_H
+#define LLVM_LIBC_TEST_SRC_STDFIX_ISQRTTEST_H
 
 #include "test/UnitTest/FPMatcher.h"
 #include "test/UnitTest/Test.h"
@@ -67,3 +75,5 @@ template <typename T> class ISqrtTest : public LIBC_NAMESPACE::testing::Test {
     testSpecialNumbers(&func);                                                 \
   }                                                                            \
   static_assert(true, "Require semicolon.")
+
+#endif // LLVM_LIBC_TEST_SRC_STDFIX_ISQRTTEST_H
diff --git a/libc/test/src/stdfix/IdivFxTest.h b/libc/test/src/stdfix/IdivFxTest.h
index 883669f0bf1c75..14abf75d846d40 100644
--- a/libc/test/src/stdfix/IdivFxTest.h
+++ b/libc/test/src/stdfix/IdivFxTest.h
@@ -1,10 +1,18 @@
-//===-- Utility class to test idivfx functions ------------------*- C++ -*-===//
+//===----------------------------------------------------------------------===//
 //
 // 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
 //
 //===----------------------------------------------------------------------===//
+///
+/// \file
+/// Utility class to test idivfx functions.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_TEST_SRC_STDFIX_IDIVFXTEST_H
+#define LLVM_LIBC_TEST_SRC_STDFIX_IDIVFXTEST_H
 
 #include "test/UnitTest/Test.h"
 
@@ -89,3 +97,5 @@ class IdivFxTest : public LIBC_NAMESPACE::testing::Test {
   }                                                                            \
   static_assert(true, "Require semicolon.")
 #endif // LIBC_ADD_NULL_CHECKS
+
+#endif // LLVM_LIBC_TEST_SRC_STDFIX_IDIVFXTEST_H
diff --git a/libc/test/src/stdfix/RoundTest.h b/libc/test/src/stdfix/RoundTest.h
index d3ae04db9749ba..92dbb1f53fcb12 100644
--- a/libc/test/src/stdfix/RoundTest.h
+++ b/libc/test/src/stdfix/RoundTest.h
@@ -1,10 +1,18 @@
-//===-- Utility class to test fixed-point round -----------------*- C++ -*-===//
+//===----------------------------------------------------------------------===//
 //
 // 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
 //
 //===----------------------------------------------------------------------===//
+///
+/// \file
+/// Utility class to test fixed-point round.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_TEST_SRC_STDFIX_ROUNDTEST_H
+#define LLVM_LIBC_TEST_SRC_STDFIX_ROUNDTEST_H
 
 #include "test/UnitTest/Test.h"
 
@@ -63,3 +71,5 @@ template <typename T> class RoundTest : public LIBC_NAMESPACE::testing::Test {
   using LlvmLibcRoundTest = RoundTest<T>;                                      \
   TEST_F(LlvmLibcRoundTest, SpecialNumbers) { testSpecialNumbers(&func); }     \
   static_assert(true, "Require semicolon.")
+
+#endif // LLVM_LIBC_TEST_SRC_STDFIX_ROUNDTEST_H
diff --git a/libc/test/src/stdfix/SqrtTest.h b/libc/test/src/stdfix/SqrtTest.h
index 2a8a825abb460c..403da988c4bee8 100644
--- a/libc/test/src/stdfix/SqrtTest.h
+++ b/libc/test/src/stdfix/SqrtTest.h
@@ -1,10 +1,18 @@
-//===-- Utility class to test fixed-point sqrt ------------------*- C++ -*-===//
+//===----------------------------------------------------------------------===//
 //
 // 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
 //
 //===----------------------------------------------------------------------===//
+///
+/// \file
+/// Utility class to test fixed-point sqrt.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_TEST_SRC_STDFIX_SQRTTEST_H
+#define LLVM_LIBC_TEST_SRC_STDFIX_SQRTTEST_H
 
 #include "test/UnitTest/Test.h"
 
@@ -65,3 +73,5 @@ template <typename T> class SqrtTest : public LIBC_NAMESPACE::testing::Test {
   using LlvmLibcSqrtTest = SqrtTest<T>;                                        \
   TEST_F(LlvmLibcSqrtTest, SpecialNumbers) { testSpecialNumbers(&func); }      \
   static_assert(true, "Require semicolon.")
+
+#endif // LLVM_LIBC_TEST_SRC_STDFIX_SQRTTEST_H

>From 067b7f6c9f00c4a1e6d548a976a2438e6a61183f Mon Sep 17 00:00:00 2001
From: Jaeyong Lee <jay at glendalab.com>
Date: Thu, 5 Nov 2026 10:32:31 +0900
Subject: [PATCH 2/3] Fix file header comment in ExpTest.h

---
 libc/test/src/stdfix/ExpTest.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libc/test/src/stdfix/ExpTest.h b/libc/test/src/stdfix/ExpTest.h
index 6fa5ae583ec7d4..3513c8583caf7a 100644
--- a/libc/test/src/stdfix/ExpTest.h
+++ b/libc/test/src/stdfix/ExpTest.h
@@ -7,7 +7,7 @@
 //===----------------------------------------------------------------------===//
 ///
 /// \file
-/// Utility class to test integer sqrt.
+/// Utility class to test fixed-point exp.
 ///
 //===----------------------------------------------------------------------===//
 

>From 119991e495727879cff020db03e9684bfe2781de Mon Sep 17 00:00:00 2001
From: Jaeyong Lee <jay at glendalab.com>
Date: Sat, 7 Nov 2026 11:21:21 +0900
Subject: [PATCH 3/3] Add header guard in MuliFxTest.h

---
 libc/test/src/stdfix/MuliFxTest.h | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/libc/test/src/stdfix/MuliFxTest.h b/libc/test/src/stdfix/MuliFxTest.h
index 97dfc7ce112206..8e6cd20871b30e 100644
--- a/libc/test/src/stdfix/MuliFxTest.h
+++ b/libc/test/src/stdfix/MuliFxTest.h
@@ -11,6 +11,9 @@
 ///
 //===----------------------------------------------------------------------===//
 
+#ifndef LLVM_LIBC_TEST_SRC_STDFIX_MULIFXTEST_H
+#define LLVM_LIBC_TEST_SRC_STDFIX_MULIFXTEST_H
+
 #include "test/UnitTest/Test.h"
 
 #include "llvm-libc-macros/stdfix-macros.h"
@@ -158,3 +161,5 @@ class MuliFxTest : public LIBC_NAMESPACE::testing::Test {
   TEST_F(LlvmLibcMuli##Name##Test, BasicNumbers) { testBasicNumbers(&func); }  \
   TEST_F(LlvmLibcMuli##Name##Test, EdgeCases) { testEdgeCases(&func); }        \
   static_assert(true, "Require semicolon.")
+
+#endif // LLVM_LIBC_TEST_SRC_STDFIX_MULIFXTEST_H



More information about the libc-commits mailing list