From e03f427196ec67a8a5cfbdd658f9eabe9bce83ce Mon Sep 17 00:00:00 2001 From: Jay Foad Date: Thu, 19 Sep 2024 16:16:38 +0100 Subject: [LLVM] Use {} instead of std::nullopt to initialize empty ArrayRef (#109133) It is almost always simpler to use {} instead of std::nullopt to initialize an empty ArrayRef. This patch changes all occurrences I could find in LLVM itself. In future the ArrayRef(std::nullopt_t) constructor could be deprecated or removed. --- llvm/lib/CodeGen/AssignmentTrackingAnalysis.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'llvm/lib/CodeGen/AssignmentTrackingAnalysis.cpp') diff --git a/llvm/lib/CodeGen/AssignmentTrackingAnalysis.cpp b/llvm/lib/CodeGen/AssignmentTrackingAnalysis.cpp index 788cdfe3bb13..59257fd6aadd 100644 --- a/llvm/lib/CodeGen/AssignmentTrackingAnalysis.cpp +++ b/llvm/lib/CodeGen/AssignmentTrackingAnalysis.cpp @@ -966,7 +966,7 @@ public: auto &Ctx = Fn.getContext(); for (auto &FragMemLoc : FragMemLocs) { - DIExpression *Expr = DIExpression::get(Ctx, std::nullopt); + DIExpression *Expr = DIExpression::get(Ctx, {}); if (FragMemLoc.SizeInBits != *Aggregates[FragMemLoc.Var].first->getSizeInBits()) Expr = *DIExpression::createFragmentExpression( @@ -1398,7 +1398,7 @@ ArrayRef AssignmentTrackingLowering::getContainedFragments(VariableID Var) const { auto R = VarContains.find(Var); if (R == VarContains.end()) - return std::nullopt; + return {}; return R->second; } @@ -1638,7 +1638,7 @@ void AssignmentTrackingLowering::processUntaggedInstruction( // // DIExpression: Add fragment and offset. DebugVariable V = FnVarLocs->getVariable(Var); - DIExpression *DIE = DIExpression::get(I.getContext(), std::nullopt); + DIExpression *DIE = DIExpression::get(I.getContext(), {}); if (auto Frag = V.getFragment()) { auto R = DIExpression::createFragmentExpression(DIE, Frag->OffsetInBits, Frag->SizeInBits); @@ -2419,7 +2419,7 @@ bool AssignmentTrackingLowering::run(FunctionVarLocsBuilder *FnVarLocsBuilder) { // built appropriately rather than always using an empty DIExpression. // The assert below is a reminder. assert(Simple); - VarLoc.Expr = DIExpression::get(Fn.getContext(), std::nullopt); + VarLoc.Expr = DIExpression::get(Fn.getContext(), {}); DebugVariable Var = FnVarLocs->getVariable(VarLoc.VariableID); FnVarLocs->addSingleLocVar(Var, VarLoc.Expr, VarLoc.DL, VarLoc.Values); InsertedAnyIntrinsics = true; -- cgit v1.2.3