Skip to content

Commit 7257c37

Browse files
authored
[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.
1 parent 9c51f9b commit 7257c37

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
@@ -4729,7 +4729,8 @@ static bool shouldHaveNullability(QualType T) {
47294729
// It's unclear whether the pragma's behavior is useful for C++.
47304730
// e.g. treating type-aliases and template-type-parameters differently
47314731
// from types of declarations can be surprising.
4732-
!isa<RecordType>(T->getCanonicalTypeInternal());
4732+
!isa<RecordType, TemplateSpecializationType>(
4733+
T->getCanonicalTypeInternal());
47334734
}
47344735

47354736
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)