[libc-commits] [libc] d2c5954 - [libc] undefined reference in LibcTest.cpp

Guillaume Chatelet via libc-commits libc-commits at lists.llvm.org
Wed Feb 9 12:46:08 PST 2022


Author: Guillaume Chatelet
Date: 2022-02-09T20:45:56Z
New Revision: d2c595466207f5cc9b8cf01d66d3beaac134d02b

URL: https://github.com/llvm/llvm-project/commit/d2c595466207f5cc9b8cf01d66d3beaac134d02b
DIFF: https://github.com/llvm/llvm-project/commit/d2c595466207f5cc9b8cf01d66d3beaac134d02b.diff

LOG: [libc] undefined reference in LibcTest.cpp

GCC complains about undefined reference in LibcTest.cpp and indeed the wrong version of the template has been explicitly instanciated.
This is necessary to get llvm-libc compile with GCC.

Mentionning D119002 here for navigability.

Differential Revision: https://reviews.llvm.org/D119242

Added: 
    

Modified: 
    libc/utils/UnitTest/LibcTest.cpp

Removed: 
    


################################################################################
diff  --git a/libc/utils/UnitTest/LibcTest.cpp b/libc/utils/UnitTest/LibcTest.cpp
index c998337039a60..ed3ca4173c611 100644
--- a/libc/utils/UnitTest/LibcTest.cpp
+++ b/libc/utils/UnitTest/LibcTest.cpp
@@ -195,69 +195,70 @@ int Test::runTests(const char *TestFilter) {
   return FailCount > 0 || TestCount == 0 ? 1 : 0;
 }
 
-template bool Test::test<char, 0>(TestCondition Cond, char LHS, char RHS,
+namespace internal {
+
+template bool test<char>(RunContext *Ctx, TestCondition Cond, char LHS,
+                         char RHS, const char *LHSStr, const char *RHSStr,
+                         const char *File, unsigned long Line);
+
+template bool test<short>(RunContext *Ctx, TestCondition Cond, short LHS,
+                          short RHS, const char *LHSStr, const char *RHSStr,
+                          const char *File, unsigned long Line);
+
+template bool test<int>(RunContext *Ctx, TestCondition Cond, int LHS, int RHS,
+                        const char *LHSStr, const char *RHSStr,
+                        const char *File, unsigned long Line);
+
+template bool test<long>(RunContext *Ctx, TestCondition Cond, long LHS,
+                         long RHS, const char *LHSStr, const char *RHSStr,
+                         const char *File, unsigned long Line);
+
+template bool test<long long>(RunContext *Ctx, TestCondition Cond,
+                              long long LHS, long long RHS, const char *LHSStr,
+                              const char *RHSStr, const char *File,
+                              unsigned long Line);
+
+template bool test<__int128_t>(RunContext *Ctx, TestCondition Cond,
+                               __int128_t LHS, __int128_t RHS,
+                               const char *LHSStr, const char *RHSStr,
+                               const char *File, unsigned long Line);
+
+template bool test<unsigned char>(RunContext *Ctx, TestCondition Cond,
+                                  unsigned char LHS, unsigned char RHS,
                                   const char *LHSStr, const char *RHSStr,
                                   const char *File, unsigned long Line);
 
-template bool Test::test<short, 0>(TestCondition Cond, short LHS, short RHS,
+template bool test<unsigned short>(RunContext *Ctx, TestCondition Cond,
+                                   unsigned short LHS, unsigned short RHS,
                                    const char *LHSStr, const char *RHSStr,
                                    const char *File, unsigned long Line);
 
-template bool Test::test<int, 0>(TestCondition Cond, int LHS, int RHS,
+template bool test<unsigned int>(RunContext *Ctx, TestCondition Cond,
+                                 unsigned int LHS, unsigned int RHS,
                                  const char *LHSStr, const char *RHSStr,
                                  const char *File, unsigned long Line);
 
-template bool Test::test<long, 0>(TestCondition Cond, long LHS, long RHS,
+template bool test<unsigned long>(RunContext *Ctx, TestCondition Cond,
+                                  unsigned long LHS, unsigned long RHS,
                                   const char *LHSStr, const char *RHSStr,
                                   const char *File, unsigned long Line);
 
-template bool Test::test<long long, 0>(TestCondition Cond, long long LHS,
-                                       long long RHS, const char *LHSStr,
-                                       const char *RHSStr, const char *File,
-                                       unsigned long Line);
-
-template bool Test::test<__int128_t, 0>(TestCondition Cond, __int128_t LHS,
-                                        __int128_t RHS, const char *LHSStr,
-                                        const char *RHSStr, const char *File,
-                                        unsigned long Line);
-
-template bool Test::test<unsigned char, 0>(TestCondition Cond,
-                                           unsigned char LHS, unsigned char RHS,
-                                           const char *LHSStr,
-                                           const char *RHSStr, const char *File,
-                                           unsigned long Line);
-
-template bool
-Test::test<unsigned short, 0>(TestCondition Cond, unsigned short LHS,
-                              unsigned short RHS, const char *LHSStr,
-                              const char *RHSStr, const char *File,
-                              unsigned long Line);
-
-template bool Test::test<unsigned int, 0>(TestCondition Cond, unsigned int LHS,
-                                          unsigned int RHS, const char *LHSStr,
-                                          const char *RHSStr, const char *File,
-                                          unsigned long Line);
+template bool test<bool>(RunContext *Ctx, TestCondition Cond, bool LHS,
+                         bool RHS, const char *LHSStr, const char *RHSStr,
+                         const char *File, unsigned long Line);
 
-template bool Test::test<unsigned long, 0>(TestCondition Cond,
-                                           unsigned long LHS, unsigned long RHS,
-                                           const char *LHSStr,
-                                           const char *RHSStr, const char *File,
-                                           unsigned long Line);
+template bool test<unsigned long long>(RunContext *Ctx, TestCondition Cond,
+                                       unsigned long long LHS,
+                                       unsigned long long RHS,
+                                       const char *LHSStr, const char *RHSStr,
+                                       const char *File, unsigned long Line);
 
-template bool Test::test<bool, 0>(TestCondition Cond, bool LHS, bool RHS,
-                                  const char *LHSStr, const char *RHSStr,
-                                  const char *File, unsigned long Line);
+template bool test<__uint128_t>(RunContext *Ctx, TestCondition Cond,
+                                __uint128_t LHS, __uint128_t RHS,
+                                const char *LHSStr, const char *RHSStr,
+                                const char *File, unsigned long Line);
 
-template bool
-Test::test<unsigned long long, 0>(TestCondition Cond, unsigned long long LHS,
-                                  unsigned long long RHS, const char *LHSStr,
-                                  const char *RHSStr, const char *File,
-                                  unsigned long Line);
-
-template bool Test::test<__uint128_t, 0>(TestCondition Cond, __uint128_t LHS,
-                                         __uint128_t RHS, const char *LHSStr,
-                                         const char *RHSStr, const char *File,
-                                         unsigned long Line);
+} // namespace internal
 
 bool Test::testStrEq(const char *LHS, const char *RHS, const char *LHSStr,
                      const char *RHSStr, const char *File, unsigned long Line) {


        


More information about the libc-commits mailing list