[libc-commits] [PATCH] D156275: [libc] Add back report_assertion_failure
Michael Jones via Phabricator via libc-commits
libc-commits at lists.llvm.org
Tue Jul 25 16:35:11 PDT 2023
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG49eb1aed89c0: [libc] Add back report_assertion_failure (authored by michaelrj).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D156275/new/
https://reviews.llvm.org/D156275
Files:
libc/src/__support/libc_assert.h
Index: libc/src/__support/libc_assert.h
===================================================================
--- libc/src/__support/libc_assert.h
+++ libc/src/__support/libc_assert.h
@@ -25,6 +25,28 @@
#include "src/__support/integer_to_string.h"
#include "src/__support/macros/attributes.h" // For LIBC_INLINE
+namespace __llvm_libc {
+
+// This is intended to be removed in a future patch to use a similar design to
+// below, but it's necessary for the external assert.
+LIBC_INLINE void report_assertion_failure(const char *assertion,
+ const char *filename, unsigned line,
+ const char *funcname) {
+ char line_str[IntegerToString::dec_bufsize<unsigned>()];
+ // dec returns an optional, will always be valid for this size buffer
+ auto line_number = IntegerToString::dec(line, line_str);
+ __llvm_libc::write_to_stderr(filename);
+ __llvm_libc::write_to_stderr(":");
+ __llvm_libc::write_to_stderr(*line_number);
+ __llvm_libc::write_to_stderr(": Assertion failed: '");
+ __llvm_libc::write_to_stderr(assertion);
+ __llvm_libc::write_to_stderr("' in function: '");
+ __llvm_libc::write_to_stderr(funcname);
+ __llvm_libc::write_to_stderr("'\n");
+}
+
+} // namespace __llvm_libc
+
#ifdef LIBC_ASSERT
#error "Unexpected: LIBC_ASSERT macro already defined"
#endif
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D156275.544145.patch
Type: text/x-patch
Size: 1367 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libc-commits/attachments/20230725/23b117e7/attachment-0001.bin>
More information about the libc-commits
mailing list