|
43 | 43 | #include "llvm/ADT/APSInt.h"
|
44 | 44 | #include "llvm/ADT/ArrayRef.h"
|
45 | 45 | #include "llvm/ADT/FoldingSet.h"
|
| 46 | +#include "llvm/ADT/STLExtras.h" |
46 | 47 | #include "llvm/ADT/SmallVector.h"
|
47 | 48 | #include "llvm/Support/Casting.h"
|
48 | 49 | #include "llvm/Support/ErrorHandling.h"
|
@@ -4774,7 +4775,10 @@ bool Type::canHaveNullability(bool ResultIfUnknown) const {
|
4774 | 4775 | ->getTemplateName()
|
4775 | 4776 | .getAsTemplateDecl())
|
4776 | 4777 | if (auto *CTD = dyn_cast<ClassTemplateDecl>(templateDecl))
|
4777 |
| - return CTD->getTemplatedDecl()->hasAttr<TypeNullableAttr>(); |
| 4778 | + return llvm::any_of( |
| 4779 | + CTD->redecls(), [](const RedeclarableTemplateDecl *RTD) { |
| 4780 | + return RTD->getTemplatedDecl()->hasAttr<TypeNullableAttr>(); |
| 4781 | + }); |
4778 | 4782 | return ResultIfUnknown;
|
4779 | 4783 |
|
4780 | 4784 | case Type::Builtin:
|
@@ -4841,10 +4845,14 @@ bool Type::canHaveNullability(bool ResultIfUnknown) const {
|
4841 | 4845 | // For template specializations, look only at primary template attributes.
|
4842 | 4846 | // This is a consistent regardless of whether the instantiation is known.
|
4843 | 4847 | if (const auto *CTSD = dyn_cast<ClassTemplateSpecializationDecl>(RD))
|
4844 |
| - return CTSD->getSpecializedTemplate() |
4845 |
| - ->getTemplatedDecl() |
4846 |
| - ->hasAttr<TypeNullableAttr>(); |
4847 |
| - return RD->hasAttr<TypeNullableAttr>(); |
| 4848 | + return llvm::any_of( |
| 4849 | + CTSD->getSpecializedTemplate()->redecls(), |
| 4850 | + [](const RedeclarableTemplateDecl *RTD) { |
| 4851 | + return RTD->getTemplatedDecl()->hasAttr<TypeNullableAttr>(); |
| 4852 | + }); |
| 4853 | + return llvm::any_of(RD->redecls(), [](const TagDecl *RD) { |
| 4854 | + return RD->hasAttr<TypeNullableAttr>(); |
| 4855 | + }); |
4848 | 4856 | }
|
4849 | 4857 |
|
4850 | 4858 | // Non-pointer types.
|
|
0 commit comments