[libcxx-commits] [PATCH] D120634: [Libcxx] Add <source_location> header.

Nikolas Klauser via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Sat Mar 5 17:14:00 PST 2022


philnik accepted this revision.
philnik added a comment.
This revision is now accepted and ready to land.

LGTM % comments.



================
Comment at: libcxx/include/source_location:67-72
+  _LIBCPP_HIDE_FROM_ABI constexpr uint_least32_t line() const noexcept { return __ptr_ ? __ptr_->_M_line : 0; }
+  _LIBCPP_HIDE_FROM_ABI constexpr uint_least32_t column() const noexcept { return __ptr_ ? __ptr_->_M_column : 0; }
+  _LIBCPP_HIDE_FROM_ABI constexpr const char* file_name() const noexcept { return __ptr_ ? __ptr_->_M_file_name : ""; }
+  _LIBCPP_HIDE_FROM_ABI constexpr const char* function_name() const noexcept {
+    return __ptr_ ? __ptr_->_M_function_name : "";
+  }
----------------
I'd like to see `__ptr_ != nullptr`


================
Comment at: libcxx/test/std/language.support/support.srcloc/general.pass.cpp:65
+      std::source_location::current();
+  assert(!strcmp(local.file_name(), "ss"));
+  assert(strstr(local.function_name(), "main"));
----------------
Could you `== 0` or cast one to `string_view` for comparison? The current code looks a lot like they should not be equal. Ditto below.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120634



More information about the libcxx-commits mailing list