[libcxx-commits] [PATCH] D155866: [libc++][hardening] Don't trigger uncategorized assertions in the hardened mode.

Konstantin Varlamov via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Thu Jul 20 18:07:29 PDT 2023


var-const marked an inline comment as done.
var-const added inline comments.


================
Comment at: libcxx/include/__config:287
 #    define _LIBCPP_ASSERT_INTERNAL(expression, message)               _LIBCPP_ASSUME(expression)
+#    define _LIBCPP_ASSERT_UNCATEGORIZED(expression, message)          _LIBCPP_ASSUME(expression)
 
----------------
ldionne wrote:
> Mordante wrote:
> > I noticed there are quite a number of cheap tests in this category. For example `nullptr` guards in `std::string`. Would it make sense to put them in a "cheap-to-test-category". Maybe a `_LIBCPP_ASSERT_PRECONDITION`?
> I suggest we discuss this in D155873.
@Mordante I think it would be easier to discuss in the other patch like @ldionne suggested above because it deals with some of those assertions (including the `nullptr` guards in string).


================
Comment at: libcxx/test/libcxx/algorithms/alg.sorting/assert.min.max.pass.cpp:13
 // UNSUPPORTED: c++03, c++11, c++14, c++17
 // UNSUPPORTED: !libcpp-has-hardened-mode && !libcpp-has-debug-mode
 // XFAIL: availability-verbose_abort-missing
----------------
ldionne wrote:
> As a follow-up patch, I think we could do this:
> 
> ```
> # This,
> AddFeature("libcpp-has-hardened-mode")             if hardening_mode == "hardened" else None,
> AddFeature("libcpp-has-debug-mode")                if hardening_mode == "debug" else None,
> AddFeature("libcpp-has-unchecked-mode")            if hardening_mode == "unchecked" else None,
> 
> # Or that
> AddFeature(f"libcpp-hardening-mode={hardening_mode}")
> ```
> 
> And then we could switch to `// UNSUPPORTED: libcpp-has-unchecked-mode` (or the other syntax). This would be a bit easier to understand.
> 
https://reviews.llvm.org/D155906


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155866



More information about the libcxx-commits mailing list