From 2fce1137c7c227f40edbb657c484797addba38ca Mon Sep 17 00:00:00 2001 From: Lawrence D'Anna Date: Thu, 26 Sep 2019 17:54:59 +0000 Subject: Convert FileSystem::Open() to return Expected Summary: This patch converts FileSystem::Open from this prototype: Status Open(File &File, const FileSpec &file_spec, ...); to this one: llvm::Expected> Open(const FileSpec &file_spec, ...); This is beneficial on its own, as llvm::Expected is a more modern and recommended error type than Status. It is also a necessary step towards https://reviews.llvm.org/D67891, and further developments for lldb_private::File. Reviewers: JDevlieghere, jasonmolenda, labath Reviewed By: labath Subscribers: mgorny, lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D67996 llvm-svn: 373003 --- lldb/source/Interpreter/CommandInterpreter.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'lldb/source/Interpreter/CommandInterpreter.cpp') diff --git a/lldb/source/Interpreter/CommandInterpreter.cpp b/lldb/source/Interpreter/CommandInterpreter.cpp index a5b2d24aeba..6c97391a68b 100644 --- a/lldb/source/Interpreter/CommandInterpreter.cpp +++ b/lldb/source/Interpreter/CommandInterpreter.cpp @@ -70,6 +70,7 @@ #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/SmallString.h" +#include "llvm/Support/FormatAdapters.h" #include "llvm/Support/Path.h" #include "llvm/Support/PrettyStackTrace.h" @@ -2337,18 +2338,17 @@ void CommandInterpreter::HandleCommandsFromFile( return; } - StreamFileSP input_file_sp(new StreamFile()); std::string cmd_file_path = cmd_file.GetPath(); - Status error = FileSystem::Instance().Open(input_file_sp->GetFile(), cmd_file, - File::eOpenOptionRead); - if (error.Fail()) { - result.AppendErrorWithFormat( - "error: an error occurred read file '%s': %s\n", cmd_file_path.c_str(), - error.AsCString()); + auto file = FileSystem::Instance().Open(cmd_file, File::eOpenOptionRead); + if (!file) { + result.AppendErrorWithFormatv( + "error: an error occurred read file '{0}': {1}\n", cmd_file_path, + llvm::fmt_consume(file.takeError())); result.SetStatus(eReturnStatusFailed); return; } + auto input_file_sp = std::make_shared(std::move(file.get())); Debugger &debugger = GetDebugger(); -- cgit v1.2.3