Don't emit `-Wnullability-completeness` warnings on `weak` Objective-C properties.
authorMichael Wyman <michael@mwyman.com>
Wed, 19 Oct 2022 20:11:41 +0000 (13:11 -0700)
committerMichael Wyman <michael@mwyman.com>
Fri, 21 Oct 2022 05:42:24 +0000 (22:42 -0700)
commit34020d39b8a116770aad0b5ad1a450e6e22da5cd
tree6ddc6619f44d0535d56ce56d814ccd7e8c81d78e
parente5f6ad2212ac4d871c69fb1320c998094b97f278
Don't emit `-Wnullability-completeness` warnings on `weak` Objective-C properties.

Zeroing weak references are by definition `nullable`, and adding
`nonnull` or `_Nullable` yields a mutual-exclusivity error. When
`-Wnullability-completeness` is enabled, however, non-audited header
regions require adding the `nullable` property keyword to avoid a
warning. This should be unnecessary, since it restates known nullability
of the `weak` property.

Additionally, the fix-it hints are both non-idiomatic Objective-C
(adding `_Nullable` to the property's pointer type rather than in the
`@property` attributes) and suggest the option of adding `_Nonnull`,
which would be an error.

Differential Revision: https://reviews.llvm.org/D128031
clang/lib/Sema/SemaType.cpp
clang/test/SemaObjCXX/Inputs/nullability-consistency-2.h