[clang] [clang-tools-extra] [clang-tidy] `bugprone-unchecked-optional-access`: Improve handling of value constructors for `bsl::optional` and `bdlb::NullableValue` (PR #224969)
Jan Voung via cfe-commits
cfe-commits at lists.llvm.org
Fri Oct 2 06:45:00 PDT 2026
================
@@ -5,6 +5,32 @@
namespace bsl {
class string {};
+
+ template <typename T> class optional;
+
+ struct nullopt_t {
+ constexpr explicit nullopt_t() {}
+ };
+
+ constexpr nullopt_t nullopt;
+
+ struct in_place_t {
+ constexpr explicit in_place_t() {}
+ };
+
+ constexpr in_place_t in_place;
+
+ struct allocator_arg_t {
+ constexpr explicit allocator_arg_t() {}
+ };
+
+ constexpr allocator_arg_t allocator_arg;
+
+ /// Mock of the allocator type taken by the allocator-extended constructors.
+ class allocator {};
+
+ template <bool B, class T> struct enable_if {};
----------------
jvoung wrote:
Thanks!
I was wondering about both
- But, right -- after thinking again about the `bsl::optional` case the allocator-awareness would make it different.
- For the `bsl::enable_if` that seemed like it could be replaced more easily. It isn't being matched so it's really only in the test mocks, so not too bad.
https://github.com/llvm/llvm-project/pull/224969
More information about the cfe-commits
mailing list