Skip to content

Commit ce4ac7a

Browse files
author
git apple-llvm automerger
committed
Merge commit '3426f9c4811d' from llvm.org/main into next
2 parents 06cfa9d + 3426f9c commit ce4ac7a

File tree

10 files changed

+200
-211
lines changed

10 files changed

+200
-211
lines changed

clang/include/clang/Sema/Sema.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12200,7 +12200,7 @@ class Sema final : public SemaBase {
1220012200
ASTTemplateArgsPtr TemplateArgsIn, SourceLocation RAngleLoc);
1220112201

1220212202
DeclResult ActOnVarTemplateSpecialization(
12203-
Scope *S, Declarator &D, TypeSourceInfo *DI, LookupResult &Previous,
12203+
Scope *S, Declarator &D, TypeSourceInfo *TSI, LookupResult &Previous,
1220412204
SourceLocation TemplateKWLoc, TemplateParameterList *TemplateParams,
1220512205
StorageClass SC, bool IsPartialSpecialization);
1220612206

clang/lib/AST/ASTContext.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3241,9 +3241,9 @@ TypeSourceInfo *ASTContext::CreateTypeSourceInfo(QualType T,
32413241

32423242
TypeSourceInfo *ASTContext::getTrivialTypeSourceInfo(QualType T,
32433243
SourceLocation L) const {
3244-
TypeSourceInfo *DI = CreateTypeSourceInfo(T);
3245-
DI->getTypeLoc().initialize(const_cast<ASTContext &>(*this), L);
3246-
return DI;
3244+
TypeSourceInfo *TSI = CreateTypeSourceInfo(T);
3245+
TSI->getTypeLoc().initialize(const_cast<ASTContext &>(*this), L);
3246+
return TSI;
32473247
}
32483248

32493249
const ASTRecordLayout &
@@ -6501,11 +6501,11 @@ TypeSourceInfo *ASTContext::getTemplateSpecializationTypeInfo(
65016501
QualType TST = getTemplateSpecializationType(
65026502
Keyword, Name, SpecifiedArgs.arguments(), CanonicalArgs, Underlying);
65036503

6504-
TypeSourceInfo *DI = CreateTypeSourceInfo(TST);
6505-
DI->getTypeLoc().castAs<TemplateSpecializationTypeLoc>().set(
6504+
TypeSourceInfo *TSI = CreateTypeSourceInfo(TST);
6505+
TSI->getTypeLoc().castAs<TemplateSpecializationTypeLoc>().set(
65066506
ElaboratedKeywordLoc, QualifierLoc, TemplateKeywordLoc, NameLoc,
65076507
SpecifiedArgs);
6508-
return DI;
6508+
return TSI;
65096509
}
65106510

65116511
QualType ASTContext::getTemplateSpecializationType(

clang/lib/Sema/SemaDeclObjC.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4801,13 +4801,13 @@ ParmVarDecl *SemaObjC::ActOnMethodParmDeclaration(Scope *S,
48014801
bool MethodDefinition) {
48024802
ASTContext &Context = getASTContext();
48034803
QualType ArgType;
4804-
TypeSourceInfo *DI;
4804+
TypeSourceInfo *TSI;
48054805

48064806
if (!ArgInfo.Type) {
48074807
ArgType = Context.getObjCIdType();
4808-
DI = nullptr;
4808+
TSI = nullptr;
48094809
} else {
4810-
ArgType = SemaRef.GetTypeFromParser(ArgInfo.Type, &DI);
4810+
ArgType = SemaRef.GetTypeFromParser(ArgInfo.Type, &TSI);
48114811
}
48124812
LookupResult R(SemaRef, ArgInfo.Name, ArgInfo.NameLoc,
48134813
Sema::LookupOrdinaryName,
@@ -4824,14 +4824,14 @@ ParmVarDecl *SemaObjC::ActOnMethodParmDeclaration(Scope *S,
48244824
}
48254825
}
48264826
SourceLocation StartLoc =
4827-
DI ? DI->getTypeLoc().getBeginLoc() : ArgInfo.NameLoc;
4827+
TSI ? TSI->getTypeLoc().getBeginLoc() : ArgInfo.NameLoc;
48284828

48294829
// Temporarily put parameter variables in the translation unit. This is what
48304830
// ActOnParamDeclarator does in the case of C arguments to the Objective-C
48314831
// method too.
48324832
ParmVarDecl *Param = SemaRef.CheckParameter(
48334833
Context.getTranslationUnitDecl(), StartLoc, ArgInfo.NameLoc, ArgInfo.Name,
4834-
ArgType, DI, SC_None);
4834+
ArgType, TSI, SC_None);
48354835
Param->setObjCMethodScopeInfo(ParamIndex);
48364836
Param->setObjCDeclQualifier(
48374837
CvtQTToAstBitMask(ArgInfo.DeclSpec.getObjCDeclQualifier()));

clang/lib/Sema/SemaTemplate.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -949,11 +949,11 @@ static TemplateArgumentLoc translateTemplateArgument(Sema &SemaRef,
949949

950950
switch (Arg.getKind()) {
951951
case ParsedTemplateArgument::Type: {
952-
TypeSourceInfo *DI;
953-
QualType T = SemaRef.GetTypeFromParser(Arg.getAsType(), &DI);
954-
if (!DI)
955-
DI = SemaRef.Context.getTrivialTypeSourceInfo(T, Arg.getNameLoc());
956-
return TemplateArgumentLoc(TemplateArgument(T), DI);
952+
TypeSourceInfo *TSI;
953+
QualType T = SemaRef.GetTypeFromParser(Arg.getAsType(), &TSI);
954+
if (!TSI)
955+
TSI = SemaRef.Context.getTrivialTypeSourceInfo(T, Arg.getNameLoc());
956+
return TemplateArgumentLoc(TemplateArgument(T), TSI);
957957
}
958958

959959
case ParsedTemplateArgument::NonType: {
@@ -4329,7 +4329,7 @@ void Sema::CheckDeductionGuideTemplate(FunctionTemplateDecl *TD) {
43294329
}
43304330

43314331
DeclResult Sema::ActOnVarTemplateSpecialization(
4332-
Scope *S, Declarator &D, TypeSourceInfo *DI, LookupResult &Previous,
4332+
Scope *S, Declarator &D, TypeSourceInfo *TSI, LookupResult &Previous,
43334333
SourceLocation TemplateKWLoc, TemplateParameterList *TemplateParams,
43344334
StorageClass SC, bool IsPartialSpecialization) {
43354335
// D must be variable template id.
@@ -4455,8 +4455,8 @@ DeclResult Sema::ActOnVarTemplateSpecialization(
44554455
VarTemplatePartialSpecializationDecl *Partial =
44564456
VarTemplatePartialSpecializationDecl::Create(
44574457
Context, VarTemplate->getDeclContext(), TemplateKWLoc,
4458-
TemplateNameLoc, TemplateParams, VarTemplate, DI->getType(), DI, SC,
4459-
CTAI.CanonicalConverted);
4458+
TemplateNameLoc, TemplateParams, VarTemplate, TSI->getType(), TSI,
4459+
SC, CTAI.CanonicalConverted);
44604460
Partial->setTemplateArgsAsWritten(TemplateArgs);
44614461

44624462
if (!PrevPartial)
@@ -4474,7 +4474,7 @@ DeclResult Sema::ActOnVarTemplateSpecialization(
44744474
// this explicit specialization or friend declaration.
44754475
Specialization = VarTemplateSpecializationDecl::Create(
44764476
Context, VarTemplate->getDeclContext(), TemplateKWLoc, TemplateNameLoc,
4477-
VarTemplate, DI->getType(), DI, SC, CTAI.CanonicalConverted);
4477+
VarTemplate, TSI->getType(), TSI, SC, CTAI.CanonicalConverted);
44784478
Specialization->setTemplateArgsAsWritten(TemplateArgs);
44794479

44804480
if (!PrevDecl)

clang/lib/Sema/SemaTemplateDeductionGuide.cpp

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -632,42 +632,42 @@ struct ConvertConstructorToDeductionGuideTransform {
632632
ParmVarDecl *OldParam, MultiLevelTemplateArgumentList &Args,
633633
llvm::SmallVectorImpl<TypedefNameDecl *> &MaterializedTypedefs,
634634
bool TransformingOuterPatterns) {
635-
TypeSourceInfo *OldDI = OldParam->getTypeSourceInfo();
636-
TypeSourceInfo *NewDI;
637-
if (auto PackTL = OldDI->getTypeLoc().getAs<PackExpansionTypeLoc>()) {
635+
TypeSourceInfo *OldTSI = OldParam->getTypeSourceInfo();
636+
TypeSourceInfo *NewTSI;
637+
if (auto PackTL = OldTSI->getTypeLoc().getAs<PackExpansionTypeLoc>()) {
638638
// Expand out the one and only element in each inner pack.
639639
Sema::ArgPackSubstIndexRAII SubstIndex(SemaRef, 0u);
640-
NewDI =
640+
NewTSI =
641641
SemaRef.SubstType(PackTL.getPatternLoc(), Args,
642642
OldParam->getLocation(), OldParam->getDeclName());
643-
if (!NewDI)
643+
if (!NewTSI)
644644
return nullptr;
645-
NewDI =
646-
SemaRef.CheckPackExpansion(NewDI, PackTL.getEllipsisLoc(),
645+
NewTSI =
646+
SemaRef.CheckPackExpansion(NewTSI, PackTL.getEllipsisLoc(),
647647
PackTL.getTypePtr()->getNumExpansions());
648648
} else
649-
NewDI = SemaRef.SubstType(OldDI, Args, OldParam->getLocation(),
650-
OldParam->getDeclName());
651-
if (!NewDI)
649+
NewTSI = SemaRef.SubstType(OldTSI, Args, OldParam->getLocation(),
650+
OldParam->getDeclName());
651+
if (!NewTSI)
652652
return nullptr;
653653

654654
// Extract the type. This (for instance) replaces references to typedef
655655
// members of the current instantiations with the definitions of those
656656
// typedefs, avoiding triggering instantiation of the deduced type during
657657
// deduction.
658-
NewDI = ExtractTypeForDeductionGuide(
659-
SemaRef, MaterializedTypedefs, NestedPattern,
660-
TransformingOuterPatterns ? &Args : nullptr)
661-
.transform(NewDI);
662-
if (!NewDI)
658+
NewTSI = ExtractTypeForDeductionGuide(
659+
SemaRef, MaterializedTypedefs, NestedPattern,
660+
TransformingOuterPatterns ? &Args : nullptr)
661+
.transform(NewTSI);
662+
if (!NewTSI)
663663
return nullptr;
664664
// Resolving a wording defect, we also inherit default arguments from the
665665
// constructor.
666666
ExprResult NewDefArg;
667667
if (OldParam->hasDefaultArg()) {
668668
// We don't care what the value is (we won't use it); just create a
669669
// placeholder to indicate there is a default argument.
670-
QualType ParamTy = NewDI->getType();
670+
QualType ParamTy = NewTSI->getType();
671671
NewDefArg = new (SemaRef.Context)
672672
OpaqueValueExpr(OldParam->getDefaultArgRange().getBegin(),
673673
ParamTy.getNonLValueExprType(SemaRef.Context),
@@ -676,13 +676,13 @@ struct ConvertConstructorToDeductionGuideTransform {
676676
: VK_PRValue);
677677
}
678678
// Handle arrays and functions decay.
679-
auto NewType = NewDI->getType();
679+
auto NewType = NewTSI->getType();
680680
if (NewType->isArrayType() || NewType->isFunctionType())
681681
NewType = SemaRef.Context.getDecayedType(NewType);
682682

683683
ParmVarDecl *NewParam = ParmVarDecl::Create(
684684
SemaRef.Context, DC, OldParam->getInnerLocStart(),
685-
OldParam->getLocation(), OldParam->getIdentifier(), NewType, NewDI,
685+
OldParam->getLocation(), OldParam->getIdentifier(), NewType, NewTSI,
686686
OldParam->getStorageClass(), NewDefArg.get());
687687
NewParam->setScopeInfo(OldParam->getFunctionScopeDepth(),
688688
OldParam->getFunctionScopeIndex());

clang/lib/Sema/SemaTemplateInstantiate.cpp

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3156,44 +3156,44 @@ Sema::SubstParmVarDecl(ParmVarDecl *OldParm,
31563156
const MultiLevelTemplateArgumentList &TemplateArgs,
31573157
int indexAdjustment, UnsignedOrNone NumExpansions,
31583158
bool ExpectParameterPack, bool EvaluateConstraint) {
3159-
TypeSourceInfo *OldDI = OldParm->getTypeSourceInfo();
3160-
TypeSourceInfo *NewDI = nullptr;
3159+
TypeSourceInfo *OldTSI = OldParm->getTypeSourceInfo();
3160+
TypeSourceInfo *NewTSI = nullptr;
31613161

3162-
TypeLoc OldTL = OldDI->getTypeLoc();
3162+
TypeLoc OldTL = OldTSI->getTypeLoc();
31633163
if (PackExpansionTypeLoc ExpansionTL = OldTL.getAs<PackExpansionTypeLoc>()) {
31643164

31653165
// We have a function parameter pack. Substitute into the pattern of the
31663166
// expansion.
3167-
NewDI = SubstType(ExpansionTL.getPatternLoc(), TemplateArgs,
3168-
OldParm->getLocation(), OldParm->getDeclName());
3169-
if (!NewDI)
3167+
NewTSI = SubstType(ExpansionTL.getPatternLoc(), TemplateArgs,
3168+
OldParm->getLocation(), OldParm->getDeclName());
3169+
if (!NewTSI)
31703170
return nullptr;
31713171

3172-
if (NewDI->getType()->containsUnexpandedParameterPack()) {
3172+
if (NewTSI->getType()->containsUnexpandedParameterPack()) {
31733173
// We still have unexpanded parameter packs, which means that
31743174
// our function parameter is still a function parameter pack.
31753175
// Therefore, make its type a pack expansion type.
3176-
NewDI = CheckPackExpansion(NewDI, ExpansionTL.getEllipsisLoc(),
3177-
NumExpansions);
3176+
NewTSI = CheckPackExpansion(NewTSI, ExpansionTL.getEllipsisLoc(),
3177+
NumExpansions);
31783178
} else if (ExpectParameterPack) {
31793179
// We expected to get a parameter pack but didn't (because the type
31803180
// itself is not a pack expansion type), so complain. This can occur when
31813181
// the substitution goes through an alias template that "loses" the
31823182
// pack expansion.
31833183
Diag(OldParm->getLocation(),
31843184
diag::err_function_parameter_pack_without_parameter_packs)
3185-
<< NewDI->getType();
3185+
<< NewTSI->getType();
31863186
return nullptr;
31873187
}
31883188
} else {
3189-
NewDI = SubstType(OldDI, TemplateArgs, OldParm->getLocation(),
3190-
OldParm->getDeclName());
3189+
NewTSI = SubstType(OldTSI, TemplateArgs, OldParm->getLocation(),
3190+
OldParm->getDeclName());
31913191
}
31923192

3193-
if (!NewDI)
3193+
if (!NewTSI)
31943194
return nullptr;
31953195

3196-
if (NewDI->getType()->isVoidType()) {
3196+
if (NewTSI->getType()->isVoidType()) {
31973197
Diag(OldParm->getLocation(), diag::err_param_with_void_type);
31983198
return nullptr;
31993199
}
@@ -3205,7 +3205,7 @@ Sema::SubstParmVarDecl(ParmVarDecl *OldParm,
32053205
// here, when the instantiated versions of those referenced parameters are in
32063206
// scope.
32073207
if (TemplateTypeParmDecl *TTP =
3208-
GetContainedInventedTypeParmVisitor().Visit(OldDI->getType())) {
3208+
GetContainedInventedTypeParmVisitor().Visit(OldTSI->getType())) {
32093209
if (const TypeConstraint *TC = TTP->getTypeConstraint()) {
32103210
auto *Inst = cast_or_null<TemplateTypeParmDecl>(
32113211
FindInstantiatedDecl(TTP->getLocation(), TTP, TemplateArgs));
@@ -3219,12 +3219,10 @@ Sema::SubstParmVarDecl(ParmVarDecl *OldParm,
32193219
}
32203220
}
32213221

3222-
ParmVarDecl *NewParm = CheckParameter(Context.getTranslationUnitDecl(),
3223-
OldParm->getInnerLocStart(),
3224-
OldParm->getLocation(),
3225-
OldParm->getIdentifier(),
3226-
NewDI->getType(), NewDI,
3227-
OldParm->getStorageClass());
3222+
ParmVarDecl *NewParm = CheckParameter(
3223+
Context.getTranslationUnitDecl(), OldParm->getInnerLocStart(),
3224+
OldParm->getLocation(), OldParm->getIdentifier(), NewTSI->getType(),
3225+
NewTSI, OldParm->getStorageClass());
32283226
if (!NewParm)
32293227
return nullptr;
32303228

0 commit comments

Comments
 (0)