Author: Sam McCall Date: 2024-04-18T16:26:08+02:00 New Revision: 7257c37357ee4540d6a63e5d2854b97f43ae2c49
URL: https://github.com/llvm/llvm-project/commit/7257c37357ee4540d6a63e5d2854b97f43ae2c49 DIFF: https://github.com/llvm/llvm-project/commit/7257c37357ee4540d6a63e5d2854b97f43ae2c49.diff LOG: [clang] fix -Wnullability-completeness false-positive in dependent code (#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. Added: Modified: clang/lib/Sema/SemaType.cpp clang/test/SemaObjCXX/Inputs/nullability-consistency-smart.h Removed: ################################################################################ diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp index 1b31df8d97fba2..fddc3545ecb61c 100644 --- a/clang/lib/Sema/SemaType.cpp +++ b/clang/lib/Sema/SemaType.cpp @@ -4729,7 +4729,8 @@ static bool shouldHaveNullability(QualType T) { // It's unclear whether the pragma's behavior is useful for C++. // e.g. treating type-aliases and template-type-parameters diff erently // from types of declarations can be surprising. - !isa<RecordType>(T->getCanonicalTypeInternal()); + !isa<RecordType, TemplateSpecializationType>( + T->getCanonicalTypeInternal()); } static TypeSourceInfo *GetFullTypeForDeclarator(TypeProcessingState &state, diff --git a/clang/test/SemaObjCXX/Inputs/nullability-consistency-smart.h b/clang/test/SemaObjCXX/Inputs/nullability-consistency-smart.h index a28532e5d71668..5ff974af57f49b 100644 --- a/clang/test/SemaObjCXX/Inputs/nullability-consistency-smart.h +++ b/clang/test/SemaObjCXX/Inputs/nullability-consistency-smart.h @@ -5,3 +5,7 @@ void f1(int * _Nonnull); void f2(Smart); // OK, not required on smart-pointer types using Alias = Smart; void f3(Alias); + +template <class T> class _Nullable SmartTmpl; +void f2(SmartTmpl<int>); +template <class T> void f2(SmartTmpl<T>); _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits