Skip to content

Commit 40118bf

Browse files
committed
[clang][NFC] Rename stale TypeSourceInfo DI variables
1 parent 4c2a9c4 commit 40118bf

File tree

10 files changed

+198
-209
lines changed

10 files changed

+198
-209
lines changed

clang/include/clang/Sema/Sema.h

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

1167011670
DeclResult ActOnVarTemplateSpecialization(
11671-
Scope *S, Declarator &D, TypeSourceInfo *DI, LookupResult &Previous,
11671+
Scope *S, Declarator &D, TypeSourceInfo *TSI, LookupResult &Previous,
1167211672
SourceLocation TemplateKWLoc, TemplateParameterList *TemplateParams,
1167311673
StorageClass SC, bool IsPartialSpecialization);
1167411674

clang/lib/AST/ASTContext.cpp

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

31093109
TypeSourceInfo *ASTContext::getTrivialTypeSourceInfo(QualType T,
31103110
SourceLocation L) const {
3111-
TypeSourceInfo *DI = CreateTypeSourceInfo(T);
3112-
DI->getTypeLoc().initialize(const_cast<ASTContext &>(*this), L);
3113-
return DI;
3111+
TypeSourceInfo *TSI = CreateTypeSourceInfo(T);
3112+
TSI->getTypeLoc().initialize(const_cast<ASTContext &>(*this), L);
3113+
return TSI;
31143114
}
31153115

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

5894-
TypeSourceInfo *DI = CreateTypeSourceInfo(TST);
5895-
DI->getTypeLoc().castAs<TemplateSpecializationTypeLoc>().set(
5894+
TypeSourceInfo *TSI = CreateTypeSourceInfo(TST);
5895+
TSI->getTypeLoc().castAs<TemplateSpecializationTypeLoc>().set(
58965896
ElaboratedKeywordLoc, QualifierLoc, TemplateKeywordLoc, NameLoc,
58975897
SpecifiedArgs);
5898-
return DI;
5898+
return TSI;
58995899
}
59005900

59015901
QualType ASTContext::getTemplateSpecializationType(

clang/lib/Sema/SemaDeclObjC.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4730,13 +4730,13 @@ ParmVarDecl *SemaObjC::ActOnMethodParmDeclaration(Scope *S,
47304730
bool MethodDefinition) {
47314731
ASTContext &Context = getASTContext();
47324732
QualType ArgType;
4733-
TypeSourceInfo *DI;
4733+
TypeSourceInfo *TSI;
47344734

47354735
if (!ArgInfo.Type) {
47364736
ArgType = Context.getObjCIdType();
4737-
DI = nullptr;
4737+
TSI = nullptr;
47384738
} else {
4739-
ArgType = SemaRef.GetTypeFromParser(ArgInfo.Type, &DI);
4739+
ArgType = SemaRef.GetTypeFromParser(ArgInfo.Type, &TSI);
47404740
}
47414741
LookupResult R(SemaRef, ArgInfo.Name, ArgInfo.NameLoc,
47424742
Sema::LookupOrdinaryName,
@@ -4753,14 +4753,14 @@ ParmVarDecl *SemaObjC::ActOnMethodParmDeclaration(Scope *S,
47534753
}
47544754
}
47554755
SourceLocation StartLoc =
4756-
DI ? DI->getTypeLoc().getBeginLoc() : ArgInfo.NameLoc;
4756+
TSI ? TSI->getTypeLoc().getBeginLoc() : ArgInfo.NameLoc;
47574757

47584758
// Temporarily put parameter variables in the translation unit. This is what
47594759
// ActOnParamDeclarator does in the case of C arguments to the Objective-C
47604760
// method too.
47614761
ParmVarDecl *Param = SemaRef.CheckParameter(
47624762
Context.getTranslationUnitDecl(), StartLoc, ArgInfo.NameLoc, ArgInfo.Name,
4763-
ArgType, DI, SC_None);
4763+
ArgType, TSI, SC_None);
47644764
Param->setObjCMethodScopeInfo(ParamIndex);
47654765
Param->setObjCDeclQualifier(
47664766
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: 16 additions & 16 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(
658+
NewTSI = ExtractTypeForDeductionGuide(
659659
SemaRef, MaterializedTypedefs, NestedPattern,
660660
TransformingOuterPatterns ? &Args : nullptr)
661-
.transform(NewDI);
662-
if (!NewDI)
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)