[libcxx-commits] [libcxx] [libc++] Make sure the LLVM libc shared utilities use libc++'s assertion mechanism (PR #170149)
Louis Dionne via libcxx-commits
libcxx-commits at lists.llvm.org
Mon Dec 1 06:57:20 PST 2025
https://github.com/ldionne created https://github.com/llvm/llvm-project/pull/170149
Otherwise, they would use their own mechanism based on C assert. It's better to use the same assertion mechanism consistently everywhere since this code is considered an implementation detail of libc++.
>From 88f78df831124e6a1298f91190fc63517e945c98 Mon Sep 17 00:00:00 2001
From: Louis Dionne <ldionne.2 at gmail.com>
Date: Mon, 1 Dec 2025 09:55:31 -0500
Subject: [PATCH] [libc++] Make sure the LLVM libc shared utilities use
libc++'s assertion mechanism
Otherwise, they would use their own mechanism based on C assert. It's
better to use the same assertion mechanism consistently everywhere since
this code is considered an implementation detail of libc++.
---
libcxx/src/include/from_chars_floating_point.h | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/libcxx/src/include/from_chars_floating_point.h b/libcxx/src/include/from_chars_floating_point.h
index 19eeeb28fb08d..20f23d2bc267d 100644
--- a/libcxx/src/include/from_chars_floating_point.h
+++ b/libcxx/src/include/from_chars_floating_point.h
@@ -9,11 +9,6 @@
#ifndef _LIBCPP_SRC_INCLUDE_FROM_CHARS_FLOATING_POINT_H
#define _LIBCPP_SRC_INCLUDE_FROM_CHARS_FLOATING_POINT_H
-// These headers are in the shared LLVM-libc header library.
-#include "shared/fp_bits.h"
-#include "shared/str_to_float.h"
-#include "shared/str_to_integer.h"
-
#include <__assert>
#include <__config>
#include <cctype>
@@ -21,6 +16,15 @@
#include <concepts>
#include <limits>
+// Make sure we use libc++'s assertion machinery within the shared code we use
+// from LLVM libc.
+#define LIBC_ASSERT(cond) _LIBCPP_ASSERT((cond), _LIBCPP_TOSTRING(cond))
+
+// These headers are in the shared LLVM-libc header library.
+#include "shared/fp_bits.h"
+#include "shared/str_to_float.h"
+#include "shared/str_to_integer.h"
+
// Included for the _Floating_type_traits class
#include "to_chars_floating_point.h"
More information about the libcxx-commits
mailing list