[clang] 8595f2e - [Sema] Use std::nullopt instead of None (NFC)
Kazu Hirata via cfe-commits
cfe-commits at lists.llvm.org
Sat Dec 3 11:13:51 PST 2022
Author: Kazu Hirata
Date: 2022-12-03T11:13:39-08:00
New Revision: 8595f2e54d2df80e8d0f9de415324eaae510a84a
URL: https://github.com/llvm/llvm-project/commit/8595f2e54d2df80e8d0f9de415324eaae510a84a
DIFF: https://github.com/llvm/llvm-project/commit/8595f2e54d2df80e8d0f9de415324eaae510a84a.diff
LOG: [Sema] Use std::nullopt instead of None (NFC)
This patch mechanically replaces None with std::nullopt where the
compiler would warn if None were deprecated. The intent is to reduce
the amount of manual work required in migrating from Optional to
std::optional.
This is part of an effort to migrate from llvm::Optional to
std::optional:
https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
Added:
Modified:
clang/include/clang/Sema/CodeCompleteConsumer.h
clang/include/clang/Sema/Overload.h
clang/include/clang/Sema/Sema.h
clang/include/clang/Sema/Template.h
clang/lib/Sema/Scope.cpp
clang/lib/Sema/Sema.cpp
clang/lib/Sema/SemaAttr.cpp
clang/lib/Sema/SemaAvailability.cpp
clang/lib/Sema/SemaChecking.cpp
clang/lib/Sema/SemaCodeComplete.cpp
clang/lib/Sema/SemaConcept.cpp
clang/lib/Sema/SemaCoroutine.cpp
clang/lib/Sema/SemaDecl.cpp
clang/lib/Sema/SemaDeclAttr.cpp
clang/lib/Sema/SemaDeclCXX.cpp
clang/lib/Sema/SemaExpr.cpp
clang/lib/Sema/SemaExprObjC.cpp
clang/lib/Sema/SemaInit.cpp
clang/lib/Sema/SemaLambda.cpp
clang/lib/Sema/SemaLookup.cpp
clang/lib/Sema/SemaModule.cpp
clang/lib/Sema/SemaObjCProperty.cpp
clang/lib/Sema/SemaOpenMP.cpp
clang/lib/Sema/SemaOverload.cpp
clang/lib/Sema/SemaPseudoObject.cpp
clang/lib/Sema/SemaStmt.cpp
clang/lib/Sema/SemaTemplate.cpp
clang/lib/Sema/SemaTemplateInstantiate.cpp
clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
clang/lib/Sema/SemaTemplateVariadic.cpp
clang/lib/Sema/SemaType.cpp
clang/lib/Sema/TreeTransform.h
Removed:
################################################################################
diff --git a/clang/include/clang/Sema/CodeCompleteConsumer.h b/clang/include/clang/Sema/CodeCompleteConsumer.h
index db1f3850984c1..e0c7424220f5d 100644
--- a/clang/include/clang/Sema/CodeCompleteConsumer.h
+++ b/clang/include/clang/Sema/CodeCompleteConsumer.h
@@ -368,11 +368,11 @@ class CodeCompletionContext {
public:
/// Construct a new code-completion context of the given kind.
CodeCompletionContext(Kind CCKind)
- : CCKind(CCKind), IsUsingDeclaration(false), SelIdents(None) {}
+ : CCKind(CCKind), IsUsingDeclaration(false), SelIdents(std::nullopt) {}
/// Construct a new code-completion context of the given kind.
CodeCompletionContext(Kind CCKind, QualType T,
- ArrayRef<IdentifierInfo *> SelIdents = None)
+ ArrayRef<IdentifierInfo *> SelIdents = std::nullopt)
: CCKind(CCKind), IsUsingDeclaration(false), SelIdents(SelIdents) {
if (CCKind == CCC_DotMemberAccess || CCKind == CCC_ArrowMemberAccess ||
CCKind == CCC_ObjCPropertyAccess || CCKind == CCC_ObjCClassMessage ||
@@ -425,7 +425,7 @@ class CodeCompletionContext {
llvm::Optional<const CXXScopeSpec *> getCXXScopeSpecifier() {
if (ScopeSpecifier)
return &*ScopeSpecifier;
- return llvm::None;
+ return std::nullopt;
}
};
diff --git a/clang/include/clang/Sema/Overload.h b/clang/include/clang/Sema/Overload.h
index 29d0fa63369f0..f7773bd9c56d6 100644
--- a/clang/include/clang/Sema/Overload.h
+++ b/clang/include/clang/Sema/Overload.h
@@ -1146,8 +1146,9 @@ class Sema;
/// Add a new candidate with NumConversions conversion sequence slots
/// to the overload set.
- OverloadCandidate &addCandidate(unsigned NumConversions = 0,
- ConversionSequenceList Conversions = None) {
+ OverloadCandidate &
+ addCandidate(unsigned NumConversions = 0,
+ ConversionSequenceList Conversions = std::nullopt) {
assert((Conversions.empty() || Conversions.size() == NumConversions) &&
"preallocated conversion sequence has wrong length");
diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 55f3f0e0a1cce..7a493c052ab1f 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -2886,12 +2886,10 @@ class Sema final {
LookupResult &Previous);
NamedDecl* ActOnTypedefNameDecl(Scope* S, DeclContext* DC, TypedefNameDecl *D,
LookupResult &Previous, bool &Redeclaration);
- NamedDecl *ActOnVariableDeclarator(Scope *S, Declarator &D, DeclContext *DC,
- TypeSourceInfo *TInfo,
- LookupResult &Previous,
- MultiTemplateParamsArg TemplateParamLists,
- bool &AddToScope,
- ArrayRef<BindingDecl *> Bindings = None);
+ NamedDecl *ActOnVariableDeclarator(
+ Scope *S, Declarator &D, DeclContext *DC, TypeSourceInfo *TInfo,
+ LookupResult &Previous, MultiTemplateParamsArg TemplateParamLists,
+ bool &AddToScope, ArrayRef<BindingDecl *> Bindings = std::nullopt);
NamedDecl *
ActOnDecompositionDeclarator(Scope *S, Declarator &D,
MultiTemplateParamsArg TemplateParamLists);
@@ -3930,16 +3928,14 @@ class Sema final {
using ADLCallKind = CallExpr::ADLCallKind;
- void AddOverloadCandidate(FunctionDecl *Function, DeclAccessPair FoundDecl,
- ArrayRef<Expr *> Args,
- OverloadCandidateSet &CandidateSet,
- bool SuppressUserConversions = false,
- bool PartialOverloading = false,
- bool AllowExplicit = true,
- bool AllowExplicitConversion = false,
- ADLCallKind IsADLCandidate = ADLCallKind::NotADL,
- ConversionSequenceList EarlyConversions = None,
- OverloadCandidateParamOrder PO = {});
+ void AddOverloadCandidate(
+ FunctionDecl *Function, DeclAccessPair FoundDecl, ArrayRef<Expr *> Args,
+ OverloadCandidateSet &CandidateSet, bool SuppressUserConversions = false,
+ bool PartialOverloading = false, bool AllowExplicit = true,
+ bool AllowExplicitConversion = false,
+ ADLCallKind IsADLCandidate = ADLCallKind::NotADL,
+ ConversionSequenceList EarlyConversions = std::nullopt,
+ OverloadCandidateParamOrder PO = {});
void AddFunctionCandidates(const UnresolvedSetImpl &Functions,
ArrayRef<Expr *> Args,
OverloadCandidateSet &CandidateSet,
@@ -3954,16 +3950,15 @@ class Sema final {
OverloadCandidateSet& CandidateSet,
bool SuppressUserConversion = false,
OverloadCandidateParamOrder PO = {});
- void AddMethodCandidate(CXXMethodDecl *Method,
- DeclAccessPair FoundDecl,
- CXXRecordDecl *ActingContext, QualType ObjectType,
- Expr::Classification ObjectClassification,
- ArrayRef<Expr *> Args,
- OverloadCandidateSet& CandidateSet,
- bool SuppressUserConversions = false,
- bool PartialOverloading = false,
- ConversionSequenceList EarlyConversions = None,
- OverloadCandidateParamOrder PO = {});
+ void
+ AddMethodCandidate(CXXMethodDecl *Method, DeclAccessPair FoundDecl,
+ CXXRecordDecl *ActingContext, QualType ObjectType,
+ Expr::Classification ObjectClassification,
+ ArrayRef<Expr *> Args, OverloadCandidateSet &CandidateSet,
+ bool SuppressUserConversions = false,
+ bool PartialOverloading = false,
+ ConversionSequenceList EarlyConversions = std::nullopt,
+ OverloadCandidateParamOrder PO = {});
void AddMethodTemplateCandidate(FunctionTemplateDecl *MethodTmpl,
DeclAccessPair FoundDecl,
CXXRecordDecl *ActingContext,
@@ -5451,9 +5446,9 @@ class Sema final {
/// referenced. Used when template instantiation instantiates a non-dependent
/// type -- entities referenced by the type are now referenced.
void MarkDeclarationsReferencedInType(SourceLocation Loc, QualType T);
- void MarkDeclarationsReferencedInExpr(Expr *E,
- bool SkipLocalVariables = false,
- ArrayRef<const Expr *> StopAt = None);
+ void MarkDeclarationsReferencedInExpr(
+ Expr *E, bool SkipLocalVariables = false,
+ ArrayRef<const Expr *> StopAt = std::nullopt);
/// Try to recover by turning the given expression into a
/// call. Returns true if recovery was attempted or an error was
@@ -5514,7 +5509,8 @@ class Sema final {
DiagnoseEmptyLookup(Scope *S, CXXScopeSpec &SS, LookupResult &R,
CorrectionCandidateCallback &CCC,
TemplateArgumentListInfo *ExplicitTemplateArgs = nullptr,
- ArrayRef<Expr *> Args = None, TypoExpr **Out = nullptr);
+ ArrayRef<Expr *> Args = std::nullopt,
+ TypoExpr **Out = nullptr);
DeclResult LookupIvarInObjCMethod(LookupResult &Lookup, Scope *S,
IdentifierInfo *II);
@@ -7061,7 +7057,8 @@ class Sema final {
/// Number lambda for linkage purposes if necessary.
void handleLambdaNumbering(
CXXRecordDecl *Class, CXXMethodDecl *Method,
- Optional<std::tuple<bool, unsigned, unsigned, Decl *>> Mangling = None);
+ Optional<std::tuple<bool, unsigned, unsigned, Decl *>> Mangling =
+ std::nullopt);
/// Endow the lambda scope info with the relevant properties.
void buildLambdaScope(sema::LambdaScopeInfo *LSI,
@@ -7080,7 +7077,7 @@ class Sema final {
SourceLocation Loc, bool ByRef, SourceLocation EllipsisLoc,
IdentifierInfo *Id, LambdaCaptureInitKind InitKind, Expr *&Init) {
return ParsedType::make(buildLambdaInitCaptureInitialization(
- Loc, ByRef, EllipsisLoc, None, Id,
+ Loc, ByRef, EllipsisLoc, std::nullopt, Id,
InitKind != LambdaCaptureInitKind::CopyInit, Init));
}
QualType buildLambdaInitCaptureInitialization(
@@ -7544,8 +7541,9 @@ class Sema final {
bool SetDelegatingInitializer(CXXConstructorDecl *Constructor,
CXXCtorInitializer *Initializer);
- bool SetCtorInitializers(CXXConstructorDecl *Constructor, bool AnyErrors,
- ArrayRef<CXXCtorInitializer *> Initializers = None);
+ bool SetCtorInitializers(
+ CXXConstructorDecl *Constructor, bool AnyErrors,
+ ArrayRef<CXXCtorInitializer *> Initializers = std::nullopt);
void SetIvarInitializers(ObjCImplementationDecl *ObjCImplementation);
@@ -9574,7 +9572,7 @@ class Sema final {
Sema &SemaRef, CodeSynthesisContext::SynthesisKind Kind,
SourceLocation PointOfInstantiation, SourceRange InstantiationRange,
Decl *Entity, NamedDecl *Template = nullptr,
- ArrayRef<TemplateArgument> TemplateArgs = None,
+ ArrayRef<TemplateArgument> TemplateArgs = std::nullopt,
sema::TemplateDeductionInfo *DeductionInfo = nullptr);
InstantiatingTemplate(const InstantiatingTemplate&) = delete;
@@ -10257,8 +10255,8 @@ class Sema final {
ObjCInterfaceDecl *ID);
Decl *ActOnAtEnd(Scope *S, SourceRange AtEnd,
- ArrayRef<Decl *> allMethods = None,
- ArrayRef<DeclGroupPtrTy> allTUVars = None);
+ ArrayRef<Decl *> allMethods = std::nullopt,
+ ArrayRef<DeclGroupPtrTy> allTUVars = std::nullopt);
Decl *ActOnProperty(Scope *S, SourceLocation AtLoc,
SourceLocation LParenLoc,
@@ -11937,21 +11935,21 @@ class Sema final {
SourceLocation ModifierLoc, SourceLocation ColonLoc,
SourceLocation EndLoc, CXXScopeSpec &ReductionIdScopeSpec,
const DeclarationNameInfo &ReductionId,
- ArrayRef<Expr *> UnresolvedReductions = llvm::None);
+ ArrayRef<Expr *> UnresolvedReductions = std::nullopt);
/// Called on well-formed 'task_reduction' clause.
OMPClause *ActOnOpenMPTaskReductionClause(
ArrayRef<Expr *> VarList, SourceLocation StartLoc,
SourceLocation LParenLoc, SourceLocation ColonLoc, SourceLocation EndLoc,
CXXScopeSpec &ReductionIdScopeSpec,
const DeclarationNameInfo &ReductionId,
- ArrayRef<Expr *> UnresolvedReductions = llvm::None);
+ ArrayRef<Expr *> UnresolvedReductions = std::nullopt);
/// Called on well-formed 'in_reduction' clause.
OMPClause *ActOnOpenMPInReductionClause(
ArrayRef<Expr *> VarList, SourceLocation StartLoc,
SourceLocation LParenLoc, SourceLocation ColonLoc, SourceLocation EndLoc,
CXXScopeSpec &ReductionIdScopeSpec,
const DeclarationNameInfo &ReductionId,
- ArrayRef<Expr *> UnresolvedReductions = llvm::None);
+ ArrayRef<Expr *> UnresolvedReductions = std::nullopt);
/// Called on well-formed 'linear' clause.
OMPClause *
ActOnOpenMPLinearClause(ArrayRef<Expr *> VarList, Expr *Step,
@@ -12005,7 +12003,7 @@ class Sema final {
OpenMPMapClauseKind MapType, bool IsMapTypeImplicit,
SourceLocation MapLoc, SourceLocation ColonLoc, ArrayRef<Expr *> VarList,
const OMPVarListLocTy &Locs, bool NoDiagnose = false,
- ArrayRef<Expr *> UnresolvedMappers = llvm::None);
+ ArrayRef<Expr *> UnresolvedMappers = std::nullopt);
/// Called on well-formed 'num_teams' clause.
OMPClause *ActOnOpenMPNumTeamsClause(Expr *NumTeams, SourceLocation StartLoc,
SourceLocation LParenLoc,
@@ -12036,7 +12034,7 @@ class Sema final {
CXXScopeSpec &MapperIdScopeSpec,
DeclarationNameInfo &MapperId, SourceLocation ColonLoc,
ArrayRef<Expr *> VarList, const OMPVarListLocTy &Locs,
- ArrayRef<Expr *> UnresolvedMappers = llvm::None);
+ ArrayRef<Expr *> UnresolvedMappers = std::nullopt);
/// Called on well-formed 'from' clause.
OMPClause *
ActOnOpenMPFromClause(ArrayRef<OpenMPMotionModifierKind> MotionModifiers,
@@ -12044,7 +12042,7 @@ class Sema final {
CXXScopeSpec &MapperIdScopeSpec,
DeclarationNameInfo &MapperId, SourceLocation ColonLoc,
ArrayRef<Expr *> VarList, const OMPVarListLocTy &Locs,
- ArrayRef<Expr *> UnresolvedMappers = llvm::None);
+ ArrayRef<Expr *> UnresolvedMappers = std::nullopt);
/// Called on well-formed 'use_device_ptr' clause.
OMPClause *ActOnOpenMPUseDevicePtrClause(ArrayRef<Expr *> VarList,
const OMPVarListLocTy &Locs);
@@ -12709,7 +12707,7 @@ class Sema final {
}
llvm::Optional<bool> getKnownValue() const {
if (!HasKnownValue)
- return None;
+ return std::nullopt;
return KnownValue;
}
};
diff --git a/clang/include/clang/Sema/Template.h b/clang/include/clang/Sema/Template.h
index 039b203fd010b..8f3657d19aafc 100644
--- a/clang/include/clang/Sema/Template.h
+++ b/clang/include/clang/Sema/Template.h
@@ -601,7 +601,7 @@ enum class TemplateSubstitutionKind : char {
Decl *VisitCXXMethodDecl(CXXMethodDecl *D,
TemplateParameterList *TemplateParams,
Optional<const ASTTemplateArgumentListInfo *>
- ClassScopeSpecializationArgs = llvm::None,
+ ClassScopeSpecializationArgs = std::nullopt,
RewriteKind RK = RewriteKind::None);
Decl *VisitFunctionDecl(FunctionDecl *D,
TemplateParameterList *TemplateParams,
diff --git a/clang/lib/Sema/Scope.cpp b/clang/lib/Sema/Scope.cpp
index d27de34f3977f..a85c0cb3ee313 100644
--- a/clang/lib/Sema/Scope.cpp
+++ b/clang/lib/Sema/Scope.cpp
@@ -91,7 +91,7 @@ void Scope::Init(Scope *parent, unsigned flags) {
UsingDirectives.clear();
Entity = nullptr;
ErrorTrap.reset();
- NRVO = None;
+ NRVO = std::nullopt;
}
bool Scope::containedInPrototypeScope() const {
diff --git a/clang/lib/Sema/Sema.cpp b/clang/lib/Sema/Sema.cpp
index ad53e874e9d32..ab5db04a4994c 100644
--- a/clang/lib/Sema/Sema.cpp
+++ b/clang/lib/Sema/Sema.cpp
@@ -2475,7 +2475,7 @@ bool Sema::tryExprAsCall(Expr &E, QualType &ZeroArgCallReturnTy,
if (IsMemExpr && !E.isTypeDependent()) {
Sema::TentativeAnalysisScope Trap(*this);
ExprResult R = BuildCallToMemberFunction(nullptr, &E, SourceLocation(),
- None, SourceLocation());
+ std::nullopt, SourceLocation());
if (R.isUsable()) {
ZeroArgCallReturnTy = R.get()->getType();
return true;
@@ -2625,7 +2625,7 @@ bool Sema::tryToRecoverWithCall(ExprResult &E, const PartialDiagnostic &PD,
// FIXME: Try this before emitting the fixit, and suppress diagnostics
// while doing so.
- E = BuildCallExpr(nullptr, E.get(), Range.getEnd(), None,
+ E = BuildCallExpr(nullptr, E.get(), Range.getEnd(), std::nullopt,
Range.getEnd().getLocWithOffset(1));
return true;
}
diff --git a/clang/lib/Sema/SemaAttr.cpp b/clang/lib/Sema/SemaAttr.cpp
index 47611aed7957c..6b4777d1f05f0 100644
--- a/clang/lib/Sema/SemaAttr.cpp
+++ b/clang/lib/Sema/SemaAttr.cpp
@@ -890,7 +890,7 @@ getParentAttrMatcherRule(attr::SubjectMatchRule Rule) {
using namespace attr;
switch (Rule) {
default:
- return None;
+ return std::nullopt;
#define ATTR_MATCH_RULE(Value, Spelling, IsAbstract)
#define ATTR_MATCH_SUB_RULE(Value, Spelling, IsAbstract, Parent, IsNegated) \
case Value: \
diff --git a/clang/lib/Sema/SemaAvailability.cpp b/clang/lib/Sema/SemaAvailability.cpp
index 9ba434945e96f..3a5399a7175fa 100644
--- a/clang/lib/Sema/SemaAvailability.cpp
+++ b/clang/lib/Sema/SemaAvailability.cpp
@@ -253,7 +253,7 @@ tryParseObjCMethodName(StringRef Name, SmallVectorImpl<StringRef> &SlotNames,
if (!Name.empty() && (Name.front() == '-' || Name.front() == '+'))
Name = Name.drop_front(1);
if (Name.empty())
- return None;
+ return std::nullopt;
Name.split(SlotNames, ':');
unsigned NumParams;
if (Name.back() == ':') {
@@ -263,7 +263,7 @@ tryParseObjCMethodName(StringRef Name, SmallVectorImpl<StringRef> &SlotNames,
} else {
if (SlotNames.size() != 1)
// Not a valid method name, just a colon-separated string.
- return None;
+ return std::nullopt;
NumParams = 0;
}
// Verify all slot names are valid.
@@ -272,7 +272,7 @@ tryParseObjCMethodName(StringRef Name, SmallVectorImpl<StringRef> &SlotNames,
if (S.empty())
continue;
if (!isValidAsciiIdentifier(S, AllowDollar))
- return None;
+ return std::nullopt;
}
return NumParams;
}
@@ -286,14 +286,14 @@ createAttributeInsertion(const NamedDecl *D, const SourceManager &SM,
return AttributeInsertion::createInsertionAfter(D);
if (const auto *MD = dyn_cast<ObjCMethodDecl>(D)) {
if (MD->hasBody())
- return None;
+ return std::nullopt;
return AttributeInsertion::createInsertionAfter(D);
}
if (const auto *TD = dyn_cast<TagDecl>(D)) {
SourceLocation Loc =
Lexer::getLocForEndOfToken(TD->getInnerLocStart(), 0, SM, LangOpts);
if (Loc.isInvalid())
- return None;
+ return std::nullopt;
// Insert after the 'struct'/whatever keyword.
return AttributeInsertion::createInsertionAfter(Loc);
}
diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index 0a24c7a5f383a..ec3110a8ece2b 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -1066,7 +1066,7 @@ void Sema::checkFortifiedBuiltinMemoryFunction(FunctionDecl *FD,
? DABAttr->argIndices_begin()[Index]
: Index - DABIndices + FD->getNumParams();
if (NewIndex >= TheCall->getNumArgs())
- return llvm::None;
+ return std::nullopt;
return NewIndex;
};
@@ -1074,12 +1074,12 @@ void Sema::checkFortifiedBuiltinMemoryFunction(FunctionDecl *FD,
[&](unsigned Index) -> Optional<llvm::APSInt> {
Optional<unsigned> IndexOptional = TranslateIndex(Index);
if (!IndexOptional)
- return llvm::None;
+ return std::nullopt;
unsigned NewIndex = *IndexOptional;
Expr::EvalResult Result;
Expr *SizeArg = TheCall->getArg(NewIndex);
if (!SizeArg->EvaluateAsInt(Result, getASTContext()))
- return llvm::None;
+ return std::nullopt;
llvm::APSInt Integer = Result.Val.getInt();
Integer.setIsUnsigned(true);
return Integer;
@@ -1099,16 +1099,16 @@ void Sema::checkFortifiedBuiltinMemoryFunction(FunctionDecl *FD,
Optional<unsigned> IndexOptional = TranslateIndex(Index);
if (!IndexOptional)
- return llvm::None;
+ return std::nullopt;
unsigned NewIndex = *IndexOptional;
if (NewIndex >= TheCall->getNumArgs())
- return llvm::None;
+ return std::nullopt;
const Expr *ObjArg = TheCall->getArg(NewIndex);
uint64_t Result;
if (!ObjArg->tryEvaluateObjectSize(Result, getASTContext(), BOSType))
- return llvm::None;
+ return std::nullopt;
// Get the object size in the target's size_t width.
return llvm::APSInt::getUnsigned(Result).extOrTrunc(SizeTypeWidth);
@@ -1117,13 +1117,13 @@ void Sema::checkFortifiedBuiltinMemoryFunction(FunctionDecl *FD,
auto ComputeStrLenArgument = [&](unsigned Index) -> Optional<llvm::APSInt> {
Optional<unsigned> IndexOptional = TranslateIndex(Index);
if (!IndexOptional)
- return llvm::None;
+ return std::nullopt;
unsigned NewIndex = *IndexOptional;
const Expr *ObjArg = TheCall->getArg(NewIndex);
uint64_t Result;
if (!ObjArg->tryEvaluateStrLen(Result, getASTContext()))
- return llvm::None;
+ return std::nullopt;
// Add 1 for null byte.
return llvm::APSInt::getUnsigned(Result + 1).extOrTrunc(SizeTypeWidth);
};
@@ -9129,7 +9129,7 @@ class CheckFormatHandler : public analyze_format_string::FormatStringHandler {
EmitFormatDiagnostic(Sema &S, bool inFunctionCall, const Expr *ArgumentExpr,
const PartialDiagnostic &PDiag, SourceLocation StringLoc,
bool IsStringLocation, Range StringRange,
- ArrayRef<FixItHint> Fixit = None);
+ ArrayRef<FixItHint> Fixit = std::nullopt);
protected:
bool HandleInvalidConversionSpecifier(unsigned argIndex, SourceLocation Loc,
@@ -9156,7 +9156,7 @@ class CheckFormatHandler : public analyze_format_string::FormatStringHandler {
template <typename Range>
void EmitFormatDiagnostic(PartialDiagnostic PDiag, SourceLocation StringLoc,
bool IsStringLocation, Range StringRange,
- ArrayRef<FixItHint> Fixit = None);
+ ArrayRef<FixItHint> Fixit = std::nullopt);
};
} // namespace
@@ -12739,7 +12739,7 @@ struct PromotedRange {
if (R & EQ) return StringRef("'std::strong_ordering::equal'");
if (R & LTFlag) return StringRef("'std::strong_ordering::less'");
if (R & GTFlag) return StringRef("'std::strong_ordering::greater'");
- return llvm::None;
+ return std::nullopt;
}
ComparisonResult TrueFlag, FalseFlag;
@@ -12764,7 +12764,7 @@ struct PromotedRange {
return StringRef("true");
if (R & FalseFlag)
return StringRef("false");
- return llvm::None;
+ return std::nullopt;
}
};
}
@@ -15751,12 +15751,12 @@ getAlignmentAndOffsetFromBinAddOrSub(const Expr *PtrE, const Expr *IntE,
QualType PointeeType = PtrE->getType()->getPointeeType();
if (!PointeeType->isConstantSizeType())
- return llvm::None;
+ return std::nullopt;
auto P = getBaseAlignmentAndOffsetFromPtr(PtrE, Ctx);
if (!P)
- return llvm::None;
+ return std::nullopt;
CharUnits EltSize = Ctx.getTypeSizeInChars(PointeeType);
if (Optional<llvm::APSInt> IdxRes = IntE->getIntegerConstantExpr(Ctx)) {
@@ -15859,7 +15859,7 @@ static getBaseAlignmentAndOffsetFromLValue(const Expr *E, ASTContext &Ctx) {
break;
}
}
- return llvm::None;
+ return std::nullopt;
}
/// This helper function takes a pointer expression and returns the alignment of
@@ -15924,7 +15924,7 @@ static getBaseAlignmentAndOffsetFromPtr(const Expr *E, ASTContext &Ctx) {
break;
}
}
- return llvm::None;
+ return std::nullopt;
}
static CharUnits getPresumedAlignmentOfPointer(const Expr *E, Sema &S) {
@@ -16491,7 +16491,7 @@ static Optional<int> GetNSMutableArrayArgumentIndex(Sema &S,
Message->getReceiverInterface(),
NSAPI::ClassId_NSMutableArray);
if (!IsMutableArray) {
- return None;
+ return std::nullopt;
}
Selector Sel = Message->getSelector();
@@ -16499,7 +16499,7 @@ static Optional<int> GetNSMutableArrayArgumentIndex(Sema &S,
Optional<NSAPI::NSArrayMethodKind> MKOpt =
S.NSAPIObj->getNSArrayMethodKind(Sel);
if (!MKOpt) {
- return None;
+ return std::nullopt;
}
NSAPI::NSArrayMethodKind MK = *MKOpt;
@@ -16513,10 +16513,10 @@ static Optional<int> GetNSMutableArrayArgumentIndex(Sema &S,
return 1;
default:
- return None;
+ return std::nullopt;
}
- return None;
+ return std::nullopt;
}
static
@@ -16526,7 +16526,7 @@ Optional<int> GetNSMutableDictionaryArgumentIndex(Sema &S,
Message->getReceiverInterface(),
NSAPI::ClassId_NSMutableDictionary);
if (!IsMutableDictionary) {
- return None;
+ return std::nullopt;
}
Selector Sel = Message->getSelector();
@@ -16534,7 +16534,7 @@ Optional<int> GetNSMutableDictionaryArgumentIndex(Sema &S,
Optional<NSAPI::NSDictionaryMethodKind> MKOpt =
S.NSAPIObj->getNSDictionaryMethodKind(Sel);
if (!MKOpt) {
- return None;
+ return std::nullopt;
}
NSAPI::NSDictionaryMethodKind MK = *MKOpt;
@@ -16546,10 +16546,10 @@ Optional<int> GetNSMutableDictionaryArgumentIndex(Sema &S,
return 0;
default:
- return None;
+ return std::nullopt;
}
- return None;
+ return std::nullopt;
}
static Optional<int> GetNSSetArgumentIndex(Sema &S, ObjCMessageExpr *Message) {
@@ -16561,14 +16561,14 @@ static Optional<int> GetNSSetArgumentIndex(Sema &S, ObjCMessageExpr *Message) {
Message->getReceiverInterface(),
NSAPI::ClassId_NSMutableOrderedSet);
if (!IsMutableSet && !IsMutableOrderedSet) {
- return None;
+ return std::nullopt;
}
Selector Sel = Message->getSelector();
Optional<NSAPI::NSSetMethodKind> MKOpt = S.NSAPIObj->getNSSetMethodKind(Sel);
if (!MKOpt) {
- return None;
+ return std::nullopt;
}
NSAPI::NSSetMethodKind MK = *MKOpt;
@@ -16583,7 +16583,7 @@ static Optional<int> GetNSSetArgumentIndex(Sema &S, ObjCMessageExpr *Message) {
return 1;
}
- return None;
+ return std::nullopt;
}
void Sema::CheckObjCCircularContainer(ObjCMessageExpr *Message) {
diff --git a/clang/lib/Sema/SemaCodeComplete.cpp b/clang/lib/Sema/SemaCodeComplete.cpp
index 21726920dd93c..31cd2abb24557 100644
--- a/clang/lib/Sema/SemaCodeComplete.cpp
+++ b/clang/lib/Sema/SemaCodeComplete.cpp
@@ -2855,13 +2855,12 @@ formatBlockPlaceholder(const PrintingPolicy &Policy, const NamedDecl *BlockDecl,
FunctionTypeLoc &Block, FunctionProtoTypeLoc &BlockProto,
bool SuppressBlockName = false,
bool SuppressBlock = false,
- Optional<ArrayRef<QualType>> ObjCSubsts = None);
+ Optional<ArrayRef<QualType>> ObjCSubsts = std::nullopt);
-static std::string
-FormatFunctionParameter(const PrintingPolicy &Policy,
- const DeclaratorDecl *Param, bool SuppressName = false,
- bool SuppressBlock = false,
- Optional<ArrayRef<QualType>> ObjCSubsts = None) {
+static std::string FormatFunctionParameter(
+ const PrintingPolicy &Policy, const DeclaratorDecl *Param,
+ bool SuppressName = false, bool SuppressBlock = false,
+ Optional<ArrayRef<QualType>> ObjCSubsts = std::nullopt) {
// Params are unavailable in FunctionTypeLoc if the FunctionType is invalid.
// It would be better to pass in the param Type, which is usually available.
// But this case is rare, so just pretend we fell back to int as elsewhere.
@@ -4480,7 +4479,8 @@ void Sema::CodeCompleteDeclSpec(Scope *S, DeclSpec &DS,
0) {
ParsedType T = DS.getRepAsType();
if (!T.get().isNull() && T.get()->isObjCObjectOrInterfaceType())
- AddClassMessageCompletions(*this, S, T, None, false, false, Results);
+ AddClassMessageCompletions(*this, S, T, std::nullopt, false, false,
+ Results);
}
// Note that we intentionally suppress macro results here, since we do not
@@ -4837,7 +4837,7 @@ void Sema::CodeCompletePostfixExpression(Scope *S, ExprResult E,
if (E.isInvalid())
CodeCompleteExpression(S, PreferredType);
else if (getLangOpts().ObjC)
- CodeCompleteObjCInstanceMessage(S, E.get(), None, false);
+ CodeCompleteObjCInstanceMessage(S, E.get(), std::nullopt, false);
}
/// The set of properties that have already been added, referenced by
@@ -5734,7 +5734,7 @@ void Sema::CodeCompleteMemberReferenceExpr(Scope *S, Expr *Base,
Results.EnterNewScope();
- bool CompletionSucceded = DoCompletion(Base, IsArrow, None);
+ bool CompletionSucceded = DoCompletion(Base, IsArrow, std::nullopt);
if (CodeCompleter->includeFixIts()) {
const CharSourceRange OpRange =
CharSourceRange::getTokenRange(OpLoc, OpLoc);
@@ -6219,7 +6219,7 @@ getNextAggregateIndexAfterDesignatedInit(const ResultCandidate &Aggregate,
}
}
if (!DesignatedFieldName)
- return llvm::None;
+ return std::nullopt;
// Find the index within the class's fields.
// (Probing getParamDecl() directly would be quadratic in number of fields).
@@ -7573,7 +7573,8 @@ void Sema::CodeCompleteObjCPropertyGetter(Scope *S) {
Results.EnterNewScope();
VisitedSelectorSet Selectors;
- AddObjCMethods(Class, true, MK_ZeroArgSelector, None, CurContext, Selectors,
+ AddObjCMethods(Class, true, MK_ZeroArgSelector, std::nullopt, CurContext,
+ Selectors,
/*AllowSameLength=*/true, Results);
Results.ExitScope();
HandleCodeCompleteResults(this, CodeCompleter, Results.getCompletionContext(),
@@ -7599,7 +7600,8 @@ void Sema::CodeCompleteObjCPropertySetter(Scope *S) {
Results.EnterNewScope();
VisitedSelectorSet Selectors;
- AddObjCMethods(Class, true, MK_OneArgSelector, None, CurContext, Selectors,
+ AddObjCMethods(Class, true, MK_OneArgSelector, std::nullopt, CurContext,
+ Selectors,
/*AllowSameLength=*/true, Results);
Results.ExitScope();
@@ -7895,7 +7897,8 @@ void Sema::CodeCompleteObjCMessageReceiver(Scope *S) {
if (Iface->getSuperClass()) {
Results.AddResult(Result("super"));
- AddSuperSendCompletion(*this, /*NeedSuperKeyword=*/true, None, Results);
+ AddSuperSendCompletion(*this, /*NeedSuperKeyword=*/true, std::nullopt,
+ Results);
}
if (getLangOpts().CPlusPlus11)
diff --git a/clang/lib/Sema/SemaConcept.cpp b/clang/lib/Sema/SemaConcept.cpp
index b02054bd97aaf..415ec70df0859 100644
--- a/clang/lib/Sema/SemaConcept.cpp
+++ b/clang/lib/Sema/SemaConcept.cpp
@@ -575,7 +575,7 @@ Sema::SetupConstraintCheckingTemplateArgumentsAndScope(
/*Pattern=*/nullptr,
/*ForConstraintInstantiation=*/true);
if (SetupConstraintScope(FD, TemplateArgs, MLTAL, Scope))
- return llvm::None;
+ return std::nullopt;
return MLTAL;
}
@@ -1154,11 +1154,11 @@ NormalizedConstraint::fromConstraintExprs(Sema &S, NamedDecl *D,
assert(E.size() != 0);
auto Conjunction = fromConstraintExpr(S, D, E[0]);
if (!Conjunction)
- return None;
+ return std::nullopt;
for (unsigned I = 1; I < E.size(); ++I) {
auto Next = fromConstraintExpr(S, D, E[I]);
if (!Next)
- return None;
+ return std::nullopt;
*Conjunction = NormalizedConstraint(S.Context, std::move(*Conjunction),
std::move(*Next), CCK_Conjunction);
}
@@ -1183,10 +1183,10 @@ NormalizedConstraint::fromConstraintExpr(Sema &S, NamedDecl *D, const Expr *E) {
if (LogicalBinOp BO = E) {
auto LHS = fromConstraintExpr(S, D, BO.getLHS());
if (!LHS)
- return None;
+ return std::nullopt;
auto RHS = fromConstraintExpr(S, D, BO.getRHS());
if (!RHS)
- return None;
+ return std::nullopt;
return NormalizedConstraint(S.Context, std::move(*LHS), std::move(*RHS),
BO.isAnd() ? CCK_Conjunction : CCK_Disjunction);
@@ -1210,14 +1210,14 @@ NormalizedConstraint::fromConstraintExpr(Sema &S, NamedDecl *D, const Expr *E) {
SubNF = S.getNormalizedAssociatedConstraints(CD,
{CD->getConstraintExpr()});
if (!SubNF)
- return None;
+ return std::nullopt;
}
Optional<NormalizedConstraint> New;
New.emplace(S.Context, *SubNF);
if (substituteParameterMappings(S, *New, CSE))
- return None;
+ return std::nullopt;
return New;
}
diff --git a/clang/lib/Sema/SemaCoroutine.cpp b/clang/lib/Sema/SemaCoroutine.cpp
index 46065b10156f8..4cedd53a76785 100644
--- a/clang/lib/Sema/SemaCoroutine.cpp
+++ b/clang/lib/Sema/SemaCoroutine.cpp
@@ -339,7 +339,7 @@ static Expr *maybeTailCall(Sema &S, QualType RetType, Expr *E,
// EvaluateBinaryTypeTrait(BTT_IsConvertible, ...) which is at the moment
// a private function in SemaExprCXX.cpp
- ExprResult AddressExpr = buildMemberCall(S, E, Loc, "address", None);
+ ExprResult AddressExpr = buildMemberCall(S, E, Loc, "address", std::nullopt);
if (AddressExpr.isInvalid())
return nullptr;
@@ -395,8 +395,8 @@ static ReadySuspendResumeResult buildCoawaitCalls(Sema &S, VarDecl *CoroPromise,
return Result.get();
};
- CallExpr *AwaitReady =
- cast_or_null<CallExpr>(BuildSubExpr(ACT::ACT_Ready, "await_ready", None));
+ CallExpr *AwaitReady = cast_or_null<CallExpr>(
+ BuildSubExpr(ACT::ACT_Ready, "await_ready", std::nullopt));
if (!AwaitReady)
return Calls;
if (!AwaitReady->getType()->isDependentType()) {
@@ -457,7 +457,7 @@ static ReadySuspendResumeResult buildCoawaitCalls(Sema &S, VarDecl *CoroPromise,
}
}
- BuildSubExpr(ACT::ACT_Resume, "await_resume", None);
+ BuildSubExpr(ACT::ACT_Resume, "await_resume", std::nullopt);
// Make sure the awaiter object gets a chance to be cleaned up.
S.Cleanup.setExprNeedsCleanups(true);
@@ -705,8 +705,8 @@ bool Sema::ActOnCoroutineBodyStart(Scope *SC, SourceLocation KWLoc,
SourceLocation Loc = Fn->getLocation();
// Build the initial suspend point
auto buildSuspends = [&](StringRef Name) mutable -> StmtResult {
- ExprResult Operand =
- buildPromiseCall(*this, ScopeInfo->CoroutinePromise, Loc, Name, None);
+ ExprResult Operand = buildPromiseCall(*this, ScopeInfo->CoroutinePromise,
+ Loc, Name, std::nullopt);
if (Operand.isInvalid())
return StmtError();
ExprResult Suspend =
@@ -997,7 +997,7 @@ StmtResult Sema::BuildCoreturnStmt(SourceLocation Loc, Expr *E,
PC = buildPromiseCall(*this, Promise, Loc, "return_value", E);
} else {
E = MakeFullDiscardedValueExpr(E).get();
- PC = buildPromiseCall(*this, Promise, Loc, "return_void", None);
+ PC = buildPromiseCall(*this, Promise, Loc, "return_void", std::nullopt);
}
if (PC.isInvalid())
return StmtError();
@@ -1670,8 +1670,8 @@ bool CoroutineStmtBuilder::makeOnException() {
if (!S.getLangOpts().CXXExceptions)
return true;
- ExprResult UnhandledException = buildPromiseCall(S, Fn.CoroutinePromise, Loc,
- "unhandled_exception", None);
+ ExprResult UnhandledException = buildPromiseCall(
+ S, Fn.CoroutinePromise, Loc, "unhandled_exception", std::nullopt);
UnhandledException = S.ActOnFinishFullExpr(UnhandledException.get(), Loc,
/*DiscardedValue*/ false);
if (UnhandledException.isInvalid())
@@ -1694,8 +1694,8 @@ bool CoroutineStmtBuilder::makeReturnObject() {
// [dcl.fct.def.coroutine]p7
// The expression promise.get_return_object() is used to initialize the
// returned reference or prvalue result object of a call to a coroutine.
- ExprResult ReturnObject =
- buildPromiseCall(S, Fn.CoroutinePromise, Loc, "get_return_object", None);
+ ExprResult ReturnObject = buildPromiseCall(S, Fn.CoroutinePromise, Loc,
+ "get_return_object", std::nullopt);
if (ReturnObject.isInvalid())
return false;
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 5f5124e6f6cbe..96ea3fb402e74 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -2225,7 +2225,7 @@ void Sema::ActOnPopScope(SourceLocation Loc, Scope *S) {
};
SmallVector<LocAndDiag, 16> DeclDiags;
auto addDiag = [&DeclDiags](SourceLocation Loc, PartialDiagnostic PD) {
- DeclDiags.push_back(LocAndDiag{Loc, None, std::move(PD)});
+ DeclDiags.push_back(LocAndDiag{Loc, std::nullopt, std::move(PD)});
};
auto addDiagWithPrev = [&DeclDiags](SourceLocation Loc,
SourceLocation PreviousDeclLoc,
@@ -13608,8 +13608,8 @@ void Sema::ActOnUninitializedDecl(Decl *RealDecl) {
InitializationKind Kind
= InitializationKind::CreateDefault(Var->getLocation());
- InitializationSequence InitSeq(*this, Entity, Kind, None);
- ExprResult Init = InitSeq.Perform(*this, Entity, Kind, None);
+ InitializationSequence InitSeq(*this, Entity, Kind, std::nullopt);
+ ExprResult Init = InitSeq.Perform(*this, Entity, Kind, std::nullopt);
if (Init.get()) {
Var->setInit(MaybeCreateExprWithCleanups(Init.get()));
@@ -15760,8 +15760,8 @@ NamedDecl *Sema::ImplicitlyDefineFunction(SourceLocation Loc,
/*NumExceptions=*/0,
/*NoexceptExpr=*/nullptr,
/*ExceptionSpecTokens=*/nullptr,
- /*DeclsInPrototype=*/None, Loc,
- Loc, D),
+ /*DeclsInPrototype=*/std::nullopt,
+ Loc, Loc, D),
std::move(DS.getAttributes()), SourceLocation());
D.SetIdentifier(&II, Loc);
diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
index e311a9ff45232..46153838e5f48 100644
--- a/clang/lib/Sema/SemaDeclAttr.cpp
+++ b/clang/lib/Sema/SemaDeclAttr.cpp
@@ -2676,7 +2676,7 @@ static void handleAvailabilityAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
if (IOSToWatchOSMapping) {
if (auto MappedVersion = IOSToWatchOSMapping->map(
- Version, MinimumWatchOSVersion, None)) {
+ Version, MinimumWatchOSVersion, std::nullopt)) {
return MappedVersion.value();
}
}
@@ -2731,8 +2731,8 @@ static void handleAvailabilityAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
return Version;
if (IOSToTvOSMapping) {
- if (auto MappedVersion =
- IOSToTvOSMapping->map(Version, VersionTuple(0, 0), None)) {
+ if (auto MappedVersion = IOSToTvOSMapping->map(
+ Version, VersionTuple(0, 0), std::nullopt)) {
return *MappedVersion;
}
}
@@ -2797,12 +2797,13 @@ static void handleAvailabilityAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
auto RemapMacOSVersion =
[&](const VersionTuple &V) -> Optional<VersionTuple> {
if (V.empty())
- return None;
+ return std::nullopt;
// API_TO_BE_DEPRECATED is 100000.
if (V.getMajor() == 100000)
return VersionTuple(100000);
// The minimum iosmac version is 13.1
- return MacOStoMacCatalystMapping->map(V, VersionTuple(13, 1), None);
+ return MacOStoMacCatalystMapping->map(V, VersionTuple(13, 1),
+ std::nullopt);
};
Optional<VersionTuple> NewIntroduced =
RemapMacOSVersion(Introduced.Version),
diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index 194298ab5f7bf..9a80a4874b6db 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -1265,7 +1265,7 @@ static bool checkTupleLikeDecomposition(Sema &S,
if (E.isInvalid())
return true;
- E = S.BuildCallExpr(nullptr, E.get(), Loc, None, Loc);
+ E = S.BuildCallExpr(nullptr, E.get(), Loc, std::nullopt, Loc);
} else {
// Otherwise, the initializer is get<i-1>(e), where get is looked up
// in the associated namespaces.
@@ -4750,8 +4750,8 @@ BuildImplicitBaseInitializer(Sema &SemaRef, CXXConstructorDecl *Constructor,
case IIK_Default: {
InitializationKind InitKind
= InitializationKind::CreateDefault(Constructor->getLocation());
- InitializationSequence InitSeq(SemaRef, InitEntity, InitKind, None);
- BaseInit = InitSeq.Perform(SemaRef, InitEntity, InitKind, None);
+ InitializationSequence InitSeq(SemaRef, InitEntity, InitKind, std::nullopt);
+ BaseInit = InitSeq.Perform(SemaRef, InitEntity, InitKind, std::nullopt);
break;
}
@@ -4915,9 +4915,9 @@ BuildImplicitMemberInitializer(Sema &SemaRef, CXXConstructorDecl *Constructor,
InitializationKind InitKind =
InitializationKind::CreateDefault(Loc);
- InitializationSequence InitSeq(SemaRef, InitEntity, InitKind, None);
+ InitializationSequence InitSeq(SemaRef, InitEntity, InitKind, std::nullopt);
ExprResult MemberInit =
- InitSeq.Perform(SemaRef, InitEntity, InitKind, None);
+ InitSeq.Perform(SemaRef, InitEntity, InitKind, std::nullopt);
MemberInit = SemaRef.MaybeCreateExprWithCleanups(MemberInit);
if (MemberInit.isInvalid())
@@ -10774,7 +10774,7 @@ QualType Sema::CheckDestructorDeclarator(Declarator &D, QualType R,
EPI.Variadic = false;
EPI.TypeQuals = Qualifiers();
EPI.RefQualifier = RQ_None;
- return Context.getFunctionType(Context.VoidTy, None, EPI);
+ return Context.getFunctionType(Context.VoidTy, std::nullopt, EPI);
}
static void extendLeft(SourceRange &R, SourceRange Before) {
@@ -10950,7 +10950,8 @@ void Sema::CheckConversionDeclarator(Declarator &D, QualType &R,
// of the errors above fired) and with the conversion type as the
// return type.
if (D.isInvalidType())
- R = Context.getFunctionType(ConvType, None, Proto->getExtProtoInfo());
+ R = Context.getFunctionType(ConvType, std::nullopt,
+ Proto->getExtProtoInfo());
// C++0x explicit conversion operators.
if (DS.hasExplicitSpecifier() && !getLangOpts().CPlusPlus20)
@@ -13538,7 +13539,7 @@ CXXConstructorDecl *Sema::DeclareImplicitDefaultConstructor(
DefaultCon->setAccess(AS_public);
DefaultCon->setDefaulted();
- setupImplicitSpecialMemberType(DefaultCon, Context.VoidTy, None);
+ setupImplicitSpecialMemberType(DefaultCon, Context.VoidTy, std::nullopt);
if (getLangOpts().CUDA)
inferCUDATargetForImplicitSpecialMember(ClassDecl, CXXDefaultConstructor,
@@ -13818,7 +13819,7 @@ CXXDestructorDecl *Sema::DeclareImplicitDestructor(CXXRecordDecl *ClassDecl) {
Destructor->setAccess(AS_public);
Destructor->setDefaulted();
- setupImplicitSpecialMemberType(Destructor, Context.VoidTy, None);
+ setupImplicitSpecialMemberType(Destructor, Context.VoidTy, std::nullopt);
if (getLangOpts().CUDA)
inferCUDATargetForImplicitSpecialMember(ClassDecl, CXXDestructor,
@@ -13979,7 +13980,8 @@ void Sema::AdjustDestructorExceptionSpec(CXXDestructorDecl *Destructor) {
FunctionProtoType::ExtProtoInfo EPI = DtorType->getExtProtoInfo();
EPI.ExceptionSpec.Type = EST_Unevaluated;
EPI.ExceptionSpec.SourceDecl = Destructor;
- Destructor->setType(Context.getFunctionType(Context.VoidTy, None, EPI));
+ Destructor->setType(
+ Context.getFunctionType(Context.VoidTy, std::nullopt, EPI));
// FIXME: If the destructor has a body that could throw, and the newly created
// spec doesn't allow exceptions, we should emit a warning, because this
@@ -15264,7 +15266,8 @@ void Sema::DefineImplicitCopyConstructor(SourceLocation CurrentLocation,
: CopyConstructor->getLocation();
Sema::CompoundScopeRAII CompoundScope(*this);
CopyConstructor->setBody(
- ActOnCompoundStmt(Loc, Loc, None, /*isStmtExpr=*/false).getAs<Stmt>());
+ ActOnCompoundStmt(Loc, Loc, std::nullopt, /*isStmtExpr=*/false)
+ .getAs<Stmt>());
CopyConstructor->markUsed(Context);
}
@@ -15389,8 +15392,9 @@ void Sema::DefineImplicitMoveConstructor(SourceLocation CurrentLocation,
? MoveConstructor->getEndLoc()
: MoveConstructor->getLocation();
Sema::CompoundScopeRAII CompoundScope(*this);
- MoveConstructor->setBody(ActOnCompoundStmt(
- Loc, Loc, None, /*isStmtExpr=*/ false).getAs<Stmt>());
+ MoveConstructor->setBody(
+ ActOnCompoundStmt(Loc, Loc, std::nullopt, /*isStmtExpr=*/false)
+ .getAs<Stmt>());
MoveConstructor->markUsed(Context);
}
@@ -18188,9 +18192,9 @@ void Sema::SetIvarInitializers(ObjCImplementationDecl *ObjCImplementation) {
InitializationKind InitKind =
InitializationKind::CreateDefault(ObjCImplementation->getLocation());
- InitializationSequence InitSeq(*this, InitEntity, InitKind, None);
+ InitializationSequence InitSeq(*this, InitEntity, InitKind, std::nullopt);
ExprResult MemberInit =
- InitSeq.Perform(*this, InitEntity, InitKind, None);
+ InitSeq.Perform(*this, InitEntity, InitKind, std::nullopt);
MemberInit = MaybeCreateExprWithCleanups(MemberInit);
// Note, MemberInit could actually come back empty if no initialization
// is required (e.g., because it would call a trivial default constructor)
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index cdd3b190c9c29..466a17dc1a0ed 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -1058,7 +1058,7 @@ ExprResult Sema::DefaultVariadicArgumentPromotion(Expr *E, VariadicCallType CT,
return ExprError();
ExprResult Call = BuildCallExpr(TUScope, TrapFn.get(), E->getBeginLoc(),
- None, E->getEndLoc());
+ std::nullopt, E->getEndLoc());
if (Call.isInvalid())
return ExprError();
@@ -1963,8 +1963,8 @@ Sema::ActOnStringLiteral(ArrayRef<Token> StringToks, Scope *UDLScope) {
TemplateArgument Arg(Lit);
TemplateArgumentLocInfo ArgInfo(Lit);
ExplicitArgs.addArgument(TemplateArgumentLoc(Arg, ArgInfo));
- return BuildLiteralOperatorCall(R, OpNameInfo, None, StringTokLocs.back(),
- &ExplicitArgs);
+ return BuildLiteralOperatorCall(R, OpNameInfo, std::nullopt,
+ StringTokLocs.back(), &ExplicitArgs);
}
case LOLR_StringTemplatePack: {
@@ -1984,8 +1984,8 @@ Sema::ActOnStringLiteral(ArrayRef<Token> StringToks, Scope *UDLScope) {
TemplateArgumentLocInfo ArgInfo;
ExplicitArgs.addArgument(TemplateArgumentLoc(Arg, ArgInfo));
}
- return BuildLiteralOperatorCall(R, OpNameInfo, None, StringTokLocs.back(),
- &ExplicitArgs);
+ return BuildLiteralOperatorCall(R, OpNameInfo, std::nullopt,
+ StringTokLocs.back(), &ExplicitArgs);
}
case LOLR_Raw:
case LOLR_ErrorNoDiagnostic:
@@ -2624,7 +2624,7 @@ Sema::ActOnIdExpression(Scope *S, CXXScopeSpec &SS,
// a template name, but we happen to have always already looked up the name
// before we get here if it must be a template name.
if (DiagnoseEmptyLookup(S, SS, R, CCC ? *CCC : DefaultValidator, nullptr,
- None, &TE)) {
+ std::nullopt, &TE)) {
if (TE && KeywordReplacement) {
auto &State = getTypoExprState(TE);
auto BestTC = State.Consumer->getNextCorrection();
@@ -3855,7 +3855,7 @@ ExprResult Sema::ActOnNumericConstant(const Token &Tok, Scope *UDLScope) {
TemplateArgumentLocInfo ArgInfo;
ExplicitArgs.addArgument(TemplateArgumentLoc(Arg, ArgInfo));
}
- return BuildLiteralOperatorCall(R, OpNameInfo, None, TokLoc,
+ return BuildLiteralOperatorCall(R, OpNameInfo, std::nullopt, TokLoc,
&ExplicitArgs);
}
case LOLR_StringTemplatePack:
@@ -16245,7 +16245,7 @@ void Sema::ActOnBlockArguments(SourceLocation CaretLoc, Declarator &ParamInfo,
FunctionProtoType::ExtProtoInfo EPI;
EPI.HasTrailingReturn = false;
EPI.TypeQuals.addConst();
- T = Context.getFunctionType(Context.DependentTy, None, EPI);
+ T = Context.getFunctionType(Context.DependentTy, std::nullopt, EPI);
Sig = Context.getTrivialTypeSourceInfo(T);
}
@@ -16395,10 +16395,10 @@ ExprResult Sema::ActOnBlockStmtExpr(SourceLocation CaretLoc,
if (isa<FunctionNoProtoType>(FTy)) {
FunctionProtoType::ExtProtoInfo EPI;
EPI.ExtInfo = Ext;
- BlockTy = Context.getFunctionType(RetTy, None, EPI);
+ BlockTy = Context.getFunctionType(RetTy, std::nullopt, EPI);
- // Otherwise, if we don't need to change anything about the function type,
- // preserve its sugar structure.
+ // Otherwise, if we don't need to change anything about the function type,
+ // preserve its sugar structure.
} else if (FTy->getReturnType() == RetTy &&
(!NoReturn || FTy->getNoReturnAttr())) {
BlockTy = BSI->FunctionType;
@@ -16416,7 +16416,7 @@ ExprResult Sema::ActOnBlockStmtExpr(SourceLocation CaretLoc,
} else {
FunctionProtoType::ExtProtoInfo EPI;
EPI.ExtInfo = FunctionType::ExtInfo().withNoReturn(NoReturn);
- BlockTy = Context.getFunctionType(RetTy, None, EPI);
+ BlockTy = Context.getFunctionType(RetTy, std::nullopt, EPI);
}
DiagnoseUnusedParameters(BD->parameters());
@@ -19968,7 +19968,7 @@ bool Sema::DiagRuntimeBehavior(SourceLocation Loc, ArrayRef<const Stmt*> Stmts,
bool Sema::DiagRuntimeBehavior(SourceLocation Loc, const Stmt *Statement,
const PartialDiagnostic &PD) {
return DiagRuntimeBehavior(
- Loc, Statement ? llvm::makeArrayRef(Statement) : llvm::None, PD);
+ Loc, Statement ? llvm::makeArrayRef(Statement) : std::nullopt, PD);
}
bool Sema::CheckCallReturnType(QualType ReturnType, SourceLocation Loc,
@@ -20892,7 +20892,7 @@ ExprResult Sema::ActOnObjCAvailabilityCheckExpr(
});
}
if (Spec == AvailSpecs.end())
- return None;
+ return std::nullopt;
return Spec->getVersion();
};
diff --git a/clang/lib/Sema/SemaExprObjC.cpp b/clang/lib/Sema/SemaExprObjC.cpp
index 21326b3a1ba19..3a672741fb477 100644
--- a/clang/lib/Sema/SemaExprObjC.cpp
+++ b/clang/lib/Sema/SemaExprObjC.cpp
@@ -298,7 +298,7 @@ static ObjCMethodDecl *getNSNumberFactoryMethod(Sema &S, SourceLocation Loc,
&CX.Idents.get("value"),
NumberType, /*TInfo=*/nullptr,
SC_None, nullptr);
- Method->setMethodParams(S.Context, value, None);
+ Method->setMethodParams(S.Context, value, std::nullopt);
}
if (!validateBoxingMethod(S, Loc, S.NSNumberDecl, Sel, Method))
@@ -577,7 +577,7 @@ ExprResult Sema::BuildObjCBoxedExpr(SourceRange SR, Expr *ValueExpr) {
Context.getPointerType(ConstCharType),
/*TInfo=*/nullptr,
SC_None, nullptr);
- M->setMethodParams(Context, value, None);
+ M->setMethodParams(Context, value, std::nullopt);
BoxingMethod = M;
}
@@ -705,7 +705,7 @@ ExprResult Sema::BuildObjCBoxedExpr(SourceRange SR, Expr *ValueExpr) {
SC_None, nullptr);
Params.push_back(type);
- M->setMethodParams(Context, Params, None);
+ M->setMethodParams(Context, Params, std::nullopt);
BoxingMethod = M;
}
@@ -833,7 +833,7 @@ ExprResult Sema::BuildObjCArrayLiteral(SourceRange SR, MultiExprArg Elements) {
/*TInfo=*/nullptr, SC_None,
nullptr);
Params.push_back(cnt);
- Method->setMethodParams(Context, Params, None);
+ Method->setMethodParams(Context, Params, std::nullopt);
}
if (!validateBoxingMethod(*this, Loc, NSArrayDecl, Sel, Method))
@@ -1003,7 +1003,7 @@ ExprResult Sema::BuildObjCDictionaryLiteral(SourceRange SR,
/*TInfo=*/nullptr, SC_None,
nullptr);
Params.push_back(cnt);
- Method->setMethodParams(Context, Params, None);
+ Method->setMethodParams(Context, Params, std::nullopt);
}
if (!validateBoxingMethod(*this, SR.getBegin(), NSDictionaryDecl, Sel,
@@ -4377,11 +4377,9 @@ Sema::CheckObjCBridgeRelatedConversions(SourceLocation Loc,
Diag(RelatedClass->getBeginLoc(), diag::note_declared_at);
Diag(TDNDecl->getBeginLoc(), diag::note_declared_at);
- ExprResult msg =
- BuildInstanceMessageImplicit(SrcExpr, SrcType,
- InstanceMethod->getLocation(),
- InstanceMethod->getSelector(),
- InstanceMethod, None);
+ ExprResult msg = BuildInstanceMessageImplicit(
+ SrcExpr, SrcType, InstanceMethod->getLocation(),
+ InstanceMethod->getSelector(), InstanceMethod, std::nullopt);
SrcExpr = msg.get();
}
return true;
diff --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp
index 68f5f30103159..a92c24d577baa 100644
--- a/clang/lib/Sema/SemaInit.cpp
+++ b/clang/lib/Sema/SemaInit.cpp
@@ -503,7 +503,7 @@ ExprResult InitListChecker::PerformEmptyInit(SourceLocation Loc,
true);
MultiExprArg SubInit;
Expr *InitExpr;
- InitListExpr DummyInitList(SemaRef.Context, Loc, None, Loc);
+ InitListExpr DummyInitList(SemaRef.Context, Loc, std::nullopt, Loc);
// C++ [dcl.init.aggr]p7:
// If there are fewer initializer-clauses in the list than there are
@@ -522,8 +522,10 @@ ExprResult InitListChecker::PerformEmptyInit(SourceLocation Loc,
//
// Only do this if we're initializing a class type, to avoid filling in
// the initializer list where possible.
- InitExpr = VerifyOnly ? &DummyInitList : new (SemaRef.Context)
- InitListExpr(SemaRef.Context, Loc, None, Loc);
+ InitExpr = VerifyOnly
+ ? &DummyInitList
+ : new (SemaRef.Context)
+ InitListExpr(SemaRef.Context, Loc, std::nullopt, Loc);
InitExpr->setType(SemaRef.Context.VoidTy);
SubInit = InitExpr;
Kind = InitializationKind::CreateCopy(Loc, Loc);
@@ -3120,10 +3122,8 @@ InitListExpr *
InitListChecker::createInitListExpr(QualType CurrentObjectType,
SourceRange InitRange,
unsigned ExpectedNumInits) {
- InitListExpr *Result
- = new (SemaRef.Context) InitListExpr(SemaRef.Context,
- InitRange.getBegin(), None,
- InitRange.getEnd());
+ InitListExpr *Result = new (SemaRef.Context) InitListExpr(
+ SemaRef.Context, InitRange.getBegin(), std::nullopt, InitRange.getEnd());
QualType ResultType = CurrentObjectType;
if (!ResultType->isArrayType())
@@ -5237,7 +5237,7 @@ static void TryDefaultInitialization(Sema &S,
// constructor for T is called (and the initialization is ill-formed if
// T has no accessible default constructor);
if (DestType->isRecordType() && S.getLangOpts().CPlusPlus) {
- TryConstructorInitialization(S, Entity, Kind, None, DestType,
+ TryConstructorInitialization(S, Entity, Kind, std::nullopt, DestType,
Entity.getType(), Sequence);
return;
}
diff --git a/clang/lib/Sema/SemaLambda.cpp b/clang/lib/Sema/SemaLambda.cpp
index a22708df5dbed..176b9c6a432c7 100644
--- a/clang/lib/Sema/SemaLambda.cpp
+++ b/clang/lib/Sema/SemaLambda.cpp
@@ -953,8 +953,8 @@ void Sema::ActOnStartOfLambdaDefinition(LambdaIntroducer &Intro,
QualType DefaultTypeForNoTrailingReturn =
getLangOpts().CPlusPlus14 ? Context.getAutoDeductType()
: Context.DependentTy;
- QualType MethodTy =
- Context.getFunctionType(DefaultTypeForNoTrailingReturn, None, EPI);
+ QualType MethodTy = Context.getFunctionType(DefaultTypeForNoTrailingReturn,
+ std::nullopt, EPI);
MethodTyInfo = Context.getTrivialTypeSourceInfo(MethodTy);
ExplicitParams = false;
ExplicitResultType = false;
@@ -1411,7 +1411,7 @@ static void addFunctionPointerConversion(Sema &S, SourceRange IntroducerRange,
ConvExtInfo.TypeQuals.addConst();
ConvExtInfo.ExceptionSpec.Type = EST_BasicNoexcept;
QualType ConvTy =
- S.Context.getFunctionType(PtrToFunctionTy, None, ConvExtInfo);
+ S.Context.getFunctionType(PtrToFunctionTy, std::nullopt, ConvExtInfo);
SourceLocation Loc = IntroducerRange.getBegin();
DeclarationName ConversionName
@@ -1588,7 +1588,8 @@ static void addBlockPointerConversion(Sema &S,
/*IsVariadic=*/false, /*IsCXXMethod=*/true));
ConversionEPI.TypeQuals = Qualifiers();
ConversionEPI.TypeQuals.addConst();
- QualType ConvTy = S.Context.getFunctionType(BlockPtrTy, None, ConversionEPI);
+ QualType ConvTy =
+ S.Context.getFunctionType(BlockPtrTy, std::nullopt, ConversionEPI);
SourceLocation Loc = IntroducerRange.getBegin();
DeclarationName Name
diff --git a/clang/lib/Sema/SemaLookup.cpp b/clang/lib/Sema/SemaLookup.cpp
index 39e88bccfef64..c73acf1619930 100644
--- a/clang/lib/Sema/SemaLookup.cpp
+++ b/clang/lib/Sema/SemaLookup.cpp
@@ -1179,9 +1179,8 @@ static bool LookupDirect(Sema &S, LookupResult &R, const DeclContext *DC) {
FunctionProtoType::ExtProtoInfo EPI = ConvProto->getExtProtoInfo();
EPI.ExtInfo = EPI.ExtInfo.withCallingConv(CC_C);
EPI.ExceptionSpec = EST_None;
- QualType ExpectedType
- = R.getSema().Context.getFunctionType(R.getLookupName().getCXXNameType(),
- None, EPI);
+ QualType ExpectedType = R.getSema().Context.getFunctionType(
+ R.getLookupName().getCXXNameType(), std::nullopt, EPI);
// Perform template argument deduction against the type that we would
// expect the function to have.
diff --git a/clang/lib/Sema/SemaModule.cpp b/clang/lib/Sema/SemaModule.cpp
index 1a48a06085cde..bb0457605704d 100644
--- a/clang/lib/Sema/SemaModule.cpp
+++ b/clang/lib/Sema/SemaModule.cpp
@@ -836,7 +836,7 @@ static llvm::Optional<UnnamedDeclKind> getUnnamedDeclKind(Decl *D) {
if (isa<UsingDirectiveDecl>(D))
return UnnamedDeclKind::UsingDirective;
// Everything else either introduces one or more names or is ill-formed.
- return llvm::None;
+ return std::nullopt;
}
unsigned getUnnamedDeclDiag(UnnamedDeclKind UDK, bool InBlock) {
diff --git a/clang/lib/Sema/SemaObjCProperty.cpp b/clang/lib/Sema/SemaObjCProperty.cpp
index 266a6ebc8a813..159daca6a6421 100644
--- a/clang/lib/Sema/SemaObjCProperty.cpp
+++ b/clang/lib/Sema/SemaObjCProperty.cpp
@@ -2571,7 +2571,7 @@ void Sema::ProcessPropertyDecl(ObjCPropertyDecl *property) {
/*TInfo=*/nullptr,
SC_None,
nullptr);
- SetterMethod->setMethodParams(Context, Argument, None);
+ SetterMethod->setMethodParams(Context, Argument, std::nullopt);
AddPropertyAttrs(*this, SetterMethod, property);
diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index 89f7a6be81fa4..a60129b573159 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -1119,14 +1119,14 @@ class DSAStackTy {
const SharingMapTy &StackElem = getTopOfStack();
auto I = StackElem.UsesAllocatorsDecls.find(D);
if (I == StackElem.UsesAllocatorsDecls.end())
- return None;
+ return std::nullopt;
return I->getSecond();
}
Optional<UsesAllocatorsDeclKind> isUsesAllocatorsDecl(const Decl *D) const {
const SharingMapTy &StackElem = getTopOfStack();
auto I = StackElem.UsesAllocatorsDecls.find(D);
if (I == StackElem.UsesAllocatorsDecls.end())
- return None;
+ return std::nullopt;
return I->getSecond();
}
@@ -7293,14 +7293,14 @@ Sema::checkOpenMPDeclareVariantFunction(Sema::DeclGroupPtrTy DG,
unsigned NumAppendArgs,
SourceRange SR) {
if (!DG || DG.get().isNull())
- return None;
+ return std::nullopt;
const int VariantId = 1;
// Must be applied only to single decl.
if (!DG.get().isSingleDecl()) {
Diag(SR.getBegin(), diag::err_omp_single_decl_in_declare_simd_variant)
<< VariantId << SR;
- return None;
+ return std::nullopt;
}
Decl *ADecl = DG.get().getSingleDecl();
if (auto *FTD = dyn_cast<FunctionTemplateDecl>(ADecl))
@@ -7311,7 +7311,7 @@ Sema::checkOpenMPDeclareVariantFunction(Sema::DeclGroupPtrTy DG,
if (!FD) {
Diag(ADecl->getLocation(), diag::err_omp_function_expected)
<< VariantId << SR;
- return None;
+ return std::nullopt;
}
auto &&HasMultiVersionAttributes = [](const FunctionDecl *FD) {
@@ -7323,7 +7323,7 @@ Sema::checkOpenMPDeclareVariantFunction(Sema::DeclGroupPtrTy DG,
if (HasMultiVersionAttributes(FD)) {
Diag(FD->getLocation(), diag::err_omp_declare_variant_incompat_attributes)
<< SR;
- return None;
+ return std::nullopt;
}
// Allow #pragma omp declare variant only if the function is not used.
@@ -7341,7 +7341,7 @@ Sema::checkOpenMPDeclareVariantFunction(Sema::DeclGroupPtrTy DG,
// The VariantRef must point to function.
if (!VariantRef) {
Diag(SR.getBegin(), diag::err_omp_function_expected) << VariantId;
- return None;
+ return std::nullopt;
}
auto ShouldDelayChecks = [](Expr *&E, bool) {
@@ -7376,7 +7376,7 @@ Sema::checkOpenMPDeclareVariantFunction(Sema::DeclGroupPtrTy DG,
return true;
};
if (TI.anyScoreOrCondition(HandleNonConstantScoresAndConditions))
- return None;
+ return std::nullopt;
QualType AdjustedFnType = FD->getType();
if (NumAppendArgs) {
@@ -7384,7 +7384,7 @@ Sema::checkOpenMPDeclareVariantFunction(Sema::DeclGroupPtrTy DG,
if (!PTy) {
Diag(FD->getLocation(), diag::err_omp_declare_variant_prototype_required)
<< SR;
- return None;
+ return std::nullopt;
}
// Adjust the function type to account for an extra omp_interop_t for each
// specified in the append_args clause.
@@ -7397,12 +7397,12 @@ Sema::checkOpenMPDeclareVariantFunction(Sema::DeclGroupPtrTy DG,
}
if (!TD) {
Diag(SR.getBegin(), diag::err_omp_interop_type_not_found) << SR;
- return None;
+ return std::nullopt;
}
QualType InteropType = Context.getTypeDeclType(TD);
if (PTy->isVariadic()) {
Diag(FD->getLocation(), diag::err_omp_append_args_with_varargs) << SR;
- return None;
+ return std::nullopt;
}
llvm::SmallVector<QualType, 8> Params;
Params.append(PTy->param_type_begin(), PTy->param_type_end());
@@ -7432,7 +7432,7 @@ Sema::checkOpenMPDeclareVariantFunction(Sema::DeclGroupPtrTy DG,
if (!ER.isUsable()) {
Diag(VariantRef->getExprLoc(), diag::err_omp_function_expected)
<< VariantId << VariantRef->getSourceRange();
- return None;
+ return std::nullopt;
}
VariantRef = ER.get();
} else {
@@ -7452,12 +7452,12 @@ Sema::checkOpenMPDeclareVariantFunction(Sema::DeclGroupPtrTy DG,
<< VariantRef->getType()
<< ((Method && !Method->isStatic()) ? FnPtrType : FD->getType())
<< (NumAppendArgs ? 1 : 0) << VariantRef->getSourceRange();
- return None;
+ return std::nullopt;
}
VariantRefCast = PerformImplicitConversion(
VariantRef, FnPtrType.getUnqualifiedType(), AA_Converting);
if (!VariantRefCast.isUsable())
- return None;
+ return std::nullopt;
}
// Drop previously built artificial addr_of unary op for member functions.
if (Method && !Method->isStatic()) {
@@ -7473,7 +7473,7 @@ Sema::checkOpenMPDeclareVariantFunction(Sema::DeclGroupPtrTy DG,
!ER.get()->IgnoreParenImpCasts()->getType()->isFunctionType()) {
Diag(VariantRef->getExprLoc(), diag::err_omp_function_expected)
<< VariantId << VariantRef->getSourceRange();
- return None;
+ return std::nullopt;
}
// The VariantRef must point to function.
@@ -7481,20 +7481,20 @@ Sema::checkOpenMPDeclareVariantFunction(Sema::DeclGroupPtrTy DG,
if (!DRE) {
Diag(VariantRef->getExprLoc(), diag::err_omp_function_expected)
<< VariantId << VariantRef->getSourceRange();
- return None;
+ return std::nullopt;
}
auto *NewFD = dyn_cast_or_null<FunctionDecl>(DRE->getDecl());
if (!NewFD) {
Diag(VariantRef->getExprLoc(), diag::err_omp_function_expected)
<< VariantId << VariantRef->getSourceRange();
- return None;
+ return std::nullopt;
}
if (FD->getCanonicalDecl() == NewFD->getCanonicalDecl()) {
Diag(VariantRef->getExprLoc(),
diag::err_omp_declare_variant_same_base_function)
<< VariantRef->getSourceRange();
- return None;
+ return std::nullopt;
}
// Check if function types are compatible in C.
@@ -7506,7 +7506,7 @@ Sema::checkOpenMPDeclareVariantFunction(Sema::DeclGroupPtrTy DG,
diag::err_omp_declare_variant_incompat_types)
<< NewFD->getType() << FD->getType() << (NumAppendArgs ? 1 : 0)
<< VariantRef->getSourceRange();
- return None;
+ return std::nullopt;
}
if (NewType->isFunctionProtoType()) {
if (FD->getType()->isFunctionNoProtoType())
@@ -7524,7 +7524,7 @@ Sema::checkOpenMPDeclareVariantFunction(Sema::DeclGroupPtrTy DG,
SourceRange SR =
NewFD->specific_attr_begin<OMPDeclareVariantAttr>()->getRange();
Diag(SR.getBegin(), diag::note_omp_marked_declare_variant_here) << SR;
- return None;
+ return std::nullopt;
}
enum DoesntSupport {
@@ -7540,38 +7540,38 @@ Sema::checkOpenMPDeclareVariantFunction(Sema::DeclGroupPtrTy DG,
if (CXXFD->isVirtual()) {
Diag(FD->getLocation(), diag::err_omp_declare_variant_doesnt_support)
<< VirtFuncs;
- return None;
+ return std::nullopt;
}
if (isa<CXXConstructorDecl>(FD)) {
Diag(FD->getLocation(), diag::err_omp_declare_variant_doesnt_support)
<< Constructors;
- return None;
+ return std::nullopt;
}
if (isa<CXXDestructorDecl>(FD)) {
Diag(FD->getLocation(), diag::err_omp_declare_variant_doesnt_support)
<< Destructors;
- return None;
+ return std::nullopt;
}
}
if (FD->isDeleted()) {
Diag(FD->getLocation(), diag::err_omp_declare_variant_doesnt_support)
<< DeletedFuncs;
- return None;
+ return std::nullopt;
}
if (FD->isDefaulted()) {
Diag(FD->getLocation(), diag::err_omp_declare_variant_doesnt_support)
<< DefaultedFuncs;
- return None;
+ return std::nullopt;
}
if (FD->isConstexpr()) {
Diag(FD->getLocation(), diag::err_omp_declare_variant_doesnt_support)
<< (NewFD->isConsteval() ? ConstevalFuncs : ConstexprFuncs);
- return None;
+ return std::nullopt;
}
// Check general compatibility.
@@ -7587,7 +7587,7 @@ Sema::checkOpenMPDeclareVariantFunction(Sema::DeclGroupPtrTy DG,
<< FD->getLocation()),
/*TemplatesSupported=*/true, /*ConstexprSupported=*/false,
/*CLinkageMayDiffer=*/true))
- return None;
+ return std::nullopt;
return std::make_pair(FD, cast<Expr>(DRE));
}
@@ -8091,7 +8091,7 @@ OpenMPIterationSpaceChecker::doesDependOnLoopCounter(const Stmt *S,
DepDecl = LoopStmtChecker.getDepDecl();
return LoopStmtChecker.getBaseLoopId();
}
- return llvm::None;
+ return std::nullopt;
}
bool OpenMPIterationSpaceChecker::checkAndSetInit(Stmt *S, bool EmitDiags) {
@@ -8232,10 +8232,10 @@ bool OpenMPIterationSpaceChecker::checkAndSetCond(Expr *S) {
(Opcode == BO_LT || Opcode == BO_GT), SR, OpLoc);
} else if (IneqCondIsCanonical && Opcode == BO_NE) {
return setUB(const_cast<Expr *>(getInitLCDecl(LHS) == LCDecl ? RHS : LHS),
- /*LessOp=*/llvm::None,
+ /*LessOp=*/std::nullopt,
/*StrictOp=*/true, SR, OpLoc);
}
- return llvm::None;
+ return std::nullopt;
};
llvm::Optional<bool> Res;
if (auto *RBO = dyn_cast<CXXRewrittenBinaryOperator>(S)) {
@@ -16623,7 +16623,7 @@ OMPClause *Sema::ActOnOpenMPSimpleClause(
static std::string
getListOfPossibleValues(OpenMPClauseKind K, unsigned First, unsigned Last,
- ArrayRef<unsigned> Exclude = llvm::None) {
+ ArrayRef<unsigned> Exclude = std::nullopt) {
SmallString<256> Buffer;
llvm::raw_svector_ostream Out(Buffer);
unsigned Skipped = Exclude.size();
@@ -21551,7 +21551,7 @@ static void checkMappableExpressionList(
CXXScopeSpec &MapperIdScopeSpec, DeclarationNameInfo MapperId,
ArrayRef<Expr *> UnresolvedMappers,
OpenMPMapClauseKind MapType = OMPC_MAP_unknown,
- ArrayRef<OpenMPMapModifierKind> Modifiers = None,
+ ArrayRef<OpenMPMapModifierKind> Modifiers = std::nullopt,
bool IsMapTypeImplicit = false, bool NoDiagnose = false) {
// We only expect mappable expressions in 'to', 'from', and 'map' clauses.
assert((CKind == OMPC_map || CKind == OMPC_to || CKind == OMPC_from) &&
diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp
index 1eb68090a8fdb..bbf5e5c873de1 100644
--- a/clang/lib/Sema/SemaOverload.cpp
+++ b/clang/lib/Sema/SemaOverload.cpp
@@ -890,7 +890,7 @@ llvm::Optional<unsigned> DeductionFailureInfo::getCallArgIndex() {
return static_cast<DFIDeducedMismatchArgs*>(Data)->CallArgIndex;
default:
- return llvm::None;
+ return std::nullopt;
}
}
@@ -5192,7 +5192,7 @@ TryListConversion(Sema &S, InitListExpr *From, QualType ToType,
}
if (CT->getSize().ugt(e)) {
// Need an init from empty {}, is there one?
- InitListExpr EmptyList(S.Context, From->getEndLoc(), None,
+ InitListExpr EmptyList(S.Context, From->getEndLoc(), std::nullopt,
From->getEndLoc());
EmptyList.setType(S.Context.VoidTy);
DfltElt = TryListConversion(
@@ -7013,7 +7013,7 @@ void Sema::AddMethodCandidate(DeclAccessPair FoundDecl, QualType ObjectType,
} else {
AddMethodCandidate(cast<CXXMethodDecl>(Decl), FoundDecl, ActingContext,
ObjectType, ObjectClassification, Args, CandidateSet,
- SuppressUserConversions, false, None, PO);
+ SuppressUserConversions, false, std::nullopt, PO);
}
}
@@ -7628,7 +7628,7 @@ void Sema::AddConversionCandidate(
}
if (EnableIfAttr *FailedAttr =
- CheckEnableIf(Conversion, CandidateSet.getLocation(), None)) {
+ CheckEnableIf(Conversion, CandidateSet.getLocation(), std::nullopt)) {
Candidate.Viable = false;
Candidate.FailureKind = ovl_fail_enable_if;
Candidate.DeductionFailure.Data = FailedAttr;
@@ -7799,7 +7799,7 @@ void Sema::AddSurrogateCandidate(CXXConversionDecl *Conversion,
}
if (EnableIfAttr *FailedAttr =
- CheckEnableIf(Conversion, CandidateSet.getLocation(), None)) {
+ CheckEnableIf(Conversion, CandidateSet.getLocation(), std::nullopt)) {
Candidate.Viable = false;
Candidate.FailureKind = ovl_fail_enable_if;
Candidate.DeductionFailure.Data = FailedAttr;
@@ -7841,10 +7841,10 @@ void Sema::AddNonMemberOperatorCandidates(
continue;
AddOverloadCandidate(FD, F.getPair(), FunctionArgs, CandidateSet);
if (CandidateSet.getRewriteInfo().shouldAddReversed(*this, Args, FD))
- AddOverloadCandidate(FD, F.getPair(),
- {FunctionArgs[1], FunctionArgs[0]}, CandidateSet,
- false, false, true, false, ADLCallKind::NotADL,
- None, OverloadCandidateParamOrder::Reversed);
+ AddOverloadCandidate(
+ FD, F.getPair(), {FunctionArgs[1], FunctionArgs[0]}, CandidateSet,
+ false, false, true, false, ADLCallKind::NotADL, std::nullopt,
+ OverloadCandidateParamOrder::Reversed);
}
}
}
@@ -9602,7 +9602,8 @@ Sema::AddArgumentDependentLookupCandidates(DeclarationName Name,
FD, FoundDecl, {Args[1], Args[0]}, CandidateSet,
/*SuppressUserConversions=*/false, PartialOverloading,
/*AllowExplicit=*/true, /*AllowExplicitConversion=*/false,
- ADLCallKind::UsesADL, None, OverloadCandidateParamOrder::Reversed);
+ ADLCallKind::UsesADL, std::nullopt,
+ OverloadCandidateParamOrder::Reversed);
}
} else {
auto *FTD = cast<FunctionTemplateDecl>(*I);
@@ -9737,7 +9738,7 @@ isBetterMultiversionCandidate(const OverloadCandidate &Cand1,
static Optional<QualType> getImplicitObjectParamType(ASTContext &Context,
const FunctionDecl *F) {
if (!isa<CXXMethodDecl>(F) || isa<CXXConstructorDecl>(F))
- return llvm::None;
+ return std::nullopt;
auto *M = cast<CXXMethodDecl>(F);
// Static member functions' object parameters match all types.
@@ -12643,11 +12644,11 @@ Sema::resolveAddressOfSingleOverloadCandidate(Expr *E, DeclAccessPair &Pair) {
FD2->getAssociatedConstraints(AC2);
bool AtLeastAsConstrained1, AtLeastAsConstrained2;
if (IsAtLeastAsConstrained(FD1, AC1, FD2, AC2, AtLeastAsConstrained1))
- return None;
+ return std::nullopt;
if (IsAtLeastAsConstrained(FD2, AC2, FD1, AC1, AtLeastAsConstrained2))
- return None;
+ return std::nullopt;
if (AtLeastAsConstrained1 == AtLeastAsConstrained2)
- return None;
+ return std::nullopt;
return AtLeastAsConstrained1;
};
@@ -15125,7 +15126,8 @@ Sema::BuildOverloadedArrowExpr(Scope *S, Expr *Base, SourceLocation OpLoc,
for (LookupResult::iterator Oper = R.begin(), OperEnd = R.end();
Oper != OperEnd; ++Oper) {
AddMethodCandidate(Oper.getPair(), Base->getType(), Base->Classify(Context),
- None, CandidateSet, /*SuppressUserConversion=*/false);
+ std::nullopt, CandidateSet,
+ /*SuppressUserConversion=*/false);
}
bool HadMultipleCandidates = (CandidateSet.size() > 1);
@@ -15315,7 +15317,8 @@ Sema::BuildForRangeBeginEndCall(SourceLocation Loc,
*CallExpr = ExprError();
return FRS_DiagnosticIssued;
}
- *CallExpr = BuildCallExpr(S, MemberRef.get(), Loc, None, Loc, nullptr);
+ *CallExpr =
+ BuildCallExpr(S, MemberRef.get(), Loc, std::nullopt, Loc, nullptr);
if (CallExpr->isInvalid()) {
*CallExpr = ExprError();
return FRS_DiagnosticIssued;
diff --git a/clang/lib/Sema/SemaPseudoObject.cpp b/clang/lib/Sema/SemaPseudoObject.cpp
index 7fdb34905b616..abbdc12e70474 100644
--- a/clang/lib/Sema/SemaPseudoObject.cpp
+++ b/clang/lib/Sema/SemaPseudoObject.cpp
@@ -737,11 +737,11 @@ ExprResult ObjCPropertyOpBuilder::buildGet() {
assert(InstanceReceiver || RefExpr->isSuperReceiver());
msg = S.BuildInstanceMessageImplicit(InstanceReceiver, receiverType,
GenericLoc, Getter->getSelector(),
- Getter, None);
+ Getter, std::nullopt);
} else {
msg = S.BuildClassMessageImplicit(receiverType, RefExpr->isSuperReceiver(),
- GenericLoc, Getter->getSelector(),
- Getter, None);
+ GenericLoc, Getter->getSelector(), Getter,
+ std::nullopt);
}
return msg;
}
@@ -1200,7 +1200,7 @@ bool ObjCSubscriptOpBuilder::findAtIndexGetter() {
/*TInfo=*/nullptr,
SC_None,
nullptr);
- AtIndexGetter->setMethodParams(S.Context, Argument, None);
+ AtIndexGetter->setMethodParams(S.Context, Argument, std::nullopt);
}
if (!AtIndexGetter) {
@@ -1316,7 +1316,7 @@ bool ObjCSubscriptOpBuilder::findAtIndexSetter() {
SC_None,
nullptr);
Params.push_back(key);
- AtIndexSetter->setMethodParams(S.Context, Params, None);
+ AtIndexSetter->setMethodParams(S.Context, Params, std::nullopt);
}
if (!AtIndexSetter) {
diff --git a/clang/lib/Sema/SemaStmt.cpp b/clang/lib/Sema/SemaStmt.cpp
index 9d1f506ef5847..677abfb894d0b 100644
--- a/clang/lib/Sema/SemaStmt.cpp
+++ b/clang/lib/Sema/SemaStmt.cpp
@@ -382,7 +382,7 @@ void Sema::DiagnoseUnusedExprResult(const Stmt *S, unsigned DiagID) {
// type of the left operand could be used for SFINAE, so technically it is
// *used*.
if (DiagID != diag::warn_unused_comma_left_operand || !isSFINAEContext())
- DiagIfReachable(Loc, S ? llvm::makeArrayRef(S) : llvm::None,
+ DiagIfReachable(Loc, S ? llvm::makeArrayRef(S) : std::nullopt,
PDiag(DiagID) << R1 << R2);
}
diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp
index a6abf556d2d7c..798544b215134 100644
--- a/clang/lib/Sema/SemaTemplate.cpp
+++ b/clang/lib/Sema/SemaTemplate.cpp
@@ -1207,7 +1207,7 @@ static ExprResult formImmediatelyDeclaredConstraint(
ImmediatelyDeclaredConstraint.get(), BO_LAnd,
EllipsisLoc, /*RHS=*/nullptr,
/*RParenLoc=*/SourceLocation(),
- /*NumExpansions=*/None);
+ /*NumExpansions=*/std::nullopt);
}
/// Attach a type-constraint to a template parameter.
@@ -2378,8 +2378,9 @@ struct ConvertConstructorToDeductionGuideTransform {
/*Depth*/ 0, Depth1IndexAdjustment + TTP->getIndex(),
TTP->getIdentifier(), TTP->wasDeclaredWithTypename(),
TTP->isParameterPack(), TTP->hasTypeConstraint(),
- TTP->isExpandedParameterPack() ?
- llvm::Optional<unsigned>(TTP->getNumExpansionParameters()) : None);
+ TTP->isExpandedParameterPack()
+ ? llvm::Optional<unsigned>(TTP->getNumExpansionParameters())
+ : std::nullopt);
if (const auto *TC = TTP->getTypeConstraint())
SemaRef.SubstTypeConstraint(NewTTP, TC, Args,
/*EvaluateConstraint*/ true);
@@ -2632,7 +2633,7 @@ void Sema::DeclareImplicitDeductionGuides(TemplateDecl *Template,
// additional function template derived as above from a hypothetical
// constructor C().
if (!AddedAny)
- Transform.buildSimpleDeductionGuide(None);
+ Transform.buildSimpleDeductionGuide(std::nullopt);
// -- An additional function template derived as above from a hypothetical
// constructor C(C), called the copy deduction candidate.
@@ -3508,7 +3509,7 @@ TemplateParameterList *Sema::MatchTemplateParametersToScopeSpecifier(
// Fabricate an empty template parameter list for the invented header.
return TemplateParameterList::Create(Context, SourceLocation(),
- SourceLocation(), None,
+ SourceLocation(), std::nullopt,
SourceLocation(), nullptr);
}
@@ -5294,7 +5295,7 @@ static TypeSourceInfo *SubstDefaultTemplateArgument(
MultiLevelTemplateArgumentList TemplateArgLists(Template, SugaredConverted,
/*Final=*/true);
for (unsigned i = 0, e = Param->getDepth(); i != e; ++i)
- TemplateArgLists.addOuterTemplateArguments(None);
+ TemplateArgLists.addOuterTemplateArguments(std::nullopt);
bool ForLambdaCallOperator = false;
if (const auto *Rec = dyn_cast<CXXRecordDecl>(Template->getDeclContext()))
@@ -5346,7 +5347,7 @@ static ExprResult SubstDefaultTemplateArgument(
MultiLevelTemplateArgumentList TemplateArgLists(Template, SugaredConverted,
/*Final=*/true);
for (unsigned i = 0, e = Param->getDepth(); i != e; ++i)
- TemplateArgLists.addOuterTemplateArguments(None);
+ TemplateArgLists.addOuterTemplateArguments(std::nullopt);
Sema::ContextRAII SavedContext(SemaRef, Template->getDeclContext());
EnterExpressionEvaluationContext ConstantEvaluated(
@@ -5395,7 +5396,7 @@ static TemplateName SubstDefaultTemplateArgument(
MultiLevelTemplateArgumentList TemplateArgLists(Template, SugaredConverted,
/*Final=*/true);
for (unsigned i = 0, e = Param->getDepth(); i != e; ++i)
- TemplateArgLists.addOuterTemplateArguments(None);
+ TemplateArgLists.addOuterTemplateArguments(std::nullopt);
Sema::ContextRAII SavedContext(SemaRef, Template->getDeclContext());
// Substitute into the nested-name-specifier first,
diff --git a/clang/lib/Sema/SemaTemplateInstantiate.cpp b/clang/lib/Sema/SemaTemplateInstantiate.cpp
index 9e41dfbfdbe95..0c8ae8a927c28 100644
--- a/clang/lib/Sema/SemaTemplateInstantiate.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiate.cpp
@@ -122,7 +122,7 @@ Response
HandleDefaultTempArgIntoTempTempParam(const TemplateTemplateParmDecl *TTP,
MultiLevelTemplateArgumentList &Result) {
for (unsigned I = 0, N = TTP->getDepth() + 1; I != N; ++I)
- Result.addOuterTemplateArguments(None);
+ Result.addOuterTemplateArguments(std::nullopt);
return Response::Done();
}
@@ -523,8 +523,8 @@ Sema::InstantiatingTemplate::InstantiatingTemplate(
: InstantiatingTemplate(
SemaRef, CodeSynthesisContext::RequirementInstantiation,
PointOfInstantiation, InstantiationRange, /*Entity=*/nullptr,
- /*Template=*/nullptr, /*TemplateArgs=*/None, &DeductionInfo) {}
-
+ /*Template=*/nullptr, /*TemplateArgs=*/std::nullopt, &DeductionInfo) {
+}
Sema::InstantiatingTemplate::InstantiatingTemplate(
Sema &SemaRef, SourceLocation PointOfInstantiation,
@@ -533,7 +533,7 @@ Sema::InstantiatingTemplate::InstantiatingTemplate(
: InstantiatingTemplate(
SemaRef, CodeSynthesisContext::NestedRequirementConstraintsCheck,
PointOfInstantiation, InstantiationRange, /*Entity=*/nullptr,
- /*Template=*/nullptr, /*TemplateArgs=*/None) {}
+ /*Template=*/nullptr, /*TemplateArgs=*/std::nullopt) {}
Sema::InstantiatingTemplate::InstantiatingTemplate(
Sema &SemaRef, SourceLocation PointOfInstantiation, const RequiresExpr *RE,
@@ -541,7 +541,8 @@ Sema::InstantiatingTemplate::InstantiatingTemplate(
: InstantiatingTemplate(
SemaRef, CodeSynthesisContext::RequirementParameterInstantiation,
PointOfInstantiation, InstantiationRange, /*Entity=*/nullptr,
- /*Template=*/nullptr, /*TemplateArgs=*/None, &DeductionInfo) {}
+ /*Template=*/nullptr, /*TemplateArgs=*/std::nullopt, &DeductionInfo) {
+}
Sema::InstantiatingTemplate::InstantiatingTemplate(
Sema &SemaRef, SourceLocation PointOfInstantiation,
@@ -1031,7 +1032,7 @@ Optional<TemplateDeductionInfo *> Sema::isSFINAEContext() const {
case CodeSynthesisContext::ConstraintNormalization:
case CodeSynthesisContext::NestedRequirementConstraintsCheck:
// This is a template instantiation, so there is no SFINAE.
- return None;
+ return std::nullopt;
case CodeSynthesisContext::DefaultTemplateArgumentInstantiation:
case CodeSynthesisContext::PriorTemplateArgumentSubstitution:
@@ -1061,7 +1062,7 @@ Optional<TemplateDeductionInfo *> Sema::isSFINAEContext() const {
case CodeSynthesisContext::BuildingBuiltinDumpStructCall:
// This happens in a context unrelated to template instantiation, so
// there is no SFINAE.
- return None;
+ return std::nullopt;
case CodeSynthesisContext::ExceptionSpecEvaluation:
// FIXME: This should not be treated as a SFINAE context, because
@@ -1079,7 +1080,7 @@ Optional<TemplateDeductionInfo *> Sema::isSFINAEContext() const {
return Optional<TemplateDeductionInfo *>(nullptr);
}
- return None;
+ return std::nullopt;
}
//===----------------------------------------------------------------------===/
@@ -1135,7 +1136,7 @@ namespace {
Optional<unsigned> getPackIndex(TemplateArgument Pack) {
int Index = getSema().ArgumentPackSubstitutionIndex;
if (Index == -1)
- return None;
+ return std::nullopt;
return Pack.pack_size() - 1 - Index;
}
diff --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
index 636fabd71fc19..5aaa0c36ea671 100644
--- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -2787,8 +2787,9 @@ Decl *TemplateDeclInstantiator::VisitCXXConversionDecl(CXXConversionDecl *D) {
}
Decl *TemplateDeclInstantiator::VisitParmVarDecl(ParmVarDecl *D) {
- return SemaRef.SubstParmVarDecl(D, TemplateArgs, /*indexAdjustment*/ 0, None,
- /*ExpectParameterPack=*/ false);
+ return SemaRef.SubstParmVarDecl(D, TemplateArgs, /*indexAdjustment*/ 0,
+ std::nullopt,
+ /*ExpectParameterPack=*/false);
}
Decl *TemplateDeclInstantiator::VisitTemplateTypeParmDecl(
@@ -4043,7 +4044,7 @@ FunctionDecl *Sema::SubstSpaceshipAsEqualEqual(CXXRecordDecl *RD,
Decl *R;
if (auto *MD = dyn_cast<CXXMethodDecl>(Spaceship)) {
R = Instantiator.VisitCXXMethodDecl(
- MD, nullptr, None,
+ MD, nullptr, std::nullopt,
TemplateDeclInstantiator::RewriteKind::RewriteSpaceshipAsEqualEqual);
} else {
assert(Spaceship->getFriendObjectKind() &&
diff --git a/clang/lib/Sema/SemaTemplateVariadic.cpp b/clang/lib/Sema/SemaTemplateVariadic.cpp
index 49c178b35a8e8..3326b93c085c6 100644
--- a/clang/lib/Sema/SemaTemplateVariadic.cpp
+++ b/clang/lib/Sema/SemaTemplateVariadic.cpp
@@ -612,7 +612,8 @@ TypeResult Sema::ActOnPackExpansion(ParsedType Type,
if (!TSInfo)
return true;
- TypeSourceInfo *TSResult = CheckPackExpansion(TSInfo, EllipsisLoc, None);
+ TypeSourceInfo *TSResult =
+ CheckPackExpansion(TSInfo, EllipsisLoc, std::nullopt);
if (!TSResult)
return true;
@@ -659,7 +660,7 @@ QualType Sema::CheckPackExpansion(QualType Pattern, SourceRange PatternRange,
}
ExprResult Sema::ActOnPackExpansion(Expr *Pattern, SourceLocation EllipsisLoc) {
- return CheckPackExpansion(Pattern, EllipsisLoc, None);
+ return CheckPackExpansion(Pattern, EllipsisLoc, std::nullopt);
}
ExprResult Sema::CheckPackExpansion(Expr *Pattern, SourceLocation EllipsisLoc,
@@ -831,7 +832,7 @@ Optional<unsigned> Sema::getNumArgumentsInExpansion(QualType T,
for (auto [I, _] : Unexpanded) {
if (const auto *TTP = I.dyn_cast<const TemplateTypeParmType *>()) {
if (setResultPos({TTP->getDepth(), TTP->getIndex()}))
- return None;
+ return std::nullopt;
} else if (const auto *STP =
I.dyn_cast<const SubstTemplateTypeParmPackType *>()) {
setResultSz(STP->getNumArgs());
@@ -848,10 +849,10 @@ Optional<unsigned> Sema::getNumArgumentsInExpansion(QualType T,
if (!DAP)
// The pattern refers to an unexpanded pack. We're not ready to expand
// this pack yet.
- return None;
+ return std::nullopt;
setResultSz(DAP->size());
} else if (setResultPos(getDepthAndIndex(ND))) {
- return None;
+ return std::nullopt;
}
}
}
@@ -1132,7 +1133,7 @@ Optional<unsigned> Sema::getFullyPackExpandedSize(TemplateArgument Arg) {
if (auto *Subst = Arg.getAsType()->getAs<SubstTemplateTypeParmPackType>())
Pack = Subst->getArgumentPack();
else
- return None;
+ return std::nullopt;
break;
case TemplateArgument::Expression:
@@ -1142,10 +1143,10 @@ Optional<unsigned> Sema::getFullyPackExpandedSize(TemplateArgument Arg) {
else if (auto *Subst = dyn_cast<FunctionParmPackExpr>(Arg.getAsExpr())) {
for (VarDecl *PD : *Subst)
if (PD->isParameterPack())
- return None;
+ return std::nullopt;
return Subst->getNumExpansions();
} else
- return None;
+ return std::nullopt;
break;
case TemplateArgument::Template:
@@ -1153,7 +1154,7 @@ Optional<unsigned> Sema::getFullyPackExpandedSize(TemplateArgument Arg) {
Arg.getAsTemplate().getAsSubstTemplateTemplateParmPack())
Pack = Subst->getArgumentPack();
else
- return None;
+ return std::nullopt;
break;
case TemplateArgument::Declaration:
@@ -1162,7 +1163,7 @@ Optional<unsigned> Sema::getFullyPackExpandedSize(TemplateArgument Arg) {
case TemplateArgument::Integral:
case TemplateArgument::Pack:
case TemplateArgument::Null:
- return None;
+ return std::nullopt;
}
// Check that no argument in the pack is itself a pack expansion.
@@ -1170,7 +1171,7 @@ Optional<unsigned> Sema::getFullyPackExpandedSize(TemplateArgument Arg) {
// There's no point recursing in this case; we would have already
// expanded this pack expansion into the enclosing pack if we could.
if (Elem.isPackExpansion())
- return None;
+ return std::nullopt;
}
return Pack.pack_size();
}
@@ -1251,7 +1252,7 @@ ExprResult Sema::ActOnCXXFoldExpr(Scope *S, SourceLocation LParenLoc, Expr *LHS,
}
return BuildCXXFoldExpr(ULE, LParenLoc, LHS, Opc, EllipsisLoc, RHS, RParenLoc,
- None);
+ std::nullopt);
}
ExprResult Sema::BuildCXXFoldExpr(UnresolvedLookupExpr *Callee,
diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp
index 0a2b8c0f51080..100827ca1eb17 100644
--- a/clang/lib/Sema/SemaType.cpp
+++ b/clang/lib/Sema/SemaType.cpp
@@ -761,7 +761,7 @@ static void maybeSynthesizeBlockSignature(TypeProcessingState &state,
/*NumExceptions=*/0,
/*NoexceptExpr=*/nullptr,
/*ExceptionSpecTokens=*/nullptr,
- /*DeclsInPrototype=*/None, loc, loc, declarator));
+ /*DeclsInPrototype=*/std::nullopt, loc, loc, declarator));
// For consistency, make sure the state still has us as processing
// the decl spec.
@@ -5846,7 +5846,8 @@ static TypeSourceInfo *GetFullTypeForDeclarator(TypeProcessingState &state,
<< T << D.getSourceRange();
D.setEllipsisLoc(SourceLocation());
} else {
- T = Context.getPackExpansionType(T, None, /*ExpectPackInType=*/false);
+ T = Context.getPackExpansionType(T, std::nullopt,
+ /*ExpectPackInType=*/false);
}
break;
case DeclaratorContext::TemplateParam:
@@ -5859,7 +5860,7 @@ static TypeSourceInfo *GetFullTypeForDeclarator(TypeProcessingState &state,
// parameter packs in the type of the non-type template parameter, then
// it expands those parameter packs.
if (T->containsUnexpandedParameterPack())
- T = Context.getPackExpansionType(T, None);
+ T = Context.getPackExpansionType(T, std::nullopt);
else
S.Diag(D.getEllipsisLoc(),
LangOpts.CPlusPlus11
diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h
index 019ea3efd1a6b..4fa91a69661b4 100644
--- a/clang/lib/Sema/TreeTransform.h
+++ b/clang/lib/Sema/TreeTransform.h
@@ -3234,8 +3234,9 @@ class TreeTransform {
ExprResult RebuildCXXScalarValueInitExpr(TypeSourceInfo *TSInfo,
SourceLocation LParenLoc,
SourceLocation RParenLoc) {
- return getSema().BuildCXXTypeConstructExpr(
- TSInfo, LParenLoc, None, RParenLoc, /*ListInitialization=*/false);
+ return getSema().BuildCXXTypeConstructExpr(TSInfo, LParenLoc, std::nullopt,
+ RParenLoc,
+ /*ListInitialization=*/false);
}
/// Build a new C++ "new" expression.
@@ -4008,13 +4009,13 @@ ExprResult TreeTransform<Derived>::TransformInitializer(Expr *Init,
// Revert value-initialization back to empty parens.
if (CXXScalarValueInitExpr *VIE = dyn_cast<CXXScalarValueInitExpr>(Init)) {
SourceRange Parens = VIE->getSourceRange();
- return getDerived().RebuildParenListExpr(Parens.getBegin(), None,
+ return getDerived().RebuildParenListExpr(Parens.getBegin(), std::nullopt,
Parens.getEnd());
}
// FIXME: We shouldn't build ImplicitValueInitExprs for direct-initialization.
if (isa<ImplicitValueInitExpr>(Init))
- return getDerived().RebuildParenListExpr(SourceLocation(), None,
+ return getDerived().RebuildParenListExpr(SourceLocation(), std::nullopt,
SourceLocation());
// Revert initialization by constructor back to a parenthesized or braced list
@@ -5853,7 +5854,8 @@ bool TreeTransform<Derived>::TransformFunctionTypeParams(
"transformation.");
} else {
NewParm = getDerived().TransformFunctionTypeParam(
- OldParm, indexAdjustment, None, /*ExpectParameterPack=*/ false);
+ OldParm, indexAdjustment, std::nullopt,
+ /*ExpectParameterPack=*/false);
}
if (!NewParm)
@@ -5903,8 +5905,8 @@ bool TreeTransform<Derived>::TransformFunctionTypeParams(
return true;
if (NewType->containsUnexpandedParameterPack()) {
- NewType =
- getSema().getASTContext().getPackExpansionType(NewType, None);
+ NewType = getSema().getASTContext().getPackExpansionType(
+ NewType, std::nullopt);
if (NewType.isNull())
return true;
@@ -13179,7 +13181,7 @@ TreeTransform<Derived>::TransformLambdaExpr(LambdaExpr *E) {
if (Expand) {
for (unsigned I = 0; I != *NumExpansions; ++I) {
Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), I);
- SubstInitCapture(SourceLocation(), None);
+ SubstInitCapture(SourceLocation(), std::nullopt);
}
}
if (!Expand || RetainExpansion) {
@@ -13188,7 +13190,7 @@ TreeTransform<Derived>::TransformLambdaExpr(LambdaExpr *E) {
Result.EllipsisLoc = ExpansionTL.getEllipsisLoc();
}
} else {
- SubstInitCapture(SourceLocation(), None);
+ SubstInitCapture(SourceLocation(), std::nullopt);
}
}
@@ -13742,9 +13744,9 @@ TreeTransform<Derived>::TransformSizeOfPackExpr(SizeOfPackExpr *E) {
auto *Pack = E->getPack();
if (auto *TTPD = dyn_cast<TemplateTypeParmDecl>(Pack)) {
ArgStorage = getSema().Context.getPackExpansionType(
- getSema().Context.getTypeDeclType(TTPD), None);
+ getSema().Context.getTypeDeclType(TTPD), std::nullopt);
} else if (auto *TTPD = dyn_cast<TemplateTemplateParmDecl>(Pack)) {
- ArgStorage = TemplateArgument(TemplateName(TTPD), None);
+ ArgStorage = TemplateArgument(TemplateName(TTPD), std::nullopt);
} else {
auto *VD = cast<ValueDecl>(Pack);
ExprResult DRE = getSema().BuildDeclRefExpr(
@@ -13753,8 +13755,9 @@ TreeTransform<Derived>::TransformSizeOfPackExpr(SizeOfPackExpr *E) {
E->getPackLoc());
if (DRE.isInvalid())
return ExprError();
- ArgStorage = new (getSema().Context) PackExpansionExpr(
- getSema().Context.DependentTy, DRE.get(), E->getPackLoc(), None);
+ ArgStorage = new (getSema().Context)
+ PackExpansionExpr(getSema().Context.DependentTy, DRE.get(),
+ E->getPackLoc(), std::nullopt);
}
PackArgs = ArgStorage;
}
@@ -13766,9 +13769,9 @@ TreeTransform<Derived>::TransformSizeOfPackExpr(SizeOfPackExpr *E) {
getDerived().TransformDecl(E->getPackLoc(), E->getPack()));
if (!Pack)
return ExprError();
- return getDerived().RebuildSizeOfPackExpr(E->getOperatorLoc(), Pack,
- E->getPackLoc(),
- E->getRParenLoc(), None, None);
+ return getDerived().RebuildSizeOfPackExpr(
+ E->getOperatorLoc(), Pack, E->getPackLoc(), E->getRParenLoc(),
+ std::nullopt, std::nullopt);
}
// Try to compute the result without performing a partial substitution.
@@ -13802,7 +13805,7 @@ TreeTransform<Derived>::TransformSizeOfPackExpr(SizeOfPackExpr *E) {
if (!NumExpansions) {
// No: we must be in an alias template expansion, and we're going to need
// to actually expand the packs.
- Result = None;
+ Result = std::nullopt;
break;
}
@@ -13812,9 +13815,9 @@ TreeTransform<Derived>::TransformSizeOfPackExpr(SizeOfPackExpr *E) {
// Common case: we could determine the number of expansions without
// substituting.
if (Result)
- return getDerived().RebuildSizeOfPackExpr(E->getOperatorLoc(), E->getPack(),
- E->getPackLoc(),
- E->getRParenLoc(), *Result, None);
+ return getDerived().RebuildSizeOfPackExpr(
+ E->getOperatorLoc(), E->getPack(), E->getPackLoc(), E->getRParenLoc(),
+ *Result, std::nullopt);
TemplateArgumentListInfo TransformedPackArgs(E->getPackLoc(),
E->getPackLoc());
@@ -13839,13 +13842,13 @@ TreeTransform<Derived>::TransformSizeOfPackExpr(SizeOfPackExpr *E) {
}
if (PartialSubstitution)
- return getDerived().RebuildSizeOfPackExpr(E->getOperatorLoc(), E->getPack(),
- E->getPackLoc(),
- E->getRParenLoc(), None, Args);
+ return getDerived().RebuildSizeOfPackExpr(
+ E->getOperatorLoc(), E->getPack(), E->getPackLoc(), E->getRParenLoc(),
+ std::nullopt, Args);
return getDerived().RebuildSizeOfPackExpr(E->getOperatorLoc(), E->getPack(),
E->getPackLoc(), E->getRParenLoc(),
- Args.size(), None);
+ Args.size(), std::nullopt);
}
template<typename Derived>
@@ -14184,9 +14187,8 @@ TreeTransform<Derived>::TransformObjCDictionaryLiteral(
if (Value.get() != OrigElement.Value)
ArgChanged = true;
- ObjCDictionaryElement Element = {
- Key.get(), Value.get(), SourceLocation(), None
- };
+ ObjCDictionaryElement Element = {Key.get(), Value.get(), SourceLocation(),
+ std::nullopt};
Elements.push_back(Element);
}
More information about the cfe-commits
mailing list