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

Tom Honermann via cfe-commits cfe-commits at lists.llvm.org
Thu Mar 14 14:22:25 PDT 2024


================
@@ -201,6 +201,21 @@ Attribute Changes in Clang
   and each must be a positive integer when provided. The parameter ``x`` is required, while ``y`` and
   ``z`` are optional with default value of 1.
 
+- The ``_Nullable`` and ``_Nonnull`` family of type attributes can now apply
+  to certain C++ class types, such as smart pointers:
+  ``void useObject(std::unique_ptr<Object> _Nonnull obj);``.
+
+  This works for standard library types including ``unique_ptr``, ``shared_ptr``
+  and ``function``. See `the attribute reference
+documentation <https://llvm.org/docs/AttributeReference.html#nullability-attributes>`_
+for the full list.
----------------
tahonermann wrote:

Doc builds seem to be unhappy with this change:
```
Warning, treated as error:
/home/runner/work/llvm-project/llvm-project/clang-build/tools/clang/docs/ReleaseNotes.rst:208:Inline interpreted text or phrase reference start-string without end-string.
```

The doc build run for this PR failed for a different reason that will be fixed by https://github.com/llvm/llvm-project/pull/85310.

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


More information about the cfe-commits mailing list