[clang] [clang][nullability] allow _Nonnull etc on nullable class types (PR #82705)

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Wed Mar 13 08:37:10 PDT 2024


================
@@ -4096,6 +4096,18 @@ non-underscored keywords. For example:
       @property (assign, nullable) NSView *superview;
       @property (readonly, nonnull) NSArray *subviews;
     @end
+
+As well as built-in pointer types, the nullability attributes can be attached
+to C++ classes marked with the ``_Nullable`` attribute.
+
+The following C++ standard library types are considered nullable:
+``unique_ptr``, ``shared_ptr``, ``auto_ptr``, ``exception_ptr``, ``function``,
+``move_only_function`` and ``coroutine_handle``.
+
+Types should be marked nullable only where the type itself leaves nullability
+ambiguous. For example, ``std::optional`` is not marked ``_Nullable``, because
----------------
AaronBallman wrote:

Should we mention `std::weak_ptr` here like we do for `std::optional`?

https://github.com/llvm/llvm-project/pull/82705


More information about the cfe-commits mailing list