[clang] [clang] Use {} instead of std::nullopt to initialize empty ArrayRef (PR #109399)
via cfe-commits
cfe-commits at lists.llvm.org
Fri Sep 20 03:15:02 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-coroutines
@llvm/pr-subscribers-clang-static-analyzer-1
@llvm/pr-subscribers-backend-webassembly
Author: Jay Foad (jayfoad)
<details>
<summary>Changes</summary>
Follow up to #<!-- -->109133.
---
Patch is 133.83 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/109399.diff
115 Files Affected:
- (modified) clang/include/clang/AST/CommentSema.h (+1-1)
- (modified) clang/include/clang/AST/DeclFriend.h (+1-1)
- (modified) clang/include/clang/AST/DeclObjC.h (+1-1)
- (modified) clang/include/clang/AST/DeclOpenMP.h (+2-2)
- (modified) clang/include/clang/AST/ExprCXX.h (+1-1)
- (modified) clang/include/clang/AST/OpenMPClause.h (+3-3)
- (modified) clang/include/clang/AST/StmtOpenMP.h (+2-2)
- (modified) clang/include/clang/AST/TemplateBase.h (+1-1)
- (modified) clang/include/clang/ASTMatchers/ASTMatchersInternal.h (+6-6)
- (modified) clang/include/clang/Analysis/Analyses/ThreadSafetyTIL.h (+2-2)
- (modified) clang/include/clang/Analysis/AnyCall.h (+2-2)
- (modified) clang/include/clang/Basic/TargetInfo.h (+1-1)
- (modified) clang/include/clang/Driver/Job.h (+2-2)
- (modified) clang/include/clang/Frontend/ASTUnit.h (+2-2)
- (modified) clang/include/clang/Lex/Preprocessor.h (+3-3)
- (modified) clang/include/clang/Sema/CodeCompleteConsumer.h (+2-2)
- (modified) clang/include/clang/Sema/Overload.h (+1-1)
- (modified) clang/include/clang/Sema/Sema.h (+7-7)
- (modified) clang/include/clang/Sema/SemaObjC.h (+2-2)
- (modified) clang/include/clang/Sema/SemaOpenACC.h (+1-1)
- (modified) clang/include/clang/Sema/SemaOpenMP.h (+6-6)
- (modified) clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h (+4-4)
- (modified) clang/lib/ARCMigrate/Internals.h (+1-1)
- (modified) clang/lib/AST/ASTContext.cpp (+2-2)
- (modified) clang/lib/AST/Comment.cpp (+1-1)
- (modified) clang/lib/AST/CommentParser.cpp (+2-2)
- (modified) clang/lib/AST/Decl.cpp (+2-2)
- (modified) clang/lib/AST/DeclCXX.cpp (+2-2)
- (modified) clang/lib/AST/DeclObjC.cpp (+2-2)
- (modified) clang/lib/AST/DeclOpenMP.cpp (+1-1)
- (modified) clang/lib/AST/DeclTemplate.cpp (+2-2)
- (modified) clang/lib/AST/Expr.cpp (+1-1)
- (modified) clang/lib/AST/MicrosoftMangle.cpp (+1-1)
- (modified) clang/lib/AST/StmtOpenMP.cpp (+3-3)
- (modified) clang/lib/Analysis/BodyFarm.cpp (+2-2)
- (modified) clang/lib/Analysis/UnsafeBufferUsage.cpp (+1-1)
- (modified) clang/lib/Basic/Targets/AMDGPU.h (+1-1)
- (modified) clang/lib/Basic/Targets/ARC.h (+2-2)
- (modified) clang/lib/Basic/Targets/AVR.h (+2-2)
- (modified) clang/lib/Basic/Targets/BPF.h (+2-2)
- (modified) clang/lib/Basic/Targets/DirectX.h (+3-3)
- (modified) clang/lib/Basic/Targets/Lanai.h (+1-1)
- (modified) clang/lib/Basic/Targets/M68k.cpp (+1-1)
- (modified) clang/lib/Basic/Targets/MSP430.h (+1-1)
- (modified) clang/lib/Basic/Targets/NVPTX.h (+1-1)
- (modified) clang/lib/Basic/Targets/PNaCl.cpp (+2-2)
- (modified) clang/lib/Basic/Targets/PNaCl.h (+1-1)
- (modified) clang/lib/Basic/Targets/SPIR.h (+3-3)
- (modified) clang/lib/Basic/Targets/Sparc.h (+1-1)
- (modified) clang/lib/Basic/Targets/SystemZ.h (+1-1)
- (modified) clang/lib/Basic/Targets/TCE.h (+3-3)
- (modified) clang/lib/Basic/Targets/WebAssembly.h (+2-2)
- (modified) clang/lib/Basic/Targets/X86.h (+1-1)
- (modified) clang/lib/Basic/Targets/XCore.h (+1-1)
- (modified) clang/lib/CodeGen/CGBuiltin.cpp (+4-4)
- (modified) clang/lib/CodeGen/CGCall.cpp (+6-6)
- (modified) clang/lib/CodeGen/CGCleanup.cpp (+1-1)
- (modified) clang/lib/CodeGen/CGDebugInfo.cpp (+2-2)
- (modified) clang/lib/CodeGen/CGExpr.cpp (+3-3)
- (modified) clang/lib/CodeGen/CGLoopInfo.cpp (+1-1)
- (modified) clang/lib/CodeGen/CGObjC.cpp (+5-5)
- (modified) clang/lib/CodeGen/CGObjCGNU.cpp (+1-1)
- (modified) clang/lib/CodeGen/CGObjCMac.cpp (+2-2)
- (modified) clang/lib/CodeGen/CGOpenMPRuntime.cpp (+13-13)
- (modified) clang/lib/CodeGen/CGOpenMPRuntime.h (+2-2)
- (modified) clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp (+4-4)
- (modified) clang/lib/CodeGen/CGOpenMPRuntimeGPU.h (+1-1)
- (modified) clang/lib/CodeGen/CGStmtOpenMP.cpp (+8-8)
- (modified) clang/lib/CodeGen/CodeGenFunction.cpp (+1-1)
- (modified) clang/lib/CodeGen/CodeGenFunction.h (+5-5)
- (modified) clang/lib/CodeGen/CodeGenModule.h (+2-2)
- (modified) clang/lib/CodeGen/CoverageMappingGen.cpp (+1-1)
- (modified) clang/lib/CodeGen/ItaniumCXXABI.cpp (+1-1)
- (modified) clang/lib/Frontend/DiagnosticRenderer.cpp (+2-2)
- (modified) clang/lib/Index/IndexingContext.h (+4-4)
- (modified) clang/lib/Lex/ModuleMap.cpp (+2-2)
- (modified) clang/lib/Lex/PPMacroExpansion.cpp (+1-1)
- (modified) clang/lib/Parse/ParseDecl.cpp (+2-2)
- (modified) clang/lib/Parse/ParseDeclCXX.cpp (+1-1)
- (modified) clang/lib/Parse/ParseExpr.cpp (+1-1)
- (modified) clang/lib/Parse/ParseExprCXX.cpp (+1-1)
- (modified) clang/lib/Parse/ParseInit.cpp (+1-1)
- (modified) clang/lib/Parse/ParseObjc.cpp (+3-3)
- (modified) clang/lib/Parse/ParseOpenMP.cpp (+1-1)
- (modified) clang/lib/Parse/ParseStmt.cpp (+2-2)
- (modified) clang/lib/Sema/Sema.cpp (+2-2)
- (modified) clang/lib/Sema/SemaChecking.cpp (+2-2)
- (modified) clang/lib/Sema/SemaCodeComplete.cpp (+5-5)
- (modified) clang/lib/Sema/SemaCoroutine.cpp (+7-7)
- (modified) clang/lib/Sema/SemaDecl.cpp (+3-3)
- (modified) clang/lib/Sema/SemaDeclCXX.cpp (+13-13)
- (modified) clang/lib/Sema/SemaDeclObjC.cpp (+2-2)
- (modified) clang/lib/Sema/SemaExpr.cpp (+9-9)
- (modified) clang/lib/Sema/SemaExprObjC.cpp (+6-6)
- (modified) clang/lib/Sema/SemaInit.cpp (+7-7)
- (modified) clang/lib/Sema/SemaLambda.cpp (+3-3)
- (modified) clang/lib/Sema/SemaLookup.cpp (+1-1)
- (modified) clang/lib/Sema/SemaObjCProperty.cpp (+1-1)
- (modified) clang/lib/Sema/SemaOpenACC.cpp (+1-1)
- (modified) clang/lib/Sema/SemaOpenMP.cpp (+2-2)
- (modified) clang/lib/Sema/SemaOverload.cpp (+8-8)
- (modified) clang/lib/Sema/SemaPseudoObject.cpp (+4-4)
- (modified) clang/lib/Sema/SemaStmt.cpp (+1-1)
- (modified) clang/lib/Sema/SemaTemplate.cpp (+1-1)
- (modified) clang/lib/Sema/SemaTemplateDeductionGuide.cpp (+1-1)
- (modified) clang/lib/Sema/SemaTemplateInstantiate.cpp (+3-3)
- (modified) clang/lib/Sema/SemaType.cpp (+1-1)
- (modified) clang/lib/Sema/TreeTransform.h (+7-7)
- (modified) clang/lib/Serialization/ASTWriterDecl.cpp (+1-1)
- (modified) clang/lib/StaticAnalyzer/Core/CallEvent.cpp (+3-3)
- (modified) clang/lib/StaticAnalyzer/Core/MemRegion.cpp (+1-1)
- (modified) clang/tools/libclang/CIndex.cpp (+1-1)
- (modified) clang/unittests/Analysis/FlowSensitive/UncheckedOptionalAccessModelTest.cpp (+1-1)
- (modified) clang/unittests/Frontend/ASTUnitTest.cpp (+2-2)
- (modified) clang/utils/TableGen/NeonEmitter.cpp (+1-1)
``````````diff
diff --git a/clang/include/clang/AST/CommentSema.h b/clang/include/clang/AST/CommentSema.h
index 03f13283ac0d97..916d7945329c5b 100644
--- a/clang/include/clang/AST/CommentSema.h
+++ b/clang/include/clang/AST/CommentSema.h
@@ -80,7 +80,7 @@ class Sema {
ArrayRef<T> copyArray(ArrayRef<T> Source) {
if (!Source.empty())
return Source.copy(Allocator);
- return std::nullopt;
+ return {};
}
ParagraphComment *actOnParagraphComment(
diff --git a/clang/include/clang/AST/DeclFriend.h b/clang/include/clang/AST/DeclFriend.h
index 095f14a81fd574..1578580c89cd87 100644
--- a/clang/include/clang/AST/DeclFriend.h
+++ b/clang/include/clang/AST/DeclFriend.h
@@ -115,7 +115,7 @@ class FriendDecl final
static FriendDecl *
Create(ASTContext &C, DeclContext *DC, SourceLocation L, FriendUnion Friend_,
SourceLocation FriendL, SourceLocation EllipsisLoc = {},
- ArrayRef<TemplateParameterList *> FriendTypeTPLists = std::nullopt);
+ ArrayRef<TemplateParameterList *> FriendTypeTPLists = {});
static FriendDecl *CreateDeserialized(ASTContext &C, GlobalDeclID ID,
unsigned FriendTypeNumTPLists);
diff --git a/clang/include/clang/AST/DeclObjC.h b/clang/include/clang/AST/DeclObjC.h
index 1cda70530d7d83..4663603f797545 100644
--- a/clang/include/clang/AST/DeclObjC.h
+++ b/clang/include/clang/AST/DeclObjC.h
@@ -386,7 +386,7 @@ class ObjCMethodDecl : public NamedDecl, public DeclContext {
/// If the method is implicit (not coming from source) \p SelLocs is
/// ignored.
void setMethodParams(ASTContext &C, ArrayRef<ParmVarDecl *> Params,
- ArrayRef<SourceLocation> SelLocs = std::nullopt);
+ ArrayRef<SourceLocation> SelLocs = {});
// Iterator access to parameter types.
struct GetTypeFn {
diff --git a/clang/include/clang/AST/DeclOpenMP.h b/clang/include/clang/AST/DeclOpenMP.h
index 868662208efa1f..cf383889c0ad90 100644
--- a/clang/include/clang/AST/DeclOpenMP.h
+++ b/clang/include/clang/AST/DeclOpenMP.h
@@ -34,7 +34,7 @@ template <typename U> class OMPDeclarativeDirective : public U {
/// Get the clauses storage.
MutableArrayRef<OMPClause *> getClauses() {
if (!Data)
- return std::nullopt;
+ return {};
return Data->getClauses();
}
@@ -90,7 +90,7 @@ template <typename U> class OMPDeclarativeDirective : public U {
ArrayRef<OMPClause *> clauses() const {
if (!Data)
- return std::nullopt;
+ return {};
return Data->getClauses();
}
};
diff --git a/clang/include/clang/AST/ExprCXX.h b/clang/include/clang/AST/ExprCXX.h
index 975bcdac5069b9..ff0dc474788d00 100644
--- a/clang/include/clang/AST/ExprCXX.h
+++ b/clang/include/clang/AST/ExprCXX.h
@@ -4310,7 +4310,7 @@ class SizeOfPackExpr final
Create(ASTContext &Context, SourceLocation OperatorLoc, NamedDecl *Pack,
SourceLocation PackLoc, SourceLocation RParenLoc,
std::optional<unsigned> Length = std::nullopt,
- ArrayRef<TemplateArgument> PartialArgs = std::nullopt);
+ ArrayRef<TemplateArgument> PartialArgs = {});
static SizeOfPackExpr *CreateDeserialized(ASTContext &Context,
unsigned NumPartialArgs);
diff --git a/clang/include/clang/AST/OpenMPClause.h b/clang/include/clang/AST/OpenMPClause.h
index 3a1d6852d2a708..53b0a13fb71933 100644
--- a/clang/include/clang/AST/OpenMPClause.h
+++ b/clang/include/clang/AST/OpenMPClause.h
@@ -6009,14 +6009,14 @@ class OMPMappableExprListClause : public OMPVarListClause<T>,
return const_component_lists_iterator(
getUniqueDeclsRef(), getDeclNumListsRef(), getComponentListSizesRef(),
getComponentsRef(), SupportsMapper,
- SupportsMapper ? getUDMapperRefs() : std::nullopt);
+ SupportsMapper ? getUDMapperRefs() : ArrayRef<Expr *>());
}
const_component_lists_iterator component_lists_end() const {
return const_component_lists_iterator(
ArrayRef<ValueDecl *>(), ArrayRef<unsigned>(), ArrayRef<unsigned>(),
MappableExprComponentListRef(getComponentsRef().end(),
getComponentsRef().end()),
- SupportsMapper, std::nullopt);
+ SupportsMapper, {});
}
const_component_lists_range component_lists() const {
return {component_lists_begin(), component_lists_end()};
@@ -6029,7 +6029,7 @@ class OMPMappableExprListClause : public OMPVarListClause<T>,
return const_component_lists_iterator(
VD, getUniqueDeclsRef(), getDeclNumListsRef(),
getComponentListSizesRef(), getComponentsRef(), SupportsMapper,
- SupportsMapper ? getUDMapperRefs() : std::nullopt);
+ SupportsMapper ? getUDMapperRefs() : ArrayRef<Expr *>());
}
const_component_lists_iterator decl_component_lists_end() const {
return component_lists_end();
diff --git a/clang/include/clang/AST/StmtOpenMP.h b/clang/include/clang/AST/StmtOpenMP.h
index 930670d17f2d1c..9ec49b8683dc8e 100644
--- a/clang/include/clang/AST/StmtOpenMP.h
+++ b/clang/include/clang/AST/StmtOpenMP.h
@@ -277,7 +277,7 @@ class OMPExecutableDirective : public Stmt {
/// Get the clauses storage.
MutableArrayRef<OMPClause *> getClauses() {
if (!Data)
- return std::nullopt;
+ return {};
return Data->getClauses();
}
@@ -572,7 +572,7 @@ class OMPExecutableDirective : public Stmt {
ArrayRef<OMPClause *> clauses() const {
if (!Data)
- return std::nullopt;
+ return {};
return Data->getClauses();
}
diff --git a/clang/include/clang/AST/TemplateBase.h b/clang/include/clang/AST/TemplateBase.h
index 0eaa4b0eedb35f..a8f0263d5505ac 100644
--- a/clang/include/clang/AST/TemplateBase.h
+++ b/clang/include/clang/AST/TemplateBase.h
@@ -283,7 +283,7 @@ class TemplateArgument {
}
static TemplateArgument getEmptyPack() {
- return TemplateArgument(std::nullopt);
+ return TemplateArgument(ArrayRef<TemplateArgument>());
}
/// Create a new template argument pack by copying the given set of
diff --git a/clang/include/clang/ASTMatchers/ASTMatchersInternal.h b/clang/include/clang/ASTMatchers/ASTMatchersInternal.h
index c1cc63fdb7433f..ab8b146453e761 100644
--- a/clang/include/clang/ASTMatchers/ASTMatchersInternal.h
+++ b/clang/include/clang/ASTMatchers/ASTMatchersInternal.h
@@ -121,7 +121,7 @@ template <typename T> struct TypeListContainsSuperOf<EmptyTypeList, T> {
template <typename ResultT, typename ArgT,
ResultT (*Func)(ArrayRef<const ArgT *>)>
struct VariadicFunction {
- ResultT operator()() const { return Func(std::nullopt); }
+ ResultT operator()() const { return Func({}); }
template <typename... ArgsT>
ResultT operator()(const ArgT &Arg1, const ArgsT &... Args) const {
@@ -1949,35 +1949,35 @@ inline ArrayRef<TemplateArgument>
getTemplateSpecializationArgs(const FunctionDecl &FD) {
if (const auto* TemplateArgs = FD.getTemplateSpecializationArgs())
return TemplateArgs->asArray();
- return std::nullopt;
+ return {};
}
inline ArrayRef<TemplateArgumentLoc>
getTemplateArgsWritten(const ClassTemplateSpecializationDecl &D) {
if (const ASTTemplateArgumentListInfo *Args = D.getTemplateArgsAsWritten())
return Args->arguments();
- return std::nullopt;
+ return {};
}
inline ArrayRef<TemplateArgumentLoc>
getTemplateArgsWritten(const VarTemplateSpecializationDecl &D) {
if (const ASTTemplateArgumentListInfo *Args = D.getTemplateArgsAsWritten())
return Args->arguments();
- return std::nullopt;
+ return {};
}
inline ArrayRef<TemplateArgumentLoc>
getTemplateArgsWritten(const FunctionDecl &FD) {
if (const auto *Args = FD.getTemplateSpecializationArgsAsWritten())
return Args->arguments();
- return std::nullopt;
+ return {};
}
inline ArrayRef<TemplateArgumentLoc>
getTemplateArgsWritten(const DeclRefExpr &DRE) {
if (const auto *Args = DRE.getTemplateArgs())
return {Args, DRE.getNumTemplateArgs()};
- return std::nullopt;
+ return {};
}
inline SmallVector<TemplateArgumentLoc>
diff --git a/clang/include/clang/Analysis/Analyses/ThreadSafetyTIL.h b/clang/include/clang/Analysis/Analyses/ThreadSafetyTIL.h
index 65dd66ee093fe4..2f202607bd3fa9 100644
--- a/clang/include/clang/Analysis/Analyses/ThreadSafetyTIL.h
+++ b/clang/include/clang/Analysis/Analyses/ThreadSafetyTIL.h
@@ -1470,7 +1470,7 @@ class Return : public Terminator {
static bool classof(const SExpr *E) { return E->opcode() == COP_Return; }
/// Return an empty list.
- ArrayRef<BasicBlock *> successors() { return std::nullopt; }
+ ArrayRef<BasicBlock *> successors() { return {}; }
SExpr *returnValue() { return Retval; }
const SExpr *returnValue() const { return Retval; }
@@ -1496,7 +1496,7 @@ inline ArrayRef<BasicBlock*> Terminator::successors() {
case COP_Branch: return cast<Branch>(this)->successors();
case COP_Return: return cast<Return>(this)->successors();
default:
- return std::nullopt;
+ return {};
}
}
diff --git a/clang/include/clang/Analysis/AnyCall.h b/clang/include/clang/Analysis/AnyCall.h
index 48abce062d1330..3e95366c985956 100644
--- a/clang/include/clang/Analysis/AnyCall.h
+++ b/clang/include/clang/Analysis/AnyCall.h
@@ -143,7 +143,7 @@ class AnyCall {
/// \returns formal parameters for direct calls (including virtual calls)
ArrayRef<ParmVarDecl *> parameters() const {
if (!D)
- return std::nullopt;
+ return {};
if (const auto *FD = dyn_cast<FunctionDecl>(D)) {
return FD->parameters();
@@ -152,7 +152,7 @@ class AnyCall {
} else if (const auto *BD = dyn_cast<BlockDecl>(D)) {
return BD->parameters();
} else {
- return std::nullopt;
+ return {};
}
}
diff --git a/clang/include/clang/Basic/TargetInfo.h b/clang/include/clang/Basic/TargetInfo.h
index f31d88a354ea28..0f0d7fce478eb0 100644
--- a/clang/include/clang/Basic/TargetInfo.h
+++ b/clang/include/clang/Basic/TargetInfo.h
@@ -1853,7 +1853,7 @@ class TargetInfo : public TransferrableTargetInfo,
virtual ArrayRef<const char *> getGCCRegNames() const = 0;
virtual ArrayRef<GCCRegAlias> getGCCRegAliases() const = 0;
virtual ArrayRef<AddlRegName> getGCCAddlRegNames() const {
- return std::nullopt;
+ return {};
}
private:
diff --git a/clang/include/clang/Driver/Job.h b/clang/include/clang/Driver/Job.h
index df9449463c53bd..de7e1771834d49 100644
--- a/clang/include/clang/Driver/Job.h
+++ b/clang/include/clang/Driver/Job.h
@@ -172,7 +172,7 @@ class Command {
Command(const Action &Source, const Tool &Creator,
ResponseFileSupport ResponseSupport, const char *Executable,
const llvm::opt::ArgStringList &Arguments, ArrayRef<InputInfo> Inputs,
- ArrayRef<InputInfo> Outputs = std::nullopt,
+ ArrayRef<InputInfo> Outputs = {},
const char *PrependArg = nullptr);
// FIXME: This really shouldn't be copyable, but is currently copied in some
// error handling in Driver::generateCompilationDiagnostics.
@@ -246,7 +246,7 @@ class CC1Command : public Command {
ResponseFileSupport ResponseSupport, const char *Executable,
const llvm::opt::ArgStringList &Arguments,
ArrayRef<InputInfo> Inputs,
- ArrayRef<InputInfo> Outputs = std::nullopt,
+ ArrayRef<InputInfo> Outputs = {},
const char *PrependArg = nullptr);
void Print(llvm::raw_ostream &OS, const char *Terminator, bool Quote,
diff --git a/clang/include/clang/Frontend/ASTUnit.h b/clang/include/clang/Frontend/ASTUnit.h
index 080844893c13c9..becab837912236 100644
--- a/clang/include/clang/Frontend/ASTUnit.h
+++ b/clang/include/clang/Frontend/ASTUnit.h
@@ -836,7 +836,7 @@ class ASTUnit {
bool StorePreamblesInMemory = false,
StringRef PreambleStoragePath = StringRef(), bool OnlyLocalDecls = false,
CaptureDiagsKind CaptureDiagnostics = CaptureDiagsKind::None,
- ArrayRef<RemappedFile> RemappedFiles = std::nullopt,
+ ArrayRef<RemappedFile> RemappedFiles = {},
bool RemappedFilesKeepOriginalName = true,
unsigned PrecompilePreambleAfterNParses = 0,
TranslationUnitKind TUKind = TU_Complete,
@@ -864,7 +864,7 @@ class ASTUnit {
/// \returns True if a failure occurred that causes the ASTUnit not to
/// contain any translation-unit information, false otherwise.
bool Reparse(std::shared_ptr<PCHContainerOperations> PCHContainerOps,
- ArrayRef<RemappedFile> RemappedFiles = std::nullopt,
+ ArrayRef<RemappedFile> RemappedFiles = {},
IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS = nullptr);
/// Free data that will be re-generated on the next parse.
diff --git a/clang/include/clang/Lex/Preprocessor.h b/clang/include/clang/Lex/Preprocessor.h
index 4643b0213815f8..08e9bbd6209ef9 100644
--- a/clang/include/clang/Lex/Preprocessor.h
+++ b/clang/include/clang/Lex/Preprocessor.h
@@ -910,7 +910,7 @@ class Preprocessor {
getActiveModuleMacros(Preprocessor &PP, const IdentifierInfo *II) const {
if (auto *Info = getModuleInfo(PP, II))
return Info->ActiveModuleMacros;
- return std::nullopt;
+ return {};
}
MacroDirective::DefInfo findDirectiveAtLoc(SourceLocation Loc,
@@ -934,7 +934,7 @@ class Preprocessor {
ArrayRef<ModuleMacro*> getOverriddenMacros() const {
if (auto *Info = State.dyn_cast<ModuleMacroInfo*>())
return Info->OverriddenMacros;
- return std::nullopt;
+ return {};
}
void setOverriddenMacros(Preprocessor &PP,
@@ -1443,7 +1443,7 @@ class Preprocessor {
auto I = LeafModuleMacros.find(II);
if (I != LeafModuleMacros.end())
return I->second;
- return std::nullopt;
+ return {};
}
/// Get the list of submodules that we're currently building.
diff --git a/clang/include/clang/Sema/CodeCompleteConsumer.h b/clang/include/clang/Sema/CodeCompleteConsumer.h
index 0924dc27af82b5..aeca8cbd71f9a1 100644
--- a/clang/include/clang/Sema/CodeCompleteConsumer.h
+++ b/clang/include/clang/Sema/CodeCompleteConsumer.h
@@ -375,12 +375,12 @@ class CodeCompletionContext {
public:
/// Construct a new code-completion context of the given kind.
CodeCompletionContext(Kind CCKind)
- : CCKind(CCKind), IsUsingDeclaration(false), SelIdents(std::nullopt) {}
+ : CCKind(CCKind), IsUsingDeclaration(false), SelIdents() {}
/// Construct a new code-completion context of the given kind.
CodeCompletionContext(
Kind CCKind, QualType T,
- ArrayRef<const IdentifierInfo *> SelIdents = std::nullopt)
+ ArrayRef<const IdentifierInfo *> SelIdents = {})
: CCKind(CCKind), IsUsingDeclaration(false), SelIdents(SelIdents) {
if (CCKind == CCC_DotMemberAccess || CCKind == CCC_ArrowMemberAccess ||
CCKind == CCC_ObjCPropertyAccess || CCKind == CCC_ObjCClassMessage ||
diff --git a/clang/include/clang/Sema/Overload.h b/clang/include/clang/Sema/Overload.h
index c716a25bb673b8..cfc0881b383b9d 100644
--- a/clang/include/clang/Sema/Overload.h
+++ b/clang/include/clang/Sema/Overload.h
@@ -1208,7 +1208,7 @@ class Sema;
/// to the overload set.
OverloadCandidate &
addCandidate(unsigned NumConversions = 0,
- ConversionSequenceList Conversions = std::nullopt) {
+ ConversionSequenceList Conversions = {}) {
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 e1c3a99cfa167e..bc06bd9baf8d8e 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -3549,7 +3549,7 @@ class Sema final : public SemaBase {
NamedDecl *ActOnVariableDeclarator(
Scope *S, Declarator &D, DeclContext *DC, TypeSourceInfo *TInfo,
LookupResult &Previous, MultiTemplateParamsArg TemplateParamLists,
- bool &AddToScope, ArrayRef<BindingDecl *> Bindings = std::nullopt);
+ bool &AddToScope, ArrayRef<BindingDecl *> Bindings = {});
/// Perform semantic checking on a newly-created variable
/// declaration.
@@ -5393,7 +5393,7 @@ class Sema final : public SemaBase {
bool SetCtorInitializers(
CXXConstructorDecl *Constructor, bool AnyErrors,
- ArrayRef<CXXCtorInitializer *> Initializers = std::nullopt);
+ ArrayRef<CXXCtorInitializer *> Initializers = {});
/// MarkBaseAndMemberDestructorsReferenced - Given a record decl,
/// mark all the non-trivial destructors of its members and bases as
@@ -6691,7 +6691,7 @@ class Sema final : public SemaBase {
/// \param StopAt Subexpressions that we shouldn't recurse into.
void MarkDeclarationsReferencedInExpr(
Expr *E, bool SkipLocalVariables = false,
- ArrayRef<const Expr *> StopAt = std::nullopt);
+ ArrayRef<const Expr *> StopAt = {});
/// Try to convert an expression \p E to type \p Ty. Returns the result of the
/// conversion.
@@ -6762,7 +6762,7 @@ class Sema final : public SemaBase {
DiagnoseEmptyLookup(Scope *S, CXXScopeSpec &SS, LookupResult &R,
CorrectionCandidateCallback &CCC,
TemplateArgumentListInfo *ExplicitTemplateArgs = nullptr,
- ArrayRef<Expr *> Args = std::nullopt,
+ ArrayRef<Expr *> Args = {},
DeclContext *LookupCtx = nullptr,
TypoExpr **Out = nullptr);
@@ -10195,7 +10195,7 @@ class Sema final : public SemaBase {
bool PartialOverloading = false, bool AllowExplicit = true,
bool AllowExplicitConversion = false,
ADLCallKind IsADLCandidate = ADLCallKind::NotADL,
- ConversionSequenceList EarlyConversions = std::nullopt,
+ ConversionSequenceList EarlyConversions = {},
OverloadCandidateParamOrder PO = {},
bool AggregateCandidateDeduction = false);
@@ -10231,7 +10231,7 @@ class Sema final : public SemaBase {
ArrayRef<Expr *> Args, OverloadCandidateSet &CandidateSet,
bool SuppressUserConversions = false,
bool PartialOverloading = false,
- ConversionSequenceList EarlyConversions = std::nullopt,
+ ConversionSequenceList EarlyConversions = {},
OverloadCandidateParamOrder PO = {});
/// Add a C++ member function template as a candidate to the candidate
@@ -13035,7 +13035,7 @@ class Sema final : public SemaBase {
Sema &SemaRef, CodeSynthesisContext::SynthesisKind Kind,
SourceLocation PointOfInstantiation, SourceRange InstantiationRange,
Decl *Entity, NamedDecl *Template = nullptr,
- ArrayRef<TemplateArgument> TemplateArgs = std::nullopt,
+ ArrayRef<TemplateArgument> TemplateArgs = {},
sema::TemplateDeductionInfo *DeductionInfo = nullptr);
InstantiatingTemplate(const InstantiatingTemplate &) = delete;
diff --git a/clang/include/clang/Sema/SemaObjC.h b/clang/include/clang/Sema/SemaObjC.h
index 213c37b5091fe0..aa8a22797b38a3 100644
--- a/clang/include/clang/Sema/SemaObjC.h
+++ b/clang/include/clang/Sema/SemaObjC.h
@@ -350,8 +350,8 @@ class SemaObjC : public SemaBase {
ObjCInterfaceDecl *ID);
Decl *ActOnAtEnd(Scope *S, SourceRange AtEnd,
- ArrayRef<Decl *> allMethods = std::nullopt,
- ArrayRef<DeclGroupPtrTy> allTUVars = std::nullopt);
+ ArrayRef<Decl *> allMethods = {},
+ ArrayRef<DeclGroupPtrTy> allTUVars = {});
struct ObjCArgInfo {
IdentifierInfo *Name;
diff --git a/clang/include/clang/Sema/SemaOpenACC.h b/clang/include/clang/Sema/SemaOpenACC.h
index 0ca76842e5f902..83f6954db9a7de 100644
--- a/clang/include/clang/Sema/SemaOpenACC.h
+++ b/clang/include/clang/Sema/SemaOpenACC.h
@@ -172,7 +172,7 @@ class SemaOpenACC : public SemaBase {
"Parsed clause kind does not have a queue id expr list");
if (std::holds_alternative<std::monostate>(Details))
- return ArrayRef<Expr *>{std::nullopt};
+ return ArrayRef<Expr *>();
return std::get<WaitDetails>(Details).QueueIdExprs;
}
diff --git a/clang/include/clang/Sema/SemaOpenMP.h b/clang/include/clang/Sema/SemaOpenMP.h
index 53191e7bb4272b..b74bc76040e6d2 100644
--- a/clang/include/clang/Sema/SemaOpenMP.h
+++ b/clang/include/c...
[truncated]
``````````
</details>
https://github.com/llvm/llvm-project/pull/109399
More information about the cfe-commits
mailing list