[libcxx-commits] [libcxx] [libc++] Make sure the LLVM libc shared utilities use libc++'s assertion mechanism (PR #170149)

via libcxx-commits libcxx-commits at lists.llvm.org
Mon Dec 1 06:57:54 PST 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-libcxx

Author: Louis Dionne (ldionne)

<details>
<summary>Changes</summary>

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++.

---
Full diff: https://github.com/llvm/llvm-project/pull/170149.diff


1 Files Affected:

- (modified) libcxx/src/include/from_chars_floating_point.h (+9-5) 


``````````diff
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"
 

``````````

</details>


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


More information about the libcxx-commits mailing list