[libcxx-commits] [PATCH] D123175: [libcxx] Add flag to disable __builtin_assume in _LIBCPP_ASSERT
Arthur Eubanks via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Apr 7 09:03:36 PDT 2022
This revision was not accepted when it landed; it landed in state "Needs Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rG0a77e633226b: [libcxx] Add flag to disable __builtin_assume in _LIBCPP_ASSERT (authored by aeubanks).
Changed prior to commit:
https://reviews.llvm.org/D123175?vs=420929&id=421237#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D123175/new/
https://reviews.llvm.org/D123175
Files:
libcxx/include/__assert
libcxx/test/libcxx/assertions/single_expression.sh.cpp
Index: libcxx/test/libcxx/assertions/single_expression.sh.cpp
===================================================================
--- libcxx/test/libcxx/assertions/single_expression.sh.cpp
+++ libcxx/test/libcxx/assertions/single_expression.sh.cpp
@@ -15,6 +15,9 @@
// RUN: %{build} -Wno-macro-redefined -D_LIBCPP_ENABLE_ASSERTIONS=0
// RUN: %{run}
+// RUN: %{build} -Wno-macro-redefined -D_LIBCPP_ENABLE_ASSERTIONS=0 -D_LIBCPP_ASSERTIONS_DISABLE_ASSUME
+// RUN: %{run}
+
// We flag uses of the assertion handler in older dylibs at compile-time to avoid runtime
// failures when back-deploying.
// XFAIL: use_system_cxx_lib && target={{.+}}-apple-macosx{{10.9|10.10|10.11|10.12|10.13|10.14|10.15|11.0|12.0}}
Index: libcxx/include/__assert
===================================================================
--- libcxx/include/__assert
+++ libcxx/include/__assert
@@ -38,16 +38,14 @@
(__builtin_expect(static_cast<bool>(expression), 1) ? \
(void)0 : \
::std::__libcpp_assertion_handler(__FILE__, __LINE__, #expression, message))
+#elif !defined(_LIBCPP_ASSERTIONS_DISABLE_ASSUME) && __has_builtin(__builtin_assume)
+# define _LIBCPP_ASSERT(expression, message) \
+ (_LIBCPP_DIAGNOSTIC_PUSH \
+ _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wassume") \
+ __builtin_assume(static_cast<bool>(expression)) \
+ _LIBCPP_DIAGNOSTIC_POP)
#else
-# if __has_builtin(__builtin_assume)
-# define _LIBCPP_ASSERT(expression, message) \
- (_LIBCPP_DIAGNOSTIC_PUSH \
- _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wassume") \
- __builtin_assume(static_cast<bool>(expression)) \
- _LIBCPP_DIAGNOSTIC_POP)
-# else
-# define _LIBCPP_ASSERT(expression, message) ((void)0)
-# endif
+# define _LIBCPP_ASSERT(expression, message) ((void)0)
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D123175.421237.patch
Type: text/x-patch
Size: 2205 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20220407/1291a9f6/attachment.bin>
More information about the libcxx-commits
mailing list