[libc-commits] [PATCH] D155899: [libc] Fix line reporting in assertion failure

Jon Chesterfield via Phabricator via libc-commits libc-commits at lists.llvm.org
Thu Jul 20 15:44:52 PDT 2023


This revision was automatically updated to reflect the committed changes.
Closed by commit rGbf0992c71844: [libc] Fix line reporting in assertion failure (authored by JonChesterfield).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D155899/new/

https://reviews.llvm.org/D155899

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
@@ -31,10 +31,11 @@
                                           const char *filename, unsigned line,
                                           const char *funcname) {
   char line_str[IntegerToString::dec_bufsize<unsigned>()];
-  IntegerToString::dec(line, line_str);
+  // 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_str);
+  __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: '");


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D155899.542710.patch
Type: text/x-patch
Size: 909 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libc-commits/attachments/20230720/fa368c86/attachment.bin>


More information about the libc-commits mailing list