[libc-commits] [libc] [libc][test] Align custom matchers with GoogleMock (PR #240616)

via libc-commits libc-commits at lists.llvm.org
Mon Nov 9 21:11:21 PST 2026


llvmorg-github-actions[bot] wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-libc

Author: Roland McGrath (frobtech)

<details>
<summary>Changes</summary>

LibcTest custom matchers implemented stateful match(T) and explainError()
methods writing directly to tlog, whereas GoogleMock's polymorphic
is_gtest_matcher protocol expects const MatchAndExplain(T,
MatchResultListener *), DescribeTo, and DescribeNegationTo methods.

Add a hermetic MatchResultListener wrapper around TestLogger in
LibcTest.h and update custom matchers across libc/test and libc/utils to
implement MatchAndExplain(..., MatchResultListener *) const so they work
directly with GoogleMock's EXPECT_THAT and ASSERT_THAT without macro
redefinitions.

Depends on #<!-- -->240610
Part of #<!-- -->91630

Assisted-by: Gemini

---

Patch is 83.50 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/240616.diff


18 Files Affected:

- (modified) libc/test/UnitTest/ErrnoSetterMatcher.h (+52-39) 
- (modified) libc/test/UnitTest/FPExceptMatcher.h (+8-6) 
- (modified) libc/test/UnitTest/FPMatcher.h (+46-36) 
- (modified) libc/test/UnitTest/LibcTest.cpp (+5-14) 
- (modified) libc/test/UnitTest/LibcTest.h (+50-20) 
- (modified) libc/test/UnitTest/MemoryMatcher.cpp (+23-32) 
- (modified) libc/test/UnitTest/MemoryMatcher.h (+2-6) 
- (modified) libc/test/UnitTest/PrintfMatcher.cpp (+26-23) 
- (modified) libc/test/UnitTest/PrintfMatcher.h (+17-15) 
- (modified) libc/test/UnitTest/ScanfMatcher.cpp (+31-31) 
- (modified) libc/test/UnitTest/ScanfMatcher.h (+3-4) 
- (modified) libc/test/include/sys/queue_test.cpp (+17-4) 
- (modified) libc/test/src/sys/socket/linux/socket_test_support.h (+25-42) 
- (modified) libc/test/src/time/TmMatcher.h (+26-31) 
- (modified) libc/utils/MPCWrapper/MPCUtils.cpp (+12-8) 
- (modified) libc/utils/MPCWrapper/MPCUtils.h (+21-17) 
- (modified) libc/utils/MPFRWrapper/MPFRUtils.cpp (+203-168) 
- (modified) libc/utils/MPFRWrapper/MPFRUtils.h (+39-33) 


``````````diff
diff --git a/libc/test/UnitTest/ErrnoSetterMatcher.h b/libc/test/UnitTest/ErrnoSetterMatcher.h
index a7f21843e602c2..0776541dd818ba 100644
--- a/libc/test/UnitTest/ErrnoSetterMatcher.h
+++ b/libc/test/UnitTest/ErrnoSetterMatcher.h
@@ -37,6 +37,7 @@
 #include "src/__support/FPUtil/FPBits.h"
 #include "src/__support/FPUtil/fpbits_str.h"
 #include "src/__support/StringUtil/error_to_string.h"
+#include "src/__support/integer_to_string.h"
 #include "src/__support/libc_errno.h"
 #include "src/__support/macros/config.h"
 #include "src/__support/macros/properties/architectures.h"
@@ -62,7 +63,7 @@ constexpr const char *CompareMessage[] = {
 template <typename T> struct Comparator {
   CompareAction cmp;
   T expected;
-  bool compare(T actual) {
+  bool compare(T actual) const {
     switch (cmp) {
     case CompareAction::EQ:
       return actual == expected;
@@ -83,9 +84,9 @@ template <typename T> struct Comparator {
   // The NVPTX backend cannot handle circular dependencies on global variables.
   // We provide a constant dummy implementation to prevent this from occurring.
 #ifdef LIBC_TARGET_ARCH_IS_NVPTX
-  constexpr const char *str() { return ""; }
+  constexpr const char *str() const { return ""; }
 #else
-  const char *str() { return CompareMessage[static_cast<int>(cmp)]; }
+  const char *str() const { return CompareMessage[static_cast<int>(cmp)]; }
 #endif
 };
 
@@ -128,25 +129,25 @@ class ErrnoCheck {
     return false;
   }
 
-  void print_expected() const {
+  template <typename Stream> void print_expected(Stream &os) const {
     if (type == Type::EQ) {
       auto expected_str = try_get_errno_name(expected);
-      tlog << "equal to " << (expected_str ? *expected_str : "<unknown>") << "("
-           << expected << ")";
+      os << "equal to " << (expected_str ? *expected_str : "<unknown>") << "("
+         << expected << ")";
     } else if (type == Type::NE) {
       auto expected_str = try_get_errno_name(expected);
-      tlog << "not equal to " << (expected_str ? *expected_str : "<unknown>")
-           << "(" << expected << ")";
+      os << "not equal to " << (expected_str ? *expected_str : "<unknown>")
+         << "(" << expected << ")";
     } else if (type == Type::ANY_OF) {
-      tlog << "one of [";
+      os << "one of [";
       for (size_t i = 0; i < list_count; ++i) {
         auto expected_str = try_get_errno_name(expected_list[i]);
-        tlog << (expected_str ? *expected_str : "<unknown>") << "("
-             << expected_list[i] << ")";
+        os << (expected_str ? *expected_str : "<unknown>") << "("
+           << expected_list[i] << ")";
         if (i + 1 < list_count)
-          tlog << ", ";
+          os << ", ";
       }
-      tlog << "]";
+      os << "]";
     }
   }
 };
@@ -154,8 +155,8 @@ class ErrnoCheck {
 template <typename T> class ErrnoSetterMatcher : public Matcher<T> {
   Comparator<T> return_cmp;
   ErrnoCheck errno_cmp;
-  T actual_return;
-  int actual_errno;
+  mutable int actual_errno = 0;
+  mutable bool has_errno = false;
 
   // Even though this is a errno matcher primarily, it has to cater to platforms
   // which do not have an errno. This predicate checks if errno matching is to
@@ -178,39 +179,51 @@ template <typename T> class ErrnoSetterMatcher : public Matcher<T> {
     return *this;
   }
 
-  void explainError() override {
-    if (!return_cmp.compare(actual_return)) {
+  // NOLINTNEXTLINE(readability-identifier-naming)
+  bool MatchAndExplain(T got, MatchResultListener *listener) const {
+    if constexpr (!ignore_errno()) {
+      if (!has_errno) {
+        actual_errno = libc_errno;
+        libc_errno = 0;
+        has_errno = true;
+      }
+    }
+    bool ret_ok = return_cmp.compare(got);
+    bool errno_ok = ignore_errno() || errno_cmp.compare(actual_errno);
+    if (ret_ok && errno_ok)
+      return true;
+    if (!listener->IsInterested())
+      return false;
+
+    if (!ret_ok) {
       if constexpr (cpp::is_floating_point_v<T>) {
-        tlog << "Expected return value to be " << return_cmp.str() << ": "
-             << str(fputil::FPBits<T>(return_cmp.expected)) << '\n'
-             << "                    But got: "
-             << str(fputil::FPBits<T>(actual_return)) << '\n';
+        *listener << "Expected return value to be " << return_cmp.str() << ": "
+                  << str(fputil::FPBits<T>(return_cmp.expected)) << '\n'
+                  << "                    But got: "
+                  << str(fputil::FPBits<T>(got)) << '\n';
+      } else if constexpr (cpp::is_pointer_v<T>) {
+        const IntegerToString<uintptr_t, radix::Hex::WithPrefix> exp_hex(
+            reinterpret_cast<uintptr_t>(return_cmp.expected));
+        const IntegerToString<uintptr_t, radix::Hex::WithPrefix> got_hex(
+            reinterpret_cast<uintptr_t>(got));
+        *listener << "Expected return value to be " << return_cmp.str() << " "
+                  << exp_hex.view() << " but got " << got_hex.view() << ".\n";
       } else {
-        tlog << "Expected return value to be " << return_cmp.str() << " "
-             << return_cmp.expected << " but got " << actual_return << ".\n";
+        *listener << "Expected return value to be " << return_cmp.str() << " "
+                  << return_cmp.expected << " but got " << got << ".\n";
       }
     }
 
     if constexpr (!ignore_errno()) {
-      if (!errno_cmp.compare(actual_errno)) {
+      if (!errno_ok) {
         auto actual_str = try_get_errno_name(actual_errno);
-        tlog << "Expected errno to be ";
-        errno_cmp.print_expected();
-        tlog << " but got " << (actual_str ? *actual_str : "<unknown>") << "("
-             << actual_errno << ").\n";
+        *listener << "Expected errno to be ";
+        errno_cmp.print_expected(*listener);
+        *listener << " but got " << (actual_str ? *actual_str : "<unknown>")
+                  << "(" << actual_errno << ").\n";
       }
     }
-  }
-
-  bool match(T got) {
-    actual_return = got;
-    actual_errno = libc_errno;
-    libc_errno = 0;
-    if constexpr (ignore_errno())
-      return return_cmp.compare(actual_return);
-    else
-      return return_cmp.compare(actual_return) &&
-             errno_cmp.compare(actual_errno);
+    return false;
   }
 };
 
diff --git a/libc/test/UnitTest/FPExceptMatcher.h b/libc/test/UnitTest/FPExceptMatcher.h
index 732ac09557acbf..a3f9f7ec4537f0 100644
--- a/libc/test/UnitTest/FPExceptMatcher.h
+++ b/libc/test/UnitTest/FPExceptMatcher.h
@@ -12,7 +12,6 @@
 #include "src/__support/CPP/functional.h"
 #include "src/__support/macros/config.h"
 #include "test/UnitTest/Test.h"
-#include "test/UnitTest/TestLogger.h"
 
 #if LIBC_TEST_HAS_MATCHERS()
 
@@ -27,11 +26,14 @@ class FPExceptMatcher : public Matcher<bool> {
 public:
   explicit FPExceptMatcher(cpp::function_ref<void(void)> func);
 
-  bool match([[maybe_unused]] bool unused) { return exceptionRaised; }
-
-  void explainError() override {
-    tlog << "A floating point exception should have been raised but it "
-         << "wasn't\n";
+  // NOLINTNEXTLINE(readability-identifier-naming)
+  bool MatchAndExplain([[maybe_unused]] bool unused,
+                       MatchResultListener *listener) const {
+    if (exceptionRaised)
+      return true;
+    *listener << "A floating point exception should have been raised but it "
+              << "wasn't\n";
+    return false;
   }
 };
 
diff --git a/libc/test/UnitTest/FPMatcher.h b/libc/test/UnitTest/FPMatcher.h
index 314d8f4f1ef1e8..09ef3e181a4aef 100644
--- a/libc/test/UnitTest/FPMatcher.h
+++ b/libc/test/UnitTest/FPMatcher.h
@@ -37,13 +37,11 @@ template <typename T, TestCond Condition> class FPMatcher : public Matcher<T> {
                 "Unsupported FPMatcher test condition.");
 
   T expected;
-  T actual;
 
 public:
   FPMatcher(T expectedValue) : expected(expectedValue) {}
 
-  bool match(T actualValue) {
-    actual = actualValue;
+  bool match(T actual) const {
     fputil::FPBits<T> actualBits(actual), expectedBits(expected);
     if (Condition == TestCond::EQ)
       return (actualBits.is_nan() && expectedBits.is_nan()) ||
@@ -56,11 +54,17 @@ template <typename T, TestCond Condition> class FPMatcher : public Matcher<T> {
            (actualBits.uintval() != expectedBits.uintval());
   }
 
-  void explainError() override {
-    tlog << "Expected floating point value: "
-         << str(fputil::FPBits<T>(expected)) << '\n';
-    tlog << "Actual floating point value: " << str(fputil::FPBits<T>(actual))
-         << '\n';
+  // NOLINTNEXTLINE(readability-identifier-naming)
+  bool MatchAndExplain(T actual, MatchResultListener *listener) const {
+    if (match(actual))
+      return true;
+    if (listener->IsInterested()) {
+      *listener << "Expected floating point value: "
+                << str(fputil::FPBits<T>(expected)) << '\n'
+                << "Actual floating point value: "
+                << str(fputil::FPBits<T>(actual)) << '\n';
+    }
+    return false;
   }
 };
 
@@ -72,14 +76,13 @@ template <typename T, TestCond Condition> class CFPMatcher : public Matcher<T> {
                 "Unsupported CFPMatcher test condition.");
 
   T expected;
-  T actual;
 
 public:
   CFPMatcher(T expectedValue) : expected(expectedValue) {}
 
-  template <typename CFT> bool matchComplex() {
-    CFT *actualCmplxPtr = reinterpret_cast<CFT *>(&actual);
-    CFT *expectedCmplxPtr = reinterpret_cast<CFT *>(&expected);
+  template <typename CFT> bool matchComplex(T actual) const {
+    const CFT *actualCmplxPtr = reinterpret_cast<const CFT *>(&actual);
+    const CFT *expectedCmplxPtr = reinterpret_cast<const CFT *>(&expected);
     CFT actualReal = actualCmplxPtr[0];
     CFT actualImag = actualCmplxPtr[1];
     CFT expectedReal = expectedCmplxPtr[0];
@@ -107,62 +110,69 @@ template <typename T, TestCond Condition> class CFPMatcher : public Matcher<T> {
             actualImagBits.uintval() != expectedImagBits.uintval());
   }
 
-  template <typename CFT> void explainErrorComplex() {
-    CFT *actualCmplxPtr = reinterpret_cast<CFT *>(&actual);
-    CFT *expectedCmplxPtr = reinterpret_cast<CFT *>(&expected);
+  template <typename CFT>
+  void explainErrorComplex(T actual, MatchResultListener *listener) const {
+    const CFT *actualCmplxPtr = reinterpret_cast<const CFT *>(&actual);
+    const CFT *expectedCmplxPtr = reinterpret_cast<const CFT *>(&expected);
     CFT actualReal = actualCmplxPtr[0];
     CFT actualImag = actualCmplxPtr[1];
     CFT expectedReal = expectedCmplxPtr[0];
     CFT expectedImag = expectedCmplxPtr[1];
-    tlog << "Expected complex floating point value: "
-         << str(fputil::FPBits<CFT>(expectedReal)) + " + " +
-                str(fputil::FPBits<CFT>(expectedImag)) + "i"
-         << '\n';
-    tlog << "Actual complex floating point value: "
-         << str(fputil::FPBits<CFT>(actualReal)) + " + " +
-                str(fputil::FPBits<CFT>(actualImag)) + "i"
-         << '\n';
+    *listener << "Expected complex floating point value: "
+              << str(fputil::FPBits<CFT>(expectedReal)) + " + " +
+                     str(fputil::FPBits<CFT>(expectedImag)) + "i"
+              << '\n'
+              << "Actual complex floating point value: "
+              << str(fputil::FPBits<CFT>(actualReal)) + " + " +
+                     str(fputil::FPBits<CFT>(actualImag)) + "i"
+              << '\n';
   }
 
-  bool match(T actualValue) {
-    actual = actualValue;
+  bool match(T actual) const {
 #ifndef LIBC_COMPILER_IS_MSVC
     if constexpr (cpp::is_complex_type_same<T, _Complex float>())
-      return matchComplex<float>();
+      return matchComplex<float>(actual);
     else if constexpr (cpp::is_complex_type_same<T, _Complex double>())
-      return matchComplex<double>();
+      return matchComplex<double>(actual);
     else if constexpr (cpp::is_complex_type_same<T, _Complex long double>())
-      return matchComplex<long double>();
+      return matchComplex<long double>(actual);
 #ifdef LIBC_TYPES_HAS_CFLOAT16
     else if constexpr (cpp::is_complex_type_same<T, cfloat16>())
-      return matchComplex<float16>();
+      return matchComplex<float16>(actual);
 #endif // LIBC_TYPES_HAS_CFLOAT16
 #ifdef LIBC_TYPES_HAS_CFLOAT128
     else if constexpr (cpp::is_complex_type_same<T, cfloat128>())
-      return matchComplex<float128>();
+      return matchComplex<float128>(actual);
 #endif // LIBC_TYPES_HAS_CFLOAT128
 #else  // LIBC_COMPILER_IS_MSVC
+    (void)actual;
     return true;
 #endif // LIBC_COMPILER_IS_MSVC
   }
 
-  void explainError() override {
+  // NOLINTNEXTLINE(readability-identifier-naming)
+  bool MatchAndExplain(T actual, MatchResultListener *listener) const {
+    if (match(actual))
+      return true;
+    if (!listener->IsInterested())
+      return false;
 #ifndef LIBC_COMPILER_IS_MSVC
     if constexpr (cpp::is_complex_type_same<T, _Complex float>())
-      return explainErrorComplex<float>();
+      explainErrorComplex<float>(actual, listener);
     else if constexpr (cpp::is_complex_type_same<T, _Complex double>())
-      return explainErrorComplex<double>();
+      explainErrorComplex<double>(actual, listener);
     else if constexpr (cpp::is_complex_type_same<T, _Complex long double>())
-      return explainErrorComplex<long double>();
+      explainErrorComplex<long double>(actual, listener);
 #ifdef LIBC_TYPES_HAS_CFLOAT16
     else if constexpr (cpp::is_complex_type_same<T, cfloat16>())
-      return explainErrorComplex<float16>();
+      explainErrorComplex<float16>(actual, listener);
 #endif // LIBC_TYPES_HAS_CFLOAT16
 #ifdef LIBC_TYPES_HAS_CFLOAT128
     else if constexpr (cpp::is_complex_type_same<T, cfloat128>())
-      return explainErrorComplex<float128>();
+      explainErrorComplex<float128>(actual, listener);
 #endif // LIBC_TYPES_HAS_CFLOAT128
 #endif // LIBC_COMPILER_IS_MSVC
+    return false;
   }
 };
 
diff --git a/libc/test/UnitTest/LibcTest.cpp b/libc/test/UnitTest/LibcTest.cpp
index a00d0ff32f1153..6b767a0103f107 100644
--- a/libc/test/UnitTest/LibcTest.cpp
+++ b/libc/test/UnitTest/LibcTest.cpp
@@ -313,21 +313,12 @@ bool test_str_ne(const wchar_t *LHS, const wchar_t *RHS, const char *LHSStr,
                    RHSStr, Loc);
 }
 
-} // namespace internal
-
-bool Test::testMatch(bool MatchResult, MatcherBase &Matcher, const char *LHSStr,
-                     const char *RHSStr, internal::Location Loc) {
-  if (MatchResult)
-    return true;
-
-  internal::current_context->markFail();
-  if (!Matcher.is_silent()) {
-    tlog << Loc;
-    tlog << "Failed to match " << LHSStr << " against " << RHSStr << ".\n";
-    Matcher.explainError();
-  }
-  return false;
+void mark_match_failure(const char *LHSStr, const char *RHSStr, Location Loc) {
+  current_context->markFail();
+  tlog << Loc;
+  tlog << "Failed to match " << LHSStr << " against " << RHSStr << ".\n";
 }
 
+} // namespace internal
 } // namespace testing
 } // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/test/UnitTest/LibcTest.h b/libc/test/UnitTest/LibcTest.h
index f0a951bd5777fd..fa4117fb21b736 100644
--- a/libc/test/UnitTest/LibcTest.h
+++ b/libc/test/UnitTest/LibcTest.h
@@ -44,17 +44,42 @@ namespace testing {
 // conditions for such cases.
 enum class TestCond { EQ, NE, LT, LE, GT, GE };
 
-struct MatcherBase {
-  virtual ~MatcherBase() {}
-  virtual void explainError() { tlog << "unknown error\n"; }
-  // Override and return true to skip `explainError` step.
-  virtual bool is_silent() const { return false; }
+// Source-compatible with GoogleMock's ::testing::MatchResultListener so custom
+// matchers work unchanged under both LibcTest and GoogleTest.
+class MatchResultListener {
+  TestLogger *logger;
+
+public:
+  LIBC_INLINE explicit MatchResultListener(TestLogger *logger)
+      : logger(logger) {}
+
+  LIBC_INLINE TestLogger *stream() { return logger; }
+  LIBC_INLINE bool IsInterested() const { return logger != nullptr; }
+
+  template <typename T>
+  LIBC_INLINE MatchResultListener &operator<<(const T &val) {
+    if (logger != nullptr)
+      *logger << val;
+    return *this;
+  }
 };
 
-template <typename T> struct Matcher : public MatcherBase {
-  bool match(const T &t);
+struct MatcherBase {
+  using is_gtest_matcher = void;
+
+  // NOLINTNEXTLINE(readability-identifier-naming)
+  template <typename Stream> LIBC_INLINE void DescribeTo(Stream *os) const {
+    *os << "matches";
+  }
+
+  // NOLINTNEXTLINE(readability-identifier-naming)
+  template <typename Stream>
+  LIBC_INLINE void DescribeNegationTo(Stream *os) const {
+    *os << "does not match";
+  }
 };
 
+template <typename T> struct Matcher : public MatcherBase {};
 namespace internal {
 
 // A simple location object to allow consistent passing of __FILE__ and
@@ -177,6 +202,20 @@ bool test_str_ne(const char *LHS, const char *RHS, const char *LHSStr,
 bool test_str_ne(const wchar_t *LHS, const wchar_t *RHS, const char *LHSStr,
                  const char *RHSStr, internal::Location Loc);
 
+void mark_match_failure(const char *LHSStr, const char *RHSStr, Location Loc);
+
+template <typename MatcherT, typename ValType>
+LIBC_INLINE bool match_and_explain(const MatcherT &Matcher,
+                                   const ValType &Value, const char *MatcherStr,
+                                   const char *ValueStr, Location Loc) {
+  MatchResultListener NullListener(nullptr);
+  if (Matcher.MatchAndExplain(Value, &NullListener))
+    return true;
+  mark_match_failure(ValueStr, MatcherStr, Loc);
+  MatchResultListener Listener(&tlog);
+  Matcher.MatchAndExplain(Value, &Listener);
+  return false;
+}
 } // namespace internal
 
 struct TestOptions {
@@ -205,16 +244,6 @@ class Test {
 protected:
   static void addTest(Test *T);
 
-  bool testMatch(bool MatchResult, MatcherBase &Matcher, const char *LHSStr,
-                 const char *RHSStr, internal::Location Loc);
-
-  template <typename MatcherT, typename ValType>
-  bool matchAndExplain(MatcherT &&Matcher, ValType Value,
-                       const char *MatcherStr, const char *ValueStr,
-                       internal::Location Loc) {
-    return testMatch(Matcher.match(Value), Matcher, ValueStr, MatcherStr, Loc);
-  }
-
   bool testProcessExits(cpp::function_ref<void(void)> Func, int ExitCode,
                         const char *LHSStr, const char *RHSStr,
                         internal::Location Loc);
@@ -539,9 +568,10 @@ CString libc_make_test_file_path_func(const char *file_name);
 // Custom matcher checks.
 
 #define LIBC_TEST_MATCH_(MATCHER, MATCH, MATCHER_STR, MATCH_STR, RET_OR_EMPTY) \
-  LIBC_TEST_SCAFFOLDING_(matchAndExplain(MATCHER, MATCH, MATCHER_STR,          \
-                                         MATCH_STR, LIBC_TEST_LOC_()),         \
-                         RET_OR_EMPTY)
+  LIBC_TEST_SCAFFOLDING_(                                                      \
+      LIBC_NAMESPACE::testing::internal::match_and_explain(                    \
+          MATCHER, MATCH, MATCHER_STR, MATCH_STR, LIBC_TEST_LOC_()),           \
+      RET_OR_EMPTY)
 
 #define EXPECT_THAT(MATCH, MATCHER)                                            \
   LIBC_TEST_MATCH_(MATCHER, MATCH, #MATCHER, #MATCH, )
diff --git a/libc/test/UnitTest/MemoryMatcher.cpp b/libc/test/UnitTest/MemoryMatcher.cpp
index 405f226798f7a5..f42dd99255f9ee 100644
--- a/libc/test/UnitTest/MemoryMatcher.cpp
+++ b/libc/test/UnitTest/MemoryMatcher.cpp
@@ -14,8 +14,6 @@
 
 #if LIBC_TEST_HAS_MATCHERS()
 
-using LIBC_NAMESPACE::testing::tlog;
-
 namespace LIBC_NAMESPACE_DECL {
 namespace testing {
 
@@ -34,49 +32,42 @@ bool equals(const cpp::span<T> &Span1, const cpp::span<T> &Span2,
   return true;
 }
 
-bool MemoryMatcher::match(MemoryView actualValue) {
-  actual = actualValue;
-  return equals(expected, actual, mismatch_size, mismatch_index);
-}
-
-static void display(char C) {
-  const auto print = [](unsigned char i) {
-    tlog << LIBC_NAMESPACE::internal::toupper(
+static void display(MatchResultListener &listener, char C) {
+  const auto print = [&listener](unsigned char i) {
+    listener << LIBC_NAMESPACE::internal::toupper(
         LIBC_NAMESPACE::internal::int_to_b36_char(i));
   };
   print(static_cast<unsigned char>(C) / 16);
   print(static_cast<unsigned char>(C) & 15);
 }
 
-static void display(MemoryView View) {
+static void display(MatchResultListener &listener, MemoryView View) {
   for (auto C : View) {
-    tlog << ' ';
-    display(C);
+    listener << ' ';
+    display(listener, C);
   }
 }
 
-void MemoryMatch...
[truncated]

``````````

</details>


https://github.com/llvm/llvm-project/pull/240616


More information about the libc-commits mailing list