Skip to content

[clang] Migrate away from ArrayRef(std::nullopt) (NFC) #144982

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all 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/AST/TypeProperties.td
Original file line number Diff line number Diff line change
Expand Up @@ -753,7 +753,7 @@ let Class = TemplateSpecializationType in {
}

def : Creator<[{
return ctx.getTemplateSpecializationType(templateName, args, std::nullopt, UnderlyingType);
return ctx.getTemplateSpecializationType(templateName, args, {}, UnderlyingType);
}]>;
}

Expand Down
4 changes: 2 additions & 2 deletions clang/lib/AST/ASTContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14283,7 +14283,7 @@ static QualType getCommonNonSugarTypeNode(ASTContext &Ctx, const Type *X,
::getCommonTemplateNameChecked(Ctx, TX->getTemplateName(),
TY->getTemplateName(),
/*IgnoreDeduced=*/true),
As, /*CanonicalArgs=*/std::nullopt, X->getCanonicalTypeInternal());
As, /*CanonicalArgs=*/{}, X->getCanonicalTypeInternal());
}
case Type::Decltype: {
const auto *DX = cast<DecltypeType>(X);
Expand Down Expand Up @@ -14529,7 +14529,7 @@ static QualType getCommonSugarTypeNode(ASTContext &Ctx, const Type *X,
TY->template_arguments()))
return QualType();
return Ctx.getTemplateSpecializationType(CTN, As,
/*CanonicalArgs=*/std::nullopt,
/*CanonicalArgs=*/{},
Ctx.getQualifiedType(Underlying));
}
case Type::Typedef: {
Expand Down
4 changes: 2 additions & 2 deletions clang/lib/AST/ASTDiagnostic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ QualType clang::desugarForDiagnostic(ASTContext &Context, QualType QT,
if (DesugarArgument) {
ShouldAKA = true;
QT = Context.getTemplateSpecializationType(
TST->getTemplateName(), Args, /*CanonicalArgs=*/std::nullopt, QT);
TST->getTemplateName(), Args, /*CanonicalArgs=*/{}, QT);
}
break;
}
Expand Down Expand Up @@ -1143,7 +1143,7 @@ class TemplateDiff {

Ty = Context.getTemplateSpecializationType(
TemplateName(CTSD->getSpecializedTemplate()),
CTSD->getTemplateArgs().asArray(), /*CanonicalArgs=*/std::nullopt,
CTSD->getTemplateArgs().asArray(), /*CanonicalArgs=*/{},
Ty.getLocalUnqualifiedType().getCanonicalType());

return Ty->getAs<TemplateSpecializationType>();
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/AST/ASTImporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1664,7 +1664,7 @@ ExpectedType ASTNodeImporter::VisitTemplateSpecializationType(
if (!ToUnderlyingOrErr)
return ToUnderlyingOrErr.takeError();
return Importer.getToContext().getTemplateSpecializationType(
*ToTemplateOrErr, ToTemplateArgs, std::nullopt, *ToUnderlyingOrErr);
*ToTemplateOrErr, ToTemplateArgs, {}, *ToUnderlyingOrErr);
}

ExpectedType ASTNodeImporter::VisitElaboratedType(const ElaboratedType *T) {
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/AST/DeclTemplate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -669,7 +669,7 @@ ClassTemplateDecl::getInjectedClassNameSpecialization() {
CommonPtr->InjectedClassNameType =
Context.getTemplateSpecializationType(Name,
/*SpecifiedArgs=*/TemplateArgs,
/*CanonicalArgs=*/std::nullopt);
/*CanonicalArgs=*/{});
return CommonPtr->InjectedClassNameType;
}

