Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion clang/include/clang/Sema/Sema.h
Original file line number Diff line number Diff line change
Expand Up @@ -11668,7 +11668,7 @@ class Sema final : public SemaBase {
ASTTemplateArgsPtr TemplateArgsIn, SourceLocation RAngleLoc);

DeclResult ActOnVarTemplateSpecialization(
Scope *S, Declarator &D, TypeSourceInfo *DI, LookupResult &Previous,
Scope *S, Declarator &D, TypeSourceInfo *TSI, LookupResult &Previous,
SourceLocation TemplateKWLoc, TemplateParameterList *TemplateParams,
StorageClass SC, bool IsPartialSpecialization);

Expand Down
12 changes: 6 additions & 6 deletions clang/lib/AST/ASTContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3108,9 +3108,9 @@ TypeSourceInfo *ASTContext::CreateTypeSourceInfo(QualType T,

TypeSourceInfo *ASTContext::getTrivialTypeSourceInfo(QualType T,
SourceLocation L) const {
TypeSourceInfo *DI = CreateTypeSourceInfo(T);
DI->getTypeLoc().initialize(const_cast<ASTContext &>(*this), L);
return DI;
TypeSourceInfo *TSI = CreateTypeSourceInfo(T);
TSI->getTypeLoc().initialize(const_cast<ASTContext &>(*this), L);
return TSI;
}

const ASTRecordLayout &
Expand Down Expand Up @@ -5891,11 +5891,11 @@ TypeSourceInfo *ASTContext::getTemplateSpecializationTypeInfo(
QualType TST = getTemplateSpecializationType(
Keyword, Name, SpecifiedArgs.arguments(), CanonicalArgs, Underlying);

TypeSourceInfo *DI = CreateTypeSourceInfo(TST);
DI->getTypeLoc().castAs<TemplateSpecializationTypeLoc>().set(
TypeSourceInfo *TSI = CreateTypeSourceInfo(TST);
TSI->getTypeLoc().castAs<TemplateSpecializationTypeLoc>().set(
ElaboratedKeywordLoc, QualifierLoc, TemplateKeywordLoc, NameLoc,
SpecifiedArgs);
return DI;
return TSI;
}

QualType ASTContext::getTemplateSpecializationType(
Expand Down
10 changes: 5 additions & 5 deletions clang/lib/Sema/SemaDeclObjC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4730,13 +4730,13 @@ ParmVarDecl *SemaObjC::ActOnMethodParmDeclaration(Scope *S,
bool MethodDefinition) {
ASTContext &Context = getASTContext();
QualType ArgType;
TypeSourceInfo *DI;
TypeSourceInfo *TSI;

if (!ArgInfo.Type) {
ArgType = Context.getObjCIdType();
DI = nullptr;
TSI = nullptr;
} else {
ArgType = SemaRef.GetTypeFromParser(ArgInfo.Type, &DI);
ArgType = SemaRef.GetTypeFromParser(ArgInfo.Type, &TSI);
}
LookupResult R(SemaRef, ArgInfo.Name, ArgInfo.NameLoc,
Sema::LookupOrdinaryName,
Expand All @@ -4753,14 +4753,14 @@ ParmVarDecl *SemaObjC::ActOnMethodParmDeclaration(Scope *S,
}
}
SourceLocation StartLoc =
DI ? DI->getTypeLoc().getBeginLoc() : ArgInfo.NameLoc;
TSI ? TSI->getTypeLoc().getBeginLoc() : ArgInfo.NameLoc;

// Temporarily put parameter variables in the translation unit. This is what
// ActOnParamDeclarator does in the case of C arguments to the Objective-C
// method too.
ParmVarDecl *Param = SemaRef.CheckParameter(
Context.getTranslationUnitDecl(), StartLoc, ArgInfo.NameLoc, ArgInfo.Name,
ArgType, DI, SC_None);
ArgType, TSI, SC_None);
Param->setObjCMethodScopeInfo(ParamIndex);
Param->setObjCDeclQualifier(
CvtQTToAstBitMask(ArgInfo.DeclSpec.getObjCDeclQualifier()));
Expand Down
18 changes: 9 additions & 9 deletions clang/lib/Sema/SemaTemplate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -949,11 +949,11 @@ static TemplateArgumentLoc translateTemplateArgument(Sema &SemaRef,

switch (Arg.getKind()) {
case ParsedTemplateArgument::Type: {
TypeSourceInfo *DI;
QualType T = SemaRef.GetTypeFromParser(Arg.getAsType(), &DI);
if (!DI)
DI = SemaRef.Context.getTrivialTypeSourceInfo(T, Arg.getNameLoc());
return TemplateArgumentLoc(TemplateArgument(T), DI);
TypeSourceInfo *TSI;
QualType T = SemaRef.GetTypeFromParser(Arg.getAsType(), &TSI);
if (!TSI)
TSI = SemaRef.Context.getTrivialTypeSourceInfo(T, Arg.getNameLoc());
return TemplateArgumentLoc(TemplateArgument(T), TSI);
}

case ParsedTemplateArgument::NonType: {
Expand Down Expand Up @@ -4329,7 +4329,7 @@ void Sema::CheckDeductionGuideTemplate(FunctionTemplateDecl *TD) {
}

DeclResult Sema::ActOnVarTemplateSpecialization(
Scope *S, Declarator &D, TypeSourceInfo *DI, LookupResult &Previous,
Scope *S, Declarator &D, TypeSourceInfo *TSI, LookupResult &Previous,
SourceLocation TemplateKWLoc, TemplateParameterList *TemplateParams,
StorageClass SC, bool IsPartialSpecialization) {
// D must be variable template id.
Expand Down Expand Up @@ -4455,8 +4455,8 @@ DeclResult Sema::ActOnVarTemplateSpecialization(
VarTemplatePartialSpecializationDecl *Partial =
VarTemplatePartialSpecializationDecl::Create(
Context, VarTemplate->getDeclContext(), TemplateKWLoc,
TemplateNameLoc, TemplateParams, VarTemplate, DI->getType(), DI, SC,
CTAI.CanonicalConverted);
TemplateNameLoc, TemplateParams, VarTemplate, TSI->getType(), TSI,
SC, CTAI.CanonicalConverted);
Partial->setTemplateArgsAsWritten(TemplateArgs);

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

if (!PrevDecl)
Expand Down
32 changes: 16 additions & 16 deletions clang/lib/Sema/SemaTemplateDeductionGuide.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -632,42 +632,42 @@ struct ConvertConstructorToDeductionGuideTransform {
ParmVarDecl *OldParam, MultiLevelTemplateArgumentList &Args,
llvm::SmallVectorImpl<TypedefNameDecl *> &MaterializedTypedefs,
bool TransformingOuterPatterns) {
TypeSourceInfo *OldDI = OldParam->getTypeSourceInfo();
TypeSourceInfo *NewDI;
if (auto PackTL = OldDI->getTypeLoc().getAs<PackExpansionTypeLoc>()) {
TypeSourceInfo *OldTSI = OldParam->getTypeSourceInfo();
TypeSourceInfo *NewTSI;
if (auto PackTL = OldTSI->getTypeLoc().getAs<PackExpansionTypeLoc>()) {
// Expand out the one and only element in each inner pack.
Sema::ArgPackSubstIndexRAII SubstIndex(SemaRef, 0u);
NewDI =
NewTSI =
SemaRef.SubstType(PackTL.getPatternLoc(), Args,
OldParam->getLocation(), OldParam->getDeclName());
if (!NewDI)
if (!NewTSI)
return nullptr;
NewDI =
SemaRef.CheckPackExpansion(NewDI, PackTL.getEllipsisLoc(),
NewTSI =
SemaRef.CheckPackExpansion(NewTSI, PackTL.getEllipsisLoc(),
PackTL.getTypePtr()->getNumExpansions());
} else
NewDI = SemaRef.SubstType(OldDI, Args, OldParam->getLocation(),
OldParam->getDeclName());
if (!NewDI)
NewTSI = SemaRef.SubstType(OldTSI, Args, OldParam->getLocation(),
OldParam->getDeclName());
if (!NewTSI)
return nullptr;

// Extract the type. This (for instance) replaces references to typedef
// members of the current instantiations with the definitions of those
// typedefs, avoiding triggering instantiation of the deduced type during
// deduction.
NewDI = ExtractTypeForDeductionGuide(
NewTSI = ExtractTypeForDeductionGuide(
SemaRef, MaterializedTypedefs, NestedPattern,
TransformingOuterPatterns ? &Args : nullptr)
.transform(NewDI);
if (!NewDI)
.transform(NewTSI);
if (!NewTSI)
return nullptr;
// Resolving a wording defect, we also inherit default arguments from the
// constructor.
ExprResult NewDefArg;
if (OldParam->hasDefaultArg()) {
// We don't care what the value is (we won't use it); just create a
// placeholder to indicate there is a default argument.
QualType ParamTy = NewDI->getType();
QualType ParamTy = NewTSI->getType();
NewDefArg = new (SemaRef.Context)
OpaqueValueExpr(OldParam->getDefaultArgRange().getBegin(),
ParamTy.getNonLValueExprType(SemaRef.Context),
Expand All @@ -676,13 +676,13 @@ struct ConvertConstructorToDeductionGuideTransform {
: VK_PRValue);
}
// Handle arrays and functions decay.
auto NewType = NewDI->getType();
auto NewType = NewTSI->getType();
if (NewType->isArrayType() || NewType->isFunctionType())
NewType = SemaRef.Context.getDecayedType(NewType);

ParmVarDecl *NewParam = ParmVarDecl::Create(
SemaRef.Context, DC, OldParam->getInnerLocStart(),
OldParam->getLocation(), OldParam->getIdentifier(), NewType, NewDI,
OldParam->getLocation(), OldParam->getIdentifier(), NewType, NewTSI,
OldParam->getStorageClass(), NewDefArg.get());
NewParam->setScopeInfo(OldParam->getFunctionScopeDepth(),
OldParam->getFunctionScopeIndex());
Expand Down
40 changes: 19 additions & 21 deletions clang/lib/Sema/SemaTemplateInstantiate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3156,44 +3156,44 @@ Sema::SubstParmVarDecl(ParmVarDecl *OldParm,
const MultiLevelTemplateArgumentList &TemplateArgs,
int indexAdjustment, UnsignedOrNone NumExpansions,
bool ExpectParameterPack, bool EvaluateConstraint) {
TypeSourceInfo *OldDI = OldParm->getTypeSourceInfo();
TypeSourceInfo *NewDI = nullptr;
TypeSourceInfo *OldTSI = OldParm->getTypeSourceInfo();
TypeSourceInfo *NewTSI = nullptr;

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

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

if (NewDI->getType()->containsUnexpandedParameterPack()) {
if (NewTSI->getType()->containsUnexpandedParameterPack()) {
// We still have unexpanded parameter packs, which means that
// our function parameter is still a function parameter pack.
// Therefore, make its type a pack expansion type.
NewDI = CheckPackExpansion(NewDI, ExpansionTL.getEllipsisLoc(),
NumExpansions);
NewTSI = CheckPackExpansion(NewTSI, ExpansionTL.getEllipsisLoc(),
NumExpansions);
} else if (ExpectParameterPack) {
// We expected to get a parameter pack but didn't (because the type
// itself is not a pack expansion type), so complain. This can occur when
// the substitution goes through an alias template that "loses" the
// pack expansion.
Diag(OldParm->getLocation(),
diag::err_function_parameter_pack_without_parameter_packs)
<< NewDI->getType();
<< NewTSI->getType();
return nullptr;
}
} else {
NewDI = SubstType(OldDI, TemplateArgs, OldParm->getLocation(),
OldParm->getDeclName());
NewTSI = SubstType(OldTSI, TemplateArgs, OldParm->getLocation(),
OldParm->getDeclName());
}

if (!NewDI)
if (!NewTSI)
return nullptr;

if (NewDI->getType()->isVoidType()) {
if (NewTSI->getType()->isVoidType()) {
Diag(OldParm->getLocation(), diag::err_param_with_void_type);
return nullptr;
}
Expand All @@ -3205,7 +3205,7 @@ Sema::SubstParmVarDecl(ParmVarDecl *OldParm,
// here, when the instantiated versions of those referenced parameters are in
// scope.
if (TemplateTypeParmDecl *TTP =
GetContainedInventedTypeParmVisitor().Visit(OldDI->getType())) {
GetContainedInventedTypeParmVisitor().Visit(OldTSI->getType())) {
if (const TypeConstraint *TC = TTP->getTypeConstraint()) {
auto *Inst = cast_or_null<TemplateTypeParmDecl>(
FindInstantiatedDecl(TTP->getLocation(), TTP, TemplateArgs));
Expand All @@ -3219,12 +3219,10 @@ Sema::SubstParmVarDecl(ParmVarDecl *OldParm,
}
}

ParmVarDecl *NewParm = CheckParameter(Context.getTranslationUnitDecl(),
OldParm->getInnerLocStart(),
OldParm->getLocation(),
OldParm->getIdentifier(),
NewDI->getType(), NewDI,
OldParm->getStorageClass());
ParmVarDecl *NewParm = CheckParameter(
Context.getTranslationUnitDecl(), OldParm->getInnerLocStart(),
OldParm->getLocation(), OldParm->getIdentifier(), NewTSI->getType(),
NewTSI, OldParm->getStorageClass());
if (!NewParm)
return nullptr;

Expand Down
Loading
Loading