[libcxx-commits] [PATCH] D143443: [libc++] Use __builtin_FILE and __builtin_LINE in _LIBCPP_ASSERT

Louis Dionne via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Mon Feb 6 16:13:33 PST 2023


ldionne created this revision.
Herald added a project: All.
ldionne requested review of this revision.
Herald added a project: libc++.
Herald added a subscriber: libcxx-commits.
Herald added a reviewer: libc++.

This avoids theoretical potential ODR violations since __LINE__ and
__FILE__ expand to different things depending on where they are.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D143443

Files:
  libcxx/include/__assert


Index: libcxx/include/__assert
===================================================================
--- libcxx/include/__assert
+++ libcxx/include/__assert
@@ -41,7 +41,7 @@
 # define _LIBCPP_ASSERT(expression, message)                                        \
     (__builtin_expect(static_cast<bool>(expression), 1) ?                           \
       (void)0 :                                                                     \
-      _LIBCPP_VERBOSE_ABORT("%s:%d: assertion %s failed: %s", __FILE__, __LINE__, #expression, message))
+      _LIBCPP_VERBOSE_ABORT("%s:%d: assertion %s failed: %s", __builtin_FILE(), __builtin_FILE(), #expression, message))
 #elif !defined(_LIBCPP_ASSERTIONS_DISABLE_ASSUME) && __has_builtin(__builtin_assume)
 # define _LIBCPP_ASSERT(expression, message)                                        \
     (_LIBCPP_DIAGNOSTIC_PUSH                                                        \


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D143443.495315.patch
Type: text/x-patch
Size: 922 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20230207/1df98eae/attachment.bin>


More information about the libcxx-commits mailing list