Skip to content

Commit 172bb12

Browse files
committed
Address review comments
1 parent ebf3703 commit 172bb12

File tree

4 files changed

+9
-6
lines changed

4 files changed

+9
-6
lines changed

clang/include/clang/Basic/AttrDocs.td

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4152,10 +4152,11 @@ non-underscored keywords. For example:
41524152
@property (readonly, nonnull) NSArray *subviews;
41534153
@end
41544154

4155-
As well as built-in pointer types, ithe nullability attributes can be attached
4156-
to nullable types from the C++ standard library such as ``std::unique_ptr`` and
4157-
``std::function``, as well as C++ classes marked with the ``_Nullable``
4158-
attribute.
4155+
As well as built-in pointer types, the nullability attributes can be attached
4156+
to C++ classes marked with the ``_Nullable`` attribute, as well as the C++
4157+
standard library types ``unique_ptr``, ``shared_ptr``, ``auto_ptr``,
4158+
``exception_ptr``, ``function``, ``move_only_function`` and
4159+
``coroutine_handle``.
41594160
}];
41604161
}
41614162

clang/lib/Sema/SemaDeclAttr.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5981,7 +5981,7 @@ static void handleNullableTypeAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
59815981
return;
59825982

59835983
if (auto *CRD = dyn_cast<CXXRecordDecl>(D);
5984-
!D || !(CRD->isClass() || CRD->isStruct())) {
5984+
!CRD || !(CRD->isClass() || CRD->isStruct())) {
59855985
S.Diag(AL.getRange().getBegin(), diag::err_attribute_wrong_decl_type_str)
59865986
<< AL << AL.isRegularKeywordAttribute() << "classes";
59875987
return;

clang/test/Sema/nullability.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,3 +248,5 @@ void arraysInBlocks(void) {
248248
void (^withTypedefBad)(INTS _Nonnull [2]) = // expected-error {{nullability specifier '_Nonnull' cannot be applied to non-pointer type 'INTS' (aka 'int[4]')}}
249249
^(INTS _Nonnull x[2]) {}; // expected-error {{nullability specifier '_Nonnull' cannot be applied to non-pointer type 'INTS' (aka 'int[4]')}}
250250
}
251+
252+
struct _Nullable NotCplusplusClass {}; // expected-error {{'_Nullable' attribute only applies to classes}}

clang/test/SemaCXX/nullability.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ void AssignAndInitNonNullFromFn() {
155155
SmartPtr _Nonnull s_nonnull;
156156
s_nonnull = ReturnSmartNullable(); // expected-warning{{implicit conversion from nullable pointer 'SmartPtr _Nullable' to non-nullable pointer type 'SmartPtr _Nonnull'}}
157157
s_nonnull = {ReturnSmartNullable()};
158-
TakeSmartNonnull(ReturnSmartNullable()); //expected-warning{{implicit conversion from nullable pointer 'SmartPtr _Nullable' to non-nullable pointer type 'SmartPtr _Nonnull}}
158+
TakeSmartNonnull(ReturnSmartNullable()); // expected-warning{{implicit conversion from nullable pointer 'SmartPtr _Nullable' to non-nullable pointer type 'SmartPtr _Nonnull'}}
159159
}
160160

161161
void ConditionalExpr(bool c) {

0 commit comments

Comments
 (0)