diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2021-07-29 20:15:26 +0000 |
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2021-07-29 20:15:26 +0000 |
| commit | 344a3780b2e33f6ca763666c380202b18aab72a3 (patch) | |
| tree | f0b203ee6eb71d7fdd792373e3c81eb18d6934dd /clang/lib/Sema/SemaTemplateDeduction.cpp | |
| parent | b60736ec1405bb0a8dd40989f67ef4c93da068ab (diff) | |
vendor/llvm-project/llvmorg-13-init-16847-g88e66fa60ae5vendor/llvm-project/llvmorg-12.0.1-rc2-0-ge7dac564cd0evendor/llvm-project/llvmorg-12.0.1-0-gfed41342a82f
Diffstat (limited to 'clang/lib/Sema/SemaTemplateDeduction.cpp')
| -rw-r--r-- | clang/lib/Sema/SemaTemplateDeduction.cpp | 34 |
1 files changed, 23 insertions, 11 deletions
diff --git a/clang/lib/Sema/SemaTemplateDeduction.cpp b/clang/lib/Sema/SemaTemplateDeduction.cpp index ee4316e7a632..08e798304b0c 100644 --- a/clang/lib/Sema/SemaTemplateDeduction.cpp +++ b/clang/lib/Sema/SemaTemplateDeduction.cpp @@ -455,11 +455,13 @@ static Sema::TemplateDeductionResult DeduceNullPtrTemplateArgument( const NonTypeTemplateParmDecl *NTTP, QualType NullPtrType, TemplateDeductionInfo &Info, SmallVectorImpl<DeducedTemplateArgument> &Deduced) { - Expr *Value = - S.ImpCastExprToType(new (S.Context) CXXNullPtrLiteralExpr( - S.Context.NullPtrTy, NTTP->getLocation()), - NullPtrType, CK_NullToPointer) - .get(); + Expr *Value = S.ImpCastExprToType( + new (S.Context) CXXNullPtrLiteralExpr(S.Context.NullPtrTy, + NTTP->getLocation()), + NullPtrType, + NullPtrType->isMemberPointerType() ? CK_NullToMemberPointer + : CK_NullToPointer) + .get(); return DeduceNonTypeTemplateArgument(S, TemplateParams, NTTP, DeducedTemplateArgument(Value), Value->getType(), Info, Deduced); @@ -3077,6 +3079,10 @@ Sema::DeduceTemplateArguments(ClassTemplatePartialSpecializationDecl *Partial, *this, Sema::ExpressionEvaluationContext::Unevaluated); SFINAETrap Trap(*this); + // This deduction has no relation to any outer instantiation we might be + // performing. + LocalInstantiationScope InstantiationScope(*this); + SmallVector<DeducedTemplateArgument, 4> Deduced; Deduced.resize(Partial->getTemplateParameters()->size()); if (TemplateDeductionResult Result @@ -3125,6 +3131,10 @@ Sema::DeduceTemplateArguments(VarTemplatePartialSpecializationDecl *Partial, *this, Sema::ExpressionEvaluationContext::Unevaluated); SFINAETrap Trap(*this); + // This deduction has no relation to any outer instantiation we might be + // performing. + LocalInstantiationScope InstantiationScope(*this); + SmallVector<DeducedTemplateArgument, 4> Deduced; Deduced.resize(Partial->getTemplateParameters()->size()); if (TemplateDeductionResult Result = ::DeduceTemplateArguments( @@ -3869,7 +3879,7 @@ static bool AdjustFunctionParmAndArgTypesForDeduction( // "lvalue reference to A" is used in place of A for type deduction. if (isForwardingReference(QualType(ParamRefType, 0), FirstInnerIndex) && Arg->isLValue()) { - if (S.getLangOpts().OpenCL) + if (S.getLangOpts().OpenCL && !ArgType.hasAddressSpace()) ArgType = S.Context.getAddrSpaceQualType(ArgType, LangAS::opencl_generic); ArgType = S.Context.getLValueReferenceType(ArgType); } @@ -3918,7 +3928,7 @@ static bool AdjustFunctionParmAndArgTypesForDeduction( if (isSimpleTemplateIdType(ParamType) || (isa<PointerType>(ParamType) && isSimpleTemplateIdType( - ParamType->getAs<PointerType>()->getPointeeType()))) + ParamType->castAs<PointerType>()->getPointeeType()))) TDF |= TDF_DerivedClass; return false; @@ -4695,10 +4705,9 @@ CheckDeducedPlaceholderConstraints(Sema &S, const AutoType &Type, llvm::raw_string_ostream OS(Buf); OS << "'" << Concept->getName(); if (TypeLoc.hasExplicitTemplateArgs()) { - OS << "<"; - for (const auto &Arg : Type.getTypeConstraintArguments()) - Arg.print(S.getPrintingPolicy(), OS); - OS << ">"; + printTemplateArgumentList( + OS, Type.getTypeConstraintArguments(), S.getPrintingPolicy(), + Type.getTypeConstraintConcept()->getTemplateParameters()); } OS << "'"; OS.flush(); @@ -5464,6 +5473,9 @@ static bool isAtLeastAsSpecializedAs(Sema &S, QualType T1, QualType T2, Deduced.end()); Sema::InstantiatingTemplate Inst(S, Info.getLocation(), P2, DeducedArgs, Info); + if (Inst.isInvalid()) + return false; + auto *TST1 = T1->castAs<TemplateSpecializationType>(); bool AtLeastAsSpecialized; S.runWithSufficientStackSpace(Info.getLocation(), [&] { |
