diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp index 624cdeada4eb9..ccb91c682df55 100644 --- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp +++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp @@ -6354,8 +6354,8 @@ llvm::Expected TypeSystemClang::GetChildCompilerTypeAtIndex( if (omit_empty_base_classes) { CompilerType base_class_clang_type = GetType( getASTContext().getObjCInterfaceType(superclass_interface_decl)); - if (llvm::expectedToStdOptional(base_class_clang_type.GetNumChildren( - omit_empty_base_classes, exe_ctx)) + if (llvm::expectedToOptional(base_class_clang_type.GetNumChildren( + omit_empty_base_classes, exe_ctx)) .value_or(0) > 0) { if (idx == 0) { clang::QualType ivar_qual_type(getASTContext().getObjCInterfaceType( diff --git a/lldb/source/Symbol/Variable.cpp b/lldb/source/Symbol/Variable.cpp index 55926a0b150ff..679fd19cf9844 100644 --- a/lldb/source/Symbol/Variable.cpp +++ b/lldb/source/Symbol/Variable.cpp @@ -578,7 +578,7 @@ static void PrivateAutoComplete( case eTypeClassObjCObjectPointer: case eTypeClassPointer: { bool omit_empty_base_classes = true; - if (llvm::expectedToStdOptional( + if (llvm::expectedToOptional( compiler_type.GetNumChildren(omit_empty_base_classes, nullptr)) .value_or(0)) request.AddCompletion((prefix_path + "->").str()); diff --git a/lldb/source/ValueObject/ValueObject.cpp b/lldb/source/ValueObject/ValueObject.cpp index 5b343848dda6b..689de76674744 100644 --- a/lldb/source/ValueObject/ValueObject.cpp +++ b/lldb/source/ValueObject/ValueObject.cpp @@ -2520,7 +2520,7 @@ ValueObjectSP ValueObject::GetValueForExpressionPath_Impl( child_valobj_sp = root->GetSyntheticArrayMember(index, true); if (!child_valobj_sp) if (root->HasSyntheticValue() && - llvm::expectedToStdOptional( + llvm::expectedToOptional( root->GetSyntheticValue()->GetNumChildren()) .value_or(0) > index) child_valobj_sp = diff --git a/llvm/include/llvm/Support/Error.h b/llvm/include/llvm/Support/Error.h index c9fd16fdb7c2b..51292163de89d 100644 --- a/llvm/include/llvm/Support/Error.h +++ b/llvm/include/llvm/Support/Error.h @@ -1084,13 +1084,13 @@ inline void consumeError(Error Err) { handleAllErrors(std::move(Err), [](const ErrorInfoBase &) {}); } -/// Convert an Expected to an Optional without doing anything. This method +/// Convert an Expected to an std::optional without doing anything. This method /// should be used only where an error can be considered a reasonable and /// expected return value. /// /// Uses of this method are potentially indicative of problems: perhaps the /// error should be propagated further, or the error-producer should just -/// return an Optional in the first place. +/// return an std::optional in the first place. template std::optional expectedToOptional(Expected &&E) { if (E) return std::move(*E); @@ -1098,13 +1098,6 @@ template std::optional expectedToOptional(Expected &&E) { return std::nullopt; } -template std::optional expectedToStdOptional(Expected &&E) { - if (E) - return std::move(*E); - consumeError(E.takeError()); - return std::nullopt; -} - /// Helper for converting an Error to a bool. /// /// This method returns true if Err is in an error state, or false if it is diff --git a/llvm/tools/llvm-readobj/ELFDumper.cpp b/llvm/tools/llvm-readobj/ELFDumper.cpp index bcb580119fb85..988afcb16148d 100644 --- a/llvm/tools/llvm-readobj/ELFDumper.cpp +++ b/llvm/tools/llvm-readobj/ELFDumper.cpp @@ -6361,7 +6361,7 @@ static void processNotesHelper( for (const typename ELFT::Shdr &S : Sections) { if (S.sh_type != SHT_NOTE) continue; - StartNotesFn(expectedToStdOptional(Obj.getSectionName(S)), S.sh_offset, + StartNotesFn(expectedToOptional(Obj.getSectionName(S)), S.sh_offset, S.sh_size, S.sh_addralign); Error Err = Error::success(); size_t I = 0;