Skip to content

Commit 24dd718

Browse files
sam-mccallahatanaka
authored andcommitted
[clang] fix -Wnullability-completeness false-positive in dependent code (llvm#88727)
The intent was that smart-pointers do not participate in completeness checks, but we failed to capture dependent `unique_ptr<T>`, which is not a RecordType but a TemplateSpecializationType. (cherry picked from commit 7257c37)
1 parent cf76425 commit 24dd718

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

clang/lib/Sema/SemaType.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4722,7 +4722,8 @@ static bool shouldHaveNullability(QualType T) {
47224722
// It's unclear whether the pragma's behavior is useful for C++.
47234723
// e.g. treating type-aliases and template-type-parameters differently
47244724
// from types of declarations can be surprising.
4725-
!isa<RecordType>(T->getCanonicalTypeInternal());
4725+
!isa<RecordType, TemplateSpecializationType>(
4726+
T->getCanonicalTypeInternal());
47264727
}
47274728

47284729
static TypeSourceInfo *GetFullTypeForDeclarator(TypeProcessingState &state,

clang/test/SemaObjCXX/Inputs/nullability-consistency-smart.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,7 @@ void f1(int * _Nonnull);
55
void f2(Smart); // OK, not required on smart-pointer types
66
using Alias = Smart;
77
void f3(Alias);
8+
9+
template <class T> class _Nullable SmartTmpl;
10+
void f2(SmartTmpl<int>);
11+
template <class T> void f2(SmartTmpl<T>);

0 commit comments

Comments
 (0)