Expand Down
5 changes: 2 additions & 3 deletions clang/lib/AST/QualTypeNames.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ static const Type *getFullyQualifiedTemplateType(const ASTContext &Ctx,
if (MightHaveChanged) {
QualType QT = Ctx.getTemplateSpecializationType(
TST->getTemplateName(), FQArgs,
/*CanonicalArgs=*/std::nullopt, TST->desugar());
/*CanonicalArgs=*/{}, TST->desugar());
// getTemplateSpecializationType returns a fully qualified
// version of the specialization itself, so no need to qualify
// it.
Expand Down Expand Up @@ -172,8 +172,7 @@ static const Type *getFullyQualifiedTemplateType(const ASTContext &Ctx,
TemplateName TN(TSTDecl->getSpecializedTemplate());
QualType QT = Ctx.getTemplateSpecializationType(
TN, FQArgs,
/*CanonicalArgs=*/std::nullopt,
TSTRecord->getCanonicalTypeInternal());
/*CanonicalArgs=*/{}, TSTRecord->getCanonicalTypeInternal());
// getTemplateSpecializationType returns a fully qualified
// version of the specialization itself, so no need to qualify
// it.
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/Basic/Targets/Xtensa.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class LLVM_LIBRARY_VISIBILITY XtensaTargetInfo : public TargetInfo {
}

ArrayRef<TargetInfo::GCCRegAlias> getGCCRegAliases() const override {
return std::nullopt;
return {};
}

bool validateAsmConstraint(const char *&Name,
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/CodeGen/CGBuiltin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2032,7 +2032,7 @@ Value *CodeGenFunction::EmitCheckedArgForAssume(const Expr *E) {
std::make_pair(ArgValue, CheckOrdinal), CheckHandler,
{EmitCheckSourceLocation(E->getExprLoc()),
llvm::ConstantInt::get(Builder.getInt8Ty(), BCK_AssumePassedFalse)},
std::nullopt);
{});
return ArgValue;
}

Expand Down
4 changes: 2 additions & 2 deletions clang/lib/Driver/ToolChains/Clang.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8953,7 +8953,7 @@ void OffloadBundler::ConstructJob(Compilation &C, const JobAction &JA,
C.addCommand(std::make_unique<Command>(
JA, *this, ResponseFileSupport::None(),
TCArgs.MakeArgString(getToolChain().GetProgramPath(getShortName())),
CmdArgs, std::nullopt, Output));
CmdArgs, ArrayRef<InputInfo>(), Output));
}

void OffloadBundler::ConstructJobMultipleOutputs(
Expand Down Expand Up @@ -9040,7 +9040,7 @@ void OffloadBundler::ConstructJobMultipleOutputs(
C.addCommand(std::make_unique<Command>(
JA, *this, ResponseFileSupport::None(),
TCArgs.MakeArgString(getToolChain().GetProgramPath(getShortName())),
CmdArgs, std::nullopt, Outputs));
CmdArgs, ArrayRef<InputInfo>(), Outputs));
}

void OffloadPackager::ConstructJob(Compilation &C, const JobAction &JA,
Expand Down
4 changes: 2 additions & 2 deletions clang/lib/Sema/SemaConcept.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1081,10 +1081,10 @@ static bool CheckFunctionConstraintsWithoutInstantiation(
// FIXME: Add TemplateArgs through the 'Innermost' parameter once
// the refactoring of getTemplateInstantiationArgs() relands.
MultiLevelTemplateArgumentList MLTAL;
MLTAL.addOuterTemplateArguments(Template, std::nullopt, /*Final=*/false);
MLTAL.addOuterTemplateArguments(Template, {}, /*Final=*/false);
SemaRef.getTemplateInstantiationArgs(
MLTAL, /*D=*/FD, FD,
/*Final=*/false, /*Innermost=*/std::nullopt, /*RelativeToPrimary=*/true,
/*Final=*/false, /*Innermost=*/{}, /*RelativeToPrimary=*/true,
/*Pattern=*/nullptr, /*ForConstraintInstantiation=*/true);
MLTAL.replaceInnermostTemplateArguments(Template, TemplateArgs);

Expand Down
2 changes: 1 addition & 1 deletion clang/lib/Sema/SemaExpr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21212,7 +21212,7 @@ ExprResult Sema::CheckPlaceholderExpr(Expr *E) {
}
if (TST.isNull())
TST = Context.getTemplateSpecializationType(
TN, ULE->template_arguments(), /*CanonicalArgs=*/std::nullopt,
TN, ULE->template_arguments(), /*CanonicalArgs=*/{},
HasAnyDependentTA ? Context.DependentTy : Context.IntTy);
QualType ET =
Context.getElaboratedType(ElaboratedTypeKeyword::None, NNS, TST);
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/Sema/TreeTransform.h
Original file line number Diff line number Diff line change
Expand Up @@ -16222,7 +16222,7 @@ TreeTransform<Derived>::TransformSizeOfPackExpr(SizeOfPackExpr *E) {
return getDerived().RebuildSizeOfPackExpr(
E->getOperatorLoc(), E->getPack(), E->getPackLoc(), E->getRParenLoc(),
/*Length=*/static_cast<unsigned>(Args.size()),
/*PartialArgs=*/std::nullopt);
/*PartialArgs=*/{});
}

template <typename Derived>
Expand Down
Loading