[PATCH] D128031: Don't emit `-Wnullability-completeness` warnings on `weak` Objective-C properties.
Michael Wyman via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Jun 27 14:10:18 PDT 2022
mwyman updated this revision to Diff 440390.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D128031/new/
https://reviews.llvm.org/D128031
Files:
clang/lib/Sema/SemaType.cpp
clang/test/SemaObjCXX/Inputs/nullability-consistency-2.h
Index: clang/test/SemaObjCXX/Inputs/nullability-consistency-2.h
===================================================================
--- clang/test/SemaObjCXX/Inputs/nullability-consistency-2.h
+++ clang/test/SemaObjCXX/Inputs/nullability-consistency-2.h
@@ -19,13 +19,9 @@
@property (retain,nullable) SomeClass *property2;
- (nullable SomeClass *)method1;
- (void)method2:(nonnull SomeClass *)param;
- at property (readonly, weak) SomeClass *property3; // expected-warning{{missing a nullability type specifier}}
-// expected-note at -1 {{insert '_Nullable' if the pointer may be null}}
-// expected-note at -2 {{insert '_Nonnull' if the pointer should never be null}}
+ at property (readonly, weak) SomeClass *property3;
@end
@interface SomeClass ()
- at property (readonly, weak) SomeClass *property4; // expected-warning{{missing a nullability type specifier}}
-// expected-note at -1 {{insert '_Nullable' if the pointer may be null}}
-// expected-note at -2 {{insert '_Nonnull' if the pointer should never be null}}
+ at property (readonly, weak) SomeClass *property4;
@end
Index: clang/lib/Sema/SemaType.cpp
===================================================================
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -4683,8 +4683,13 @@
}
// Weak properties are inferred to be nullable.
- if (state.getDeclarator().isObjCWeakProperty() && inAssumeNonNullRegion) {
- inferNullability = NullabilityKind::Nullable;
+ if (state.getDeclarator().isObjCWeakProperty()) {
+ // Weak properties cannot be nonnull, and should not complain about
+ // missing nullable attributes during completeness checks.
+ complainAboutMissingNullability = CAMN_No;
+ if (inAssumeNonNullRegion) {
+ inferNullability = NullabilityKind::Nullable;
+ }
break;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D128031.440390.patch
Type: text/x-patch
Size: 1842 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220627/c1795bde/attachment.bin>
More information about the cfe-commits
mailing list