aboutsummaryrefslogtreecommitdiff
path: root/libcxx/src/filesystem/operations.cpp
diff options
context:
space:
mode:
authorKonstantin Varlamov <varconsteq@gmail.com>2024-01-20 23:38:02 -0800
committerGitHub <noreply@github.com>2024-01-20 23:38:02 -0800
commitdc57752031fb14166dff2174b36c28d27d742382 (patch)
treec7a200f598952b0ea44d778bd017e1878ad2bce3 /libcxx/src/filesystem/operations.cpp
parentf0c920ffb7e98adbad369c33c01e0996260c4ade (diff)
downloadllvm-dc57752031fb14166dff2174b36c28d27d742382.zip
llvm-dc57752031fb14166dff2174b36c28d27d742382.tar.gz
llvm-dc57752031fb14166dff2174b36c28d27d742382.tar.bz2
[libc++][hardening] Categorize assertions that produce incorrect results (#77183)
Introduce a new `argument-within-domain` category that covers cases where the given arguments make it impossible to produce a correct result (or create a valid object in case of constructors). While the incorrect result doesn't create an immediate problem within the library (like e.g. a null pointer dereference would), it always indicates a logic error in user code and is highly likely to lead to a bug in the program once the value is used.
Diffstat (limited to 'libcxx/src/filesystem/operations.cpp')
-rw-r--r--libcxx/src/filesystem/operations.cpp5
1 files changed, 2 insertions, 3 deletions
diff --git a/libcxx/src/filesystem/operations.cpp b/libcxx/src/filesystem/operations.cpp
index 6bee340..8a7d6cc 100644
--- a/libcxx/src/filesystem/operations.cpp
+++ b/libcxx/src/filesystem/operations.cpp
@@ -608,10 +608,9 @@ void __permissions(const path& p, perms prms, perm_options opts, error_code* ec)
const bool resolve_symlinks = !has_opt(perm_options::nofollow);
const bool add_perms = has_opt(perm_options::add);
const bool remove_perms = has_opt(perm_options::remove);
- _LIBCPP_ASSERT_UNCATEGORIZED(
+ _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN(
(add_perms + remove_perms + has_opt(perm_options::replace)) == 1,
- "One and only one of the perm_options constants replace, add, or remove "
- "is present in opts");
+ "One and only one of the perm_options constants 'replace', 'add', or 'remove' must be present in opts");
bool set_sym_perms = false;
prms &= perms::mask;