diff --git a/lld/ELF/Driver.cpp b/lld/ELF/Driver.cpp index 3c893cbfdbb3..8fd613790cb8 100644 --- a/lld/ELF/Driver.cpp +++ b/lld/ELF/Driver.cpp @@ -102,7 +102,7 @@ LinkerDriver::getArchiveMembers(MemoryBufferRef MB) { check(Archive::create(MB), "failed to parse archive"); std::vector V; - Error Err; + Error Err = Error::success(); for (const ErrorOr &COrErr : File->children(Err)) { Archive::Child C = check(COrErr, "could not get the child of the archive " + File->getFileName()); diff --git a/lldb/include/lldb/Target/Process.h b/lldb/include/lldb/Target/Process.h index f2add84aac9f..a3a28714dce5 100644 --- a/lldb/include/lldb/Target/Process.h +++ b/lldb/include/lldb/Target/Process.h @@ -1082,7 +1082,9 @@ public: /// @return /// Returns an error object. //------------------------------------------------------------------ - virtual Error WillAttachToProcessWithID(lldb::pid_t pid) { return Error(); } + virtual Error WillAttachToProcessWithID(lldb::pid_t pid) { + return Error::success(); + } //------------------------------------------------------------------ /// Called before attaching to a process. @@ -1095,7 +1097,7 @@ public: //------------------------------------------------------------------ virtual Error WillAttachToProcessWithName(const char *process_name, bool wait_for_launch) { - return Error(); + return Error::success(); } //------------------------------------------------------------------ @@ -1204,7 +1206,7 @@ public: /// @return /// Returns an error object. //------------------------------------------------------------------ - virtual Error WillLaunch(Module *module) { return Error(); } + virtual Error WillLaunch(Module *module) { return Error::success(); } //------------------------------------------------------------------ /// Launch a new process. @@ -1250,7 +1252,7 @@ public: /// @return /// Returns an error object. //------------------------------------------------------------------ - virtual Error WillResume() { return Error(); } + virtual Error WillResume() { return Error::success(); } //------------------------------------------------------------------ /// Resumes all of a process's threads as configured using the @@ -1294,7 +1296,7 @@ public: /// @return /// Returns an error object. //------------------------------------------------------------------ - virtual Error WillHalt() { return Error(); } + virtual Error WillHalt() { return Error::success(); } //------------------------------------------------------------------ /// Halts a running process. @@ -1341,7 +1343,7 @@ public: /// @return /// Returns an error object. //------------------------------------------------------------------ - virtual Error WillDetach() { return Error(); } + virtual Error WillDetach() { return Error::success(); } //------------------------------------------------------------------ /// Detaches from a running or stopped process. @@ -1379,7 +1381,7 @@ public: /// Process::DoSignal(int), otherwise an error describing what /// prevents the signal from being sent. //------------------------------------------------------------------ - virtual Error WillSignal() { return Error(); } + virtual Error WillSignal() { return Error::success(); } //------------------------------------------------------------------ /// Sends a process a UNIX signal \a signal. @@ -1395,7 +1397,7 @@ public: return error; } - virtual Error WillDestroy() { return Error(); } + virtual Error WillDestroy() { return Error::success(); } virtual Error DoDestroy() = 0; diff --git a/lldb/source/Commands/CommandObjectDisassemble.cpp b/lldb/source/Commands/CommandObjectDisassemble.cpp index 079503341bc5..627374419df4 100644 --- a/lldb/source/Commands/CommandObjectDisassemble.cpp +++ b/lldb/source/Commands/CommandObjectDisassemble.cpp @@ -231,7 +231,7 @@ Error CommandObjectDisassemble::CommandOptions::OptionParsingFinished( ExecutionContext *execution_context) { if (!some_location_specified) current_function = true; - return Error(); + return Error::success(); } llvm::ArrayRef diff --git a/lldb/source/Commands/CommandObjectExpression.cpp b/lldb/source/Commands/CommandObjectExpression.cpp index ba477cd5f4c4..d98a3ee6fa62 100644 --- a/lldb/source/Commands/CommandObjectExpression.cpp +++ b/lldb/source/Commands/CommandObjectExpression.cpp @@ -303,7 +303,7 @@ CanBeUsedForElementCountPrinting(ValueObject &valobj) { return Error("as it does not refer to a pointer"); if (pointee.IsVoidType()) return Error("as it refers to a pointer to void"); - return Error(); + return Error::success(); } bool CommandObjectExpression::EvaluateExpression(const char *expr, diff --git a/lldb/source/Core/ModuleList.cpp b/lldb/source/Core/ModuleList.cpp index b980e15c0b37..7ad1f09dc2cb 100644 --- a/lldb/source/Core/ModuleList.cpp +++ b/lldb/source/Core/ModuleList.cpp @@ -788,7 +788,7 @@ Error ModuleList::GetSharedModule(const ModuleSpec &module_spec, *did_create_ptr = true; shared_module_list.ReplaceEquivalent(module_sp); - return Error(); + return Error::success(); } } } else { diff --git a/lldb/source/Host/common/NativeBreakpoint.cpp b/lldb/source/Host/common/NativeBreakpoint.cpp index d61a2f531ac3..a2cc04884a6a 100644 --- a/lldb/source/Host/common/NativeBreakpoint.cpp +++ b/lldb/source/Host/common/NativeBreakpoint.cpp @@ -53,7 +53,7 @@ Error NativeBreakpoint::Enable() { log->Printf("NativeBreakpoint::%s addr = 0x%" PRIx64 " already enabled, ignoring.", __FUNCTION__, m_addr); - return Error(); + return Error::success(); } // Log and enable. @@ -85,7 +85,7 @@ Error NativeBreakpoint::Disable() { log->Printf("NativeBreakpoint::%s addr = 0x%" PRIx64 " already disabled, ignoring.", __FUNCTION__, m_addr); - return Error(); + return Error::success(); } // Log and disable. diff --git a/lldb/source/Host/common/NativeBreakpointList.cpp b/lldb/source/Host/common/NativeBreakpointList.cpp index df5bce8079e0..58e1c3e9da6d 100644 --- a/lldb/source/Host/common/NativeBreakpointList.cpp +++ b/lldb/source/Host/common/NativeBreakpointList.cpp @@ -40,7 +40,7 @@ Error NativeBreakpointList::AddRef(lldb::addr_t addr, size_t size_hint, __FUNCTION__, addr); iter->second->AddRef(); - return Error(); + return Error::success(); } // Create a new breakpoint using the given create func. @@ -205,7 +205,7 @@ Error NativeBreakpointList::GetBreakpoint(lldb::addr_t addr, // Disable it. breakpoint_sp = iter->second; - return Error(); + return Error::success(); } Error NativeBreakpointList::RemoveTrapsFromBuffer(lldb::addr_t addr, void *buf, @@ -225,5 +225,5 @@ Error NativeBreakpointList::RemoveTrapsFromBuffer(lldb::addr_t addr, void *buf, auto opcode_size = software_bp_sp->m_opcode_size; ::memcpy(opcode_addr, saved_opcodes, opcode_size); } - return Error(); + return Error::success(); } diff --git a/lldb/source/Host/common/NativeProcessProtocol.cpp b/lldb/source/Host/common/NativeProcessProtocol.cpp index d77b8b2e9746..a22d7f8de7bc 100644 --- a/lldb/source/Host/common/NativeProcessProtocol.cpp +++ b/lldb/source/Host/common/NativeProcessProtocol.cpp @@ -405,7 +405,7 @@ Error NativeProcessProtocol::ResolveProcessArchitecture(lldb::pid_t pid, arch = module_specs.GetModuleSpecRefAtIndex(0).GetArchitecture(); if (arch.IsValid()) - return Error(); + return Error::success(); else return Error("failed to retrieve a valid architecture from the exe module"); } diff --git a/lldb/source/Host/common/NativeWatchpointList.cpp b/lldb/source/Host/common/NativeWatchpointList.cpp index 5948adf3c8d1..be9d2eba6a37 100644 --- a/lldb/source/Host/common/NativeWatchpointList.cpp +++ b/lldb/source/Host/common/NativeWatchpointList.cpp @@ -17,12 +17,12 @@ using namespace lldb_private; Error NativeWatchpointList::Add(addr_t addr, size_t size, uint32_t watch_flags, bool hardware) { m_watchpoints[addr] = {addr, size, watch_flags, hardware}; - return Error(); + return Error::success(); } Error NativeWatchpointList::Remove(addr_t addr) { m_watchpoints.erase(addr); - return Error(); + return Error::success(); } const NativeWatchpointList::WatchpointMap & diff --git a/lldb/source/Host/common/SoftwareBreakpoint.cpp b/lldb/source/Host/common/SoftwareBreakpoint.cpp index 3d57b7dd6b88..6cb8126fb14c 100644 --- a/lldb/source/Host/common/SoftwareBreakpoint.cpp +++ b/lldb/source/Host/common/SoftwareBreakpoint.cpp @@ -103,7 +103,7 @@ Error SoftwareBreakpoint::CreateSoftwareBreakpoint( // breakpoint. breakpoint_sp.reset(new SoftwareBreakpoint(process, addr, saved_opcode_bytes, bp_opcode_bytes, bp_opcode_size)); - return Error(); + return Error::success(); } Error SoftwareBreakpoint::EnableSoftwareBreakpoint( @@ -219,7 +219,7 @@ Error SoftwareBreakpoint::EnableSoftwareBreakpoint( log->Printf("SoftwareBreakpoint::%s addr = 0x%" PRIx64 " -- SUCCESS", __FUNCTION__, addr); - return Error(); + return Error::success(); } // ------------------------------------------------------------------- diff --git a/lldb/source/Host/posix/FileSystem.cpp b/lldb/source/Host/posix/FileSystem.cpp index aaa53ce07723..0567f60a3cb2 100644 --- a/lldb/source/Host/posix/FileSystem.cpp +++ b/lldb/source/Host/posix/FileSystem.cpp @@ -62,7 +62,7 @@ Error FileSystem::MakeDirectory(const FileSpec &file_spec, } break; case EEXIST: { if (file_spec.IsDirectory()) - return Error(); // It is a directory and it already exists + return Error::success(); // It is a directory and it already exists } break; } } @@ -210,7 +210,7 @@ Error FileSystem::ResolveSymbolicLink(const FileSpec &src, FileSpec &dst) { dst = FileSpec(real_path, false); - return Error(); + return Error::success(); } #if defined(__NetBSD__) diff --git a/lldb/source/Host/posix/MainLoopPosix.cpp b/lldb/source/Host/posix/MainLoopPosix.cpp index 08c969e72a26..59a76121f6d8 100644 --- a/lldb/source/Host/posix/MainLoopPosix.cpp +++ b/lldb/source/Host/posix/MainLoopPosix.cpp @@ -160,7 +160,7 @@ Error MainLoopPosix::Run() { it->second.callback(*this); // Do the work if (m_terminate_request) - return Error(); + return Error::success(); } for (int fd : read_fds) { @@ -175,8 +175,8 @@ Error MainLoopPosix::Run() { it->second(*this); // Do the work if (m_terminate_request) - return Error(); + return Error::success(); } } - return Error(); + return Error::success(); } diff --git a/lldb/source/Host/posix/PipePosix.cpp b/lldb/source/Host/posix/PipePosix.cpp index 4e0810c1a9b3..142f6c99cb22 100644 --- a/lldb/source/Host/posix/PipePosix.cpp +++ b/lldb/source/Host/posix/PipePosix.cpp @@ -206,7 +206,7 @@ Error PipePosix::OpenAsWriterWithTimeout( } } - return Error(); + return Error::success(); } int PipePosix::GetReadFileDescriptor() const { return m_fds[READ]; } diff --git a/lldb/source/Host/windows/LockFileWindows.cpp b/lldb/source/Host/windows/LockFileWindows.cpp index 0e7f595e6cfd..11096bc648d9 100644 --- a/lldb/source/Host/windows/LockFileWindows.cpp +++ b/lldb/source/Host/windows/LockFileWindows.cpp @@ -31,7 +31,7 @@ Error fileLock(HANDLE file_handle, DWORD flags, const uint64_t start, if (!::GetOverlappedResult(file_handle, &overlapped, &bytes, TRUE)) return Error(::GetLastError(), eErrorTypeWin32); - return Error(); + return Error::success(); } } // namespace @@ -74,5 +74,5 @@ Error LockFileWindows::DoUnlock() { if (!::GetOverlappedResult(m_file, &overlapped, &bytes, TRUE)) return Error(::GetLastError(), eErrorTypeWin32); - return Error(); + return Error::success(); } diff --git a/lldb/source/Host/windows/PipeWindows.cpp b/lldb/source/Host/windows/PipeWindows.cpp index 407f0468e6cb..64b658475068 100644 --- a/lldb/source/Host/windows/PipeWindows.cpp +++ b/lldb/source/Host/windows/PipeWindows.cpp @@ -161,7 +161,7 @@ Error PipeWindows::OpenNamedPipe(llvm::StringRef name, ZeroMemory(&m_write_overlapped, sizeof(m_write_overlapped)); } - return Error(); + return Error::success(); } int PipeWindows::GetReadFileDescriptor() const { return m_read_fd; } @@ -217,7 +217,7 @@ void PipeWindows::Close() { CloseWriteFileDescriptor(); } -Error PipeWindows::Delete(llvm::StringRef name) { return Error(); } +Error PipeWindows::Delete(llvm::StringRef name) { return Error::success(); } bool PipeWindows::CanRead() const { return (m_read != INVALID_HANDLE_VALUE); } @@ -273,7 +273,7 @@ Error PipeWindows::ReadWithTimeout(void *buf, size_t size, return Error(::GetLastError(), eErrorTypeWin32); bytes_read = sys_bytes_read; - return Error(); + return Error::success(); } Error PipeWindows::Write(const void *buf, size_t num_bytes, @@ -291,5 +291,5 @@ Error PipeWindows::Write(const void *buf, size_t num_bytes, &sys_bytes_written, TRUE); if (!result) return Error(::GetLastError(), eErrorTypeWin32); - return Error(); + return Error::success(); } diff --git a/lldb/source/Interpreter/OptionGroupVariable.cpp b/lldb/source/Interpreter/OptionGroupVariable.cpp index c257506135fa..a3150d17f761 100644 --- a/lldb/source/Interpreter/OptionGroupVariable.cpp +++ b/lldb/source/Interpreter/OptionGroupVariable.cpp @@ -59,13 +59,13 @@ static Error ValidateNamedSummary(const char *str, void *) { if (DataVisualization::NamedSummaryFormats::GetSummaryFormat( ConstString(str), summary_sp) == false) return Error("must specify a valid named summary"); - return Error(); + return Error::success(); } static Error ValidateSummaryString(const char *str, void *) { if (!str || !str[0]) return Error("must specify a non-empty summary string"); - return Error(); + return Error::success(); } OptionGroupVariable::OptionGroupVariable(bool show_frame_options) diff --git a/lldb/source/Interpreter/OptionValueString.cpp b/lldb/source/Interpreter/OptionValueString.cpp index e61ead081b89..b5ce38ce4fd2 100644 --- a/lldb/source/Interpreter/OptionValueString.cpp +++ b/lldb/source/Interpreter/OptionValueString.cpp @@ -133,7 +133,7 @@ Error OptionValueString::SetCurrentValue(llvm::StringRef value) { return error; } m_current_value.assign(value); - return Error(); + return Error::success(); } Error OptionValueString::AppendToCurrentValue(const char *value) { @@ -148,5 +148,5 @@ Error OptionValueString::AppendToCurrentValue(const char *value) { } else m_current_value.append(value); } - return Error(); + return Error::success(); } diff --git a/lldb/source/Plugins/DynamicLoader/Hexagon-DYLD/DynamicLoaderHexagonDYLD.cpp b/lldb/source/Plugins/DynamicLoader/Hexagon-DYLD/DynamicLoaderHexagonDYLD.cpp index fcbba93762fc..73c3cca046ff 100644 --- a/lldb/source/Plugins/DynamicLoader/Hexagon-DYLD/DynamicLoaderHexagonDYLD.cpp +++ b/lldb/source/Plugins/DynamicLoader/Hexagon-DYLD/DynamicLoaderHexagonDYLD.cpp @@ -213,7 +213,7 @@ ModuleSP DynamicLoaderHexagonDYLD::GetTargetExecutable() { } // AD: Needs to be updated? -Error DynamicLoaderHexagonDYLD::CanLoadImage() { return Error(); } +Error DynamicLoaderHexagonDYLD::CanLoadImage() { return Error::success(); } void DynamicLoaderHexagonDYLD::UpdateLoadedSections(ModuleSP module, addr_t link_map_addr, diff --git a/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp b/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp index 8678f616eace..9af464622fd8 100644 --- a/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp +++ b/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp @@ -221,7 +221,7 @@ void DynamicLoaderPOSIXDYLD::DidLaunch() { } } -Error DynamicLoaderPOSIXDYLD::CanLoadImage() { return Error(); } +Error DynamicLoaderPOSIXDYLD::CanLoadImage() { return Error::success(); } void DynamicLoaderPOSIXDYLD::UpdateLoadedSections(ModuleSP module, addr_t link_map_addr, diff --git a/lldb/source/Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.cpp b/lldb/source/Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.cpp index 20bf3609f46f..09ed903cf12c 100644 --- a/lldb/source/Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.cpp +++ b/lldb/source/Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.cpp @@ -61,7 +61,7 @@ void DynamicLoaderWindowsDYLD::DidAttach() {} void DynamicLoaderWindowsDYLD::DidLaunch() {} -Error DynamicLoaderWindowsDYLD::CanLoadImage() { return Error(); } +Error DynamicLoaderWindowsDYLD::CanLoadImage() { return Error::success(); } ConstString DynamicLoaderWindowsDYLD::GetPluginName() { return GetPluginNameStatic(); diff --git a/lldb/source/Plugins/Platform/Android/AdbClient.cpp b/lldb/source/Plugins/Platform/Android/AdbClient.cpp index 79ad8f52d64c..592bc84f5906 100644 --- a/lldb/source/Plugins/Platform/Android/AdbClient.cpp +++ b/lldb/source/Plugins/Platform/Android/AdbClient.cpp @@ -381,7 +381,7 @@ Error AdbClient::internalShell(const char *command, uint32_t timeout_ms, std::string(output_buf.begin(), output_buf.end()).c_str()); } - return Error(); + return Error::success(); } Error AdbClient::Shell(const char *command, uint32_t timeout_ms, @@ -412,7 +412,7 @@ Error AdbClient::ShellToFile(const char *command, uint32_t timeout_ms, dst.close(); if (!dst) return Error("Failed to write file %s", output_filename.c_str()); - return Error(); + return Error::success(); } std::unique_ptr @@ -536,7 +536,7 @@ Error AdbClient::SyncService::internalStat(const FileSpec &remote_file, mode = extractor.GetU32(&offset); size = extractor.GetU32(&offset); mtime = extractor.GetU32(&offset); - return Error(); + return Error::success(); } Error AdbClient::SyncService::PullFile(const FileSpec &remote_file, @@ -641,7 +641,7 @@ Error AdbClient::SyncService::PullFileChunk(std::vector &buffer, } else return Error("Pull failed with unknown response: %s", response_id.c_str()); - return Error(); + return Error::success(); } Error AdbClient::SyncService::ReadAllBytes(void *buffer, size_t size) { diff --git a/lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp b/lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp index a870929d6bae..43720c06b446 100644 --- a/lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp +++ b/lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp @@ -252,7 +252,7 @@ Error PlatformFreeBSD::GetFileWithUUID(const FileSpec &platform_file, // Default to the local case local_file = platform_file; - return Error(); + return Error::success(); } //------------------------------------------------------------------ diff --git a/lldb/source/Plugins/Platform/Kalimba/PlatformKalimba.cpp b/lldb/source/Plugins/Platform/Kalimba/PlatformKalimba.cpp index 69f5c29c029f..017a1bfcb166 100644 --- a/lldb/source/Plugins/Platform/Kalimba/PlatformKalimba.cpp +++ b/lldb/source/Plugins/Platform/Kalimba/PlatformKalimba.cpp @@ -179,7 +179,7 @@ Error PlatformKalimba::ResolveExecutable( Error PlatformKalimba::GetFileWithUUID(const FileSpec & /*platform_file*/, const UUID * /*uuid_ptr*/, FileSpec & /*local_file*/) { - return Error(); + return Error::success(); } //------------------------------------------------------------------ diff --git a/lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp b/lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp index 5b6bc35c4113..b8fae1446585 100644 --- a/lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp +++ b/lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp @@ -341,7 +341,7 @@ Error PlatformLinux::GetFileWithUUID(const FileSpec &platform_file, // Default to the local case local_file = platform_file; - return Error(); + return Error::success(); } //------------------------------------------------------------------ diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp b/lldb/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp index e6da63e8af6a..0b5d394e465f 100644 --- a/lldb/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp +++ b/lldb/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp @@ -71,7 +71,7 @@ lldb_private::Error PlatformAppleSimulator::LaunchProcess( if (spawned) { launch_info.SetProcessID(spawned.GetPID()); - return Error(); + return Error::success(); } else return spawned.GetError(); #else @@ -164,7 +164,7 @@ Error PlatformAppleSimulator::ConnectRemote(Args &args) { Error PlatformAppleSimulator::DisconnectRemote() { #if defined(__APPLE__) m_device.reset(); - return Error(); + return Error::success(); #else Error err; err.SetErrorString(UNSUPPORTED_ERROR); diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp index a92a8da50fbf..8cecd38f7f64 100644 --- a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp +++ b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp @@ -393,7 +393,7 @@ lldb_private::Error PlatformDarwin::GetSharedModuleWithLocalCache( module_spec.GetArchitecture()); module_sp.reset(new Module(local_spec)); module_sp->SetPlatformFileSpec(module_spec.GetFileSpec()); - return Error(); + return Error::success(); } } @@ -433,7 +433,7 @@ lldb_private::Error PlatformDarwin::GetSharedModuleWithLocalCache( (IsHost() ? "host" : "remote"), module_spec.GetFileSpec().GetDirectory().AsCString(), module_spec.GetFileSpec().GetFilename().AsCString()); - return Error(); + return Error::success(); } // bring in the remote module file @@ -455,7 +455,7 @@ lldb_private::Error PlatformDarwin::GetSharedModuleWithLocalCache( ModuleSpec local_spec(module_cache_spec, module_spec.GetArchitecture()); module_sp.reset(new Module(local_spec)); module_sp->SetPlatformFileSpec(module_spec.GetFileSpec()); - return Error(); + return Error::success(); } else return Error("unable to obtain valid module file"); } else diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp b/lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp index 89b61bf281bc..c50630284c88 100644 --- a/lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp +++ b/lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp @@ -247,7 +247,7 @@ Error PlatformMacOSX::GetSymbolFile(const FileSpec &platform_file, // Default to the local case local_file = platform_file; - return Error(); + return Error::success(); } lldb_private::Error @@ -264,7 +264,7 @@ PlatformMacOSX::GetFileWithUUID(const lldb_private::FileSpec &platform_file, if (local_os_build.compare(remote_os_build) == 0) { // same OS version: the local file is good enough local_file = platform_file; - return Error(); + return Error::success(); } else { // try to find the file in the cache std::string cache_path(GetLocalCacheDirectory()); @@ -273,7 +273,7 @@ PlatformMacOSX::GetFileWithUUID(const lldb_private::FileSpec &platform_file, FileSpec module_cache_spec(cache_path, false); if (module_cache_spec.Exists()) { local_file = module_cache_spec; - return Error(); + return Error::success(); } // bring in the remote module file FileSpec module_cache_folder = @@ -288,13 +288,13 @@ PlatformMacOSX::GetFileWithUUID(const lldb_private::FileSpec &platform_file, return err; if (module_cache_spec.Exists()) { local_file = module_cache_spec; - return Error(); + return Error::success(); } else return Error("unable to obtain valid module file"); } } local_file = platform_file; - return Error(); + return Error::success(); } bool PlatformMacOSX::GetSupportedArchitectureAtIndex(uint32_t idx, diff --git a/lldb/source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp b/lldb/source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp index cb3c124b8dee..b7fa7aa18883 100644 --- a/lldb/source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp +++ b/lldb/source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp @@ -244,7 +244,7 @@ Error PlatformNetBSD::GetFileWithUUID(const FileSpec &platform_file, // Default to the local case local_file = platform_file; - return Error(); + return Error::success(); } //------------------------------------------------------------------ diff --git a/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp b/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp index b751de71328a..100500f3e3b7 100644 --- a/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp +++ b/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp @@ -207,7 +207,7 @@ PlatformPOSIX::PutFile(const lldb_private::FileSpec &source, if (IsHost()) { if (FileSpec::Equal(source, destination, true)) - return Error(); + return Error::success(); // cp src dst // chown uid:gid dst std::string src_path(source.GetPath()); @@ -223,10 +223,10 @@ PlatformPOSIX::PutFile(const lldb_private::FileSpec &source, if (status != 0) return Error("unable to perform copy"); if (uid == UINT32_MAX && gid == UINT32_MAX) - return Error(); + return Error::success(); if (chown_file(this, dst_path.c_str(), uid, gid) != 0) return Error("unable to perform chown"); - return Error(); + return Error::success(); } else if (m_remote_platform_sp) { if (GetSupportsRSync()) { std::string src_path(source.GetPath()); @@ -254,7 +254,7 @@ PlatformPOSIX::PutFile(const lldb_private::FileSpec &source, // Don't chown a local file for a remote system // if (chown_file(this,dst_path.c_str(),uid,gid) != 0) // return Error("unable to perform chown"); - return Error(); + return Error::success(); } // if we are still here rsync has failed - let's try the slow way before // giving up @@ -323,7 +323,7 @@ lldb_private::Error PlatformPOSIX::GetFile( RunShellCommand(cp_command.GetData(), NULL, &status, NULL, NULL, 10); if (status != 0) return Error("unable to perform copy"); - return Error(); + return Error::success(); } else if (m_remote_platform_sp) { if (GetSupportsRSync()) { StreamString command; @@ -343,7 +343,7 @@ lldb_private::Error PlatformPOSIX::GetFile( int retcode; Host::RunShellCommand(command.GetData(), NULL, &retcode, NULL, NULL, 60); if (retcode == 0) - return Error(); + return Error::success(); // If we are here, rsync has failed - let's try the slow way before giving // up } @@ -745,7 +745,7 @@ Error PlatformPOSIX::EvaluateLibdlExpression( if (result_valobj_sp->GetError().Fail()) return result_valobj_sp->GetError(); - return Error(); + return Error::success(); } uint32_t PlatformPOSIX::DoLoadImage(lldb_private::Process *process, @@ -833,7 +833,7 @@ Error PlatformPOSIX::UnloadImage(lldb_private::Process *process, return Error("expression failed: \"%s\"", expr.GetData()); process->ResetImageToken(image_token); } - return Error(); + return Error::success(); } lldb::ProcessSP PlatformPOSIX::ConnectProcess(const char *connect_url, diff --git a/lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp b/lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp index d25bb7bbf469..534c773136d7 100644 --- a/lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp +++ b/lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp @@ -527,7 +527,7 @@ Error PlatformWindows::GetFileWithUUID(const FileSpec &platform_file, // Default to the local case local_file = platform_file; - return Error(); + return Error::success(); } Error PlatformWindows::GetSharedModule( diff --git a/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp b/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp index 8b9972f9da27..007ce1a5fd10 100644 --- a/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp +++ b/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp @@ -196,7 +196,7 @@ Error PlatformRemoteGDBServer::GetFileWithUUID(const FileSpec &platform_file, FileSpec &local_file) { // Default to the local case local_file = platform_file; - return Error(); + return Error::success(); } //------------------------------------------------------------------ @@ -482,7 +482,7 @@ Error PlatformRemoteGDBServer::LaunchProcess(ProcessLaunchInfo &launch_info) { Error PlatformRemoteGDBServer::KillProcess(const lldb::pid_t pid) { if (!KillSpawnedProcess(pid)) return Error("failed to kill remote spawned process"); - return Error(); + return Error::success(); } lldb::ProcessSP PlatformRemoteGDBServer::DebugProcess( diff --git a/lldb/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp b/lldb/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp index 82e45a5d5fc1..7680dfe3cda7 100644 --- a/lldb/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp +++ b/lldb/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp @@ -150,7 +150,7 @@ Error ProcessFreeBSD::DoResume() { else m_monitor->Resume(GetID(), m_resume_signo); - return Error(); + return Error::success(); } bool ProcessFreeBSD::UpdateThreadList(ThreadList &old_thread_list, diff --git a/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp b/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp index 8494077141be..7a3696ad0fb2 100644 --- a/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp +++ b/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp @@ -1364,13 +1364,13 @@ Error NativeProcessLinux::SetupSoftwareSingleStepping( // If setting the breakpoint fails because next_pc is out of // the address space, ignore it and let the debugee segfault. if (error.GetError() == EIO || error.GetError() == EFAULT) { - return Error(); + return Error::success(); } else if (error.Fail()) return error; m_threads_stepping_with_breakpoint.insert({thread.GetID(), next_pc}); - return Error(); + return Error::success(); } bool NativeProcessLinux::SupportHardwareSingleStepping() const { @@ -1453,7 +1453,7 @@ Error NativeProcessLinux::Resume(const ResumeActionList &resume_actions) { } } - return Error(); + return Error::success(); } Error NativeProcessLinux::Halt() { @@ -1553,7 +1553,7 @@ Error NativeProcessLinux::Interrupt() { StopRunningThreads(deferred_signal_thread_sp->GetID()); - return Error(); + return Error::success(); } Error NativeProcessLinux::Kill() { @@ -1677,7 +1677,7 @@ ParseMemoryRegionInfoFromProcMapsLine(const std::string &maps_line, if (name) memory_region_info.SetName(name); - return Error(); + return Error::success(); } Error NativeProcessLinux::GetMemoryRegionInfo(lldb::addr_t load_addr, @@ -1841,7 +1841,7 @@ Error NativeProcessLinux::AllocateMemory(size_t size, uint32_t permissions, if (InferiorCallMmap(this, addr, 0, size, prot, eMmapFlagsAnon | eMmapFlagsPrivate, -1, 0)) { m_addr_to_mmap_size[addr] = size; - return Error(); + return Error::success(); } else { addr = LLDB_INVALID_ADDRESS; return Error("unable to allocate %" PRIu64 @@ -1886,11 +1886,11 @@ Error NativeProcessLinux::GetSoftwareBreakpointPCOffset( case llvm::Triple::x86: case llvm::Triple::x86_64: actual_opcode_size = static_cast(sizeof(g_i386_opcode)); - return Error(); + return Error::success(); case llvm::Triple::systemz: actual_opcode_size = static_cast(sizeof(g_s390x_opcode)); - return Error(); + return Error::success(); case llvm::Triple::arm: case llvm::Triple::aarch64: @@ -1900,7 +1900,7 @@ Error NativeProcessLinux::GetSoftwareBreakpointPCOffset( case llvm::Triple::mipsel: // On these architectures the PC don't get updated for breakpoint hits actual_opcode_size = 0; - return Error(); + return Error::success(); default: assert(false && "CPU type not supported!"); @@ -1935,18 +1935,18 @@ Error NativeProcessLinux::GetSoftwareBreakpointTrapOpcode( case llvm::Triple::aarch64: trap_opcode_bytes = g_aarch64_opcode; actual_opcode_size = sizeof(g_aarch64_opcode); - return Error(); + return Error::success(); case llvm::Triple::arm: switch (trap_opcode_size_hint) { case 2: trap_opcode_bytes = g_thumb_breakpoint_opcode; actual_opcode_size = sizeof(g_thumb_breakpoint_opcode); - return Error(); + return Error::success(); case 4: trap_opcode_bytes = g_arm_breakpoint_opcode; actual_opcode_size = sizeof(g_arm_breakpoint_opcode); - return Error(); + return Error::success(); default: assert(false && "Unrecognised trap opcode size hint!"); return Error("Unrecognised trap opcode size hint!"); @@ -1956,24 +1956,24 @@ Error NativeProcessLinux::GetSoftwareBreakpointTrapOpcode( case llvm::Triple::x86_64: trap_opcode_bytes = g_i386_opcode; actual_opcode_size = sizeof(g_i386_opcode); - return Error(); + return Error::success(); case llvm::Triple::mips: case llvm::Triple::mips64: trap_opcode_bytes = g_mips64_opcode; actual_opcode_size = sizeof(g_mips64_opcode); - return Error(); + return Error::success(); case llvm::Triple::mipsel: case llvm::Triple::mips64el: trap_opcode_bytes = g_mips64el_opcode; actual_opcode_size = sizeof(g_mips64el_opcode); - return Error(); + return Error::success(); case llvm::Triple::systemz: trap_opcode_bytes = g_s390x_opcode; actual_opcode_size = sizeof(g_s390x_opcode); - return Error(); + return Error::success(); default: assert(false && "CPU type not supported!"); @@ -2156,7 +2156,7 @@ Error NativeProcessLinux::ReadMemory(lldb::addr_t addr, void *buf, size_t size, success ? "Success" : strerror(errno)); if (success) - return Error(); + return Error::success(); // else // the call failed for some reason, let's retry the read using ptrace // api. @@ -2207,7 +2207,7 @@ Error NativeProcessLinux::ReadMemory(lldb::addr_t addr, void *buf, size_t size, if (log) ProcessPOSIXLog::DecNestLevel(); - return Error(); + return Error::success(); } Error NativeProcessLinux::ReadMemoryWithoutTrap(lldb::addr_t addr, void *buf, @@ -2303,7 +2303,7 @@ Error NativeProcessLinux::GetEventMessage(lldb::tid_t tid, Error NativeProcessLinux::Detach(lldb::tid_t tid) { if (tid == LLDB_INVALID_THREAD_ID) - return Error(); + return Error::success(); return PtraceWrapper(PTRACE_DETACH, tid); } @@ -2414,7 +2414,7 @@ Error NativeProcessLinux::FixupBreakpointPCAsNeeded(NativeThreadLinux &thread) { "NativeProcessLinux::%s pid %" PRIu64 " no lldb breakpoint found at current pc with adjustment: 0x%" PRIx64, __FUNCTION__, GetID(), breakpoint_addr); - return Error(); + return Error::success(); } // If the breakpoint is not a software breakpoint, nothing to do. @@ -2424,7 +2424,7 @@ Error NativeProcessLinux::FixupBreakpointPCAsNeeded(NativeThreadLinux &thread) { " breakpoint found at 0x%" PRIx64 ", not software, nothing to adjust", __FUNCTION__, GetID(), breakpoint_addr); - return Error(); + return Error::success(); } // @@ -2440,7 +2440,7 @@ Error NativeProcessLinux::FixupBreakpointPCAsNeeded(NativeThreadLinux &thread) { " breakpoint found at 0x%" PRIx64 ", it is software, but the size is zero, nothing to do (unexpected)", __FUNCTION__, GetID(), breakpoint_addr); - return Error(); + return Error::success(); } // Change the program counter. @@ -2488,7 +2488,7 @@ Error NativeProcessLinux::GetLoadedModuleFileSpec(const char *module_path, return Error("Module file (%s) not found in /proc/%" PRIu64 "/maps file!", module_file_spec.GetFilename().AsCString(), GetID()); - return Error(); + return Error::success(); } Error NativeProcessLinux::GetFileLoadAddress(const llvm::StringRef &file_name, diff --git a/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm.cpp b/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm.cpp index 9e857139cfca..45664937676c 100644 --- a/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm.cpp +++ b/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm.cpp @@ -263,7 +263,7 @@ Error NativeRegisterContextLinux_arm::WriteRegister( if (error.Fail()) return error; - return Error(); + return Error::success(); } return Error("failed - register wasn't recognized to be a GPR or an FPR, " @@ -679,7 +679,7 @@ Error NativeRegisterContextLinux_arm::ClearAllHardwareWatchpoints() { } } - return Error(); + return Error::success(); } uint32_t NativeRegisterContextLinux_arm::GetWatchpointSize(uint32_t wp_index) { @@ -730,12 +730,12 @@ Error NativeRegisterContextLinux_arm::GetWatchpointHitIndex( if (WatchpointIsEnabled(wp_index) && trap_addr >= watch_addr && trap_addr < watch_addr + watch_size) { m_hwp_regs[wp_index].hit_addr = trap_addr; - return Error(); + return Error::success(); } } wp_index = LLDB_INVALID_INDEX32; - return Error(); + return Error::success(); } lldb::addr_t @@ -774,7 +774,7 @@ Error NativeRegisterContextLinux_arm::ReadHardwareDebugInfo() { Error error; if (!m_refresh_hwdebug_info) { - return Error(); + return Error::success(); } unsigned int cap_val; @@ -862,7 +862,7 @@ Error NativeRegisterContextLinux_arm::DoReadRegisterValue( return error; value.SetUInt32(m_gpr_arm[offset / sizeof(uint32_t)]); - return Error(); + return Error::success(); } Error NativeRegisterContextLinux_arm::DoWriteRegisterValue( diff --git a/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp b/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp index cb0700de69f3..c0fdb74a98c6 100644 --- a/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp +++ b/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp @@ -276,7 +276,7 @@ Error NativeRegisterContextLinux_arm64::WriteRegister( if (error.Fail()) return error; - return Error(); + return Error::success(); } return Error("failed - register wasn't recognized to be a GPR or an FPR, " @@ -671,7 +671,7 @@ Error NativeRegisterContextLinux_arm64::ClearAllHardwareWatchpoints() { } } - return Error(); + return Error::success(); } uint32_t @@ -722,12 +722,12 @@ Error NativeRegisterContextLinux_arm64::GetWatchpointHitIndex( if (WatchpointIsEnabled(wp_index) && trap_addr >= watch_addr && trap_addr < watch_addr + watch_size) { m_hwp_regs[wp_index].hit_addr = trap_addr; - return Error(); + return Error::success(); } } wp_index = LLDB_INVALID_INDEX32; - return Error(); + return Error::success(); } lldb::addr_t @@ -764,7 +764,7 @@ NativeRegisterContextLinux_arm64::GetWatchpointHitAddress(uint32_t wp_index) { Error NativeRegisterContextLinux_arm64::ReadHardwareDebugInfo() { if (!m_refresh_hwdebug_info) { - return Error(); + return Error::success(); } ::pid_t tid = m_thread.GetID(); diff --git a/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_mips64.cpp b/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_mips64.cpp index c050a2ec0cc6..bbd4578f9b6c 100644 --- a/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_mips64.cpp +++ b/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_mips64.cpp @@ -932,7 +932,7 @@ Error NativeRegisterContextLinux_mips64::GetWatchpointHitIndex( } } wp_index = LLDB_INVALID_INDEX32; - return Error(); + return Error::success(); } Error NativeRegisterContextLinux_mips64::IsWatchpointVacant(uint32_t wp_index, diff --git a/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_s390x.cpp b/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_s390x.cpp index 7ec4dc551fac..105fa9b626fc 100644 --- a/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_s390x.cpp +++ b/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_s390x.cpp @@ -222,7 +222,7 @@ Error NativeRegisterContextLinux_s390x::ReadRegister( assert(false && "Unhandled data size."); return Error("unhandled byte size: %" PRIu32, reg_info->byte_size); } - return Error(); + return Error::success(); } if (IsFPR(reg)) { @@ -245,7 +245,7 @@ Error NativeRegisterContextLinux_s390x::ReadRegister( assert(false && "Unhandled data size."); return Error("unhandled byte size: %" PRIu32, reg_info->byte_size); } - return Error(); + return Error::success(); } if (reg == lldb_last_break_s390x) { @@ -255,7 +255,7 @@ Error NativeRegisterContextLinux_s390x::ReadRegister( return error; reg_value.SetUInt64(last_break); - return Error(); + return Error::success(); } if (reg == lldb_system_call_s390x) { @@ -265,7 +265,7 @@ Error NativeRegisterContextLinux_s390x::ReadRegister( return error; reg_value.SetUInt32(system_call); - return Error(); + return Error::success(); } return Error("failed - register wasn't recognized"); @@ -511,7 +511,7 @@ Error NativeRegisterContextLinux_s390x::IsWatchpointHit(uint32_t wp_index, if (m_watchpoint_addr == LLDB_INVALID_ADDRESS) { is_hit = false; - return Error(); + return Error::success(); } Error error = PeekUserArea(offsetof(user_regs_struct, per_info.lowcore), @@ -531,7 +531,7 @@ Error NativeRegisterContextLinux_s390x::IsWatchpointHit(uint32_t wp_index, sizeof(per_lowcore)); } - return Error(); + return Error::success(); } Error NativeRegisterContextLinux_s390x::GetWatchpointHitIndex( @@ -548,7 +548,7 @@ Error NativeRegisterContextLinux_s390x::GetWatchpointHitIndex( } } wp_index = LLDB_INVALID_INDEX32; - return Error(); + return Error::success(); } Error NativeRegisterContextLinux_s390x::IsWatchpointVacant(uint32_t wp_index, @@ -558,7 +558,7 @@ Error NativeRegisterContextLinux_s390x::IsWatchpointVacant(uint32_t wp_index, is_vacant = m_watchpoint_addr == LLDB_INVALID_ADDRESS; - return Error(); + return Error::success(); } bool NativeRegisterContextLinux_s390x::ClearHardwareWatchpoint( @@ -589,7 +589,7 @@ bool NativeRegisterContextLinux_s390x::ClearHardwareWatchpoint( Error NativeRegisterContextLinux_s390x::ClearAllHardwareWatchpoints() { if (ClearHardwareWatchpoint(0)) - return Error(); + return Error::success(); return Error("Clearing all hardware watchpoints failed."); } diff --git a/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.cpp b/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.cpp index 37e748da4daa..e9bc29620f1d 100644 --- a/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.cpp +++ b/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.cpp @@ -626,7 +626,7 @@ Error NativeRegisterContextLinux_x86_64::WriteRegister( if (!CopyMPXtoXSTATE(reg_index)) return Error("CopyMPXtoXSTATE() failed"); } - return Error(); + return Error::success(); } return Error("failed - register wasn't recognized to be a GPR or an FPR, " "write strategy unknown"); @@ -1035,7 +1035,7 @@ Error NativeRegisterContextLinux_x86_64::GetWatchpointHitIndex( } } wp_index = LLDB_INVALID_INDEX32; - return Error(); + return Error::success(); } Error NativeRegisterContextLinux_x86_64::IsWatchpointVacant(uint32_t wp_index, diff --git a/lldb/source/Plugins/Process/Linux/NativeThreadLinux.cpp b/lldb/source/Plugins/Process/Linux/NativeThreadLinux.cpp index d18d3c16d2c9..6b4426b3989b 100644 --- a/lldb/source/Plugins/Process/Linux/NativeThreadLinux.cpp +++ b/lldb/source/Plugins/Process/Linux/NativeThreadLinux.cpp @@ -167,7 +167,7 @@ Error NativeThreadLinux::SetWatchpoint(lldb::addr_t addr, size_t size, if (!hardware) return Error("not implemented"); if (m_state == eStateLaunching) - return Error(); + return Error::success(); Error error = RemoveWatchpoint(addr); if (error.Fail()) return error; @@ -176,17 +176,17 @@ Error NativeThreadLinux::SetWatchpoint(lldb::addr_t addr, size_t size, if (wp_index == LLDB_INVALID_INDEX32) return Error("Setting hardware watchpoint failed."); m_watchpoint_index_map.insert({addr, wp_index}); - return Error(); + return Error::success(); } Error NativeThreadLinux::RemoveWatchpoint(lldb::addr_t addr) { auto wp = m_watchpoint_index_map.find(addr); if (wp == m_watchpoint_index_map.end()) - return Error(); + return Error::success(); uint32_t wp_index = wp->second; m_watchpoint_index_map.erase(wp); if (GetRegisterContext()->ClearHardwareWatchpoint(wp_index)) - return Error(); + return Error::success(); return Error("Clearing hardware watchpoint failed."); } diff --git a/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp b/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp index 77b9fc86ebac..2decd2933f46 100644 --- a/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp +++ b/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp @@ -414,7 +414,7 @@ lldb_private::DynamicLoader *ProcessKDP::GetDynamicLoader() { return m_dyld_ap.get(); } -Error ProcessKDP::WillResume() { return Error(); } +Error ProcessKDP::WillResume() { return Error::success(); } Error ProcessKDP::DoResume() { Error error; diff --git a/lldb/source/Plugins/Process/Windows/Live/ProcessWindowsLive.cpp b/lldb/source/Plugins/Process/Windows/Live/ProcessWindowsLive.cpp index 7ddc5866a5f3..8fe93fac39fb 100644 --- a/lldb/source/Plugins/Process/Windows/Live/ProcessWindowsLive.cpp +++ b/lldb/source/Plugins/Process/Windows/Live/ProcessWindowsLive.cpp @@ -427,7 +427,7 @@ Error ProcessWindowsLive::DoDetach(bool keep_stopped) { WINDOWS_LOG_PROCESS, "DoDetach called while state = %u, but there is no active session.", private_state); - return Error(); + return Error::success(); } debugger_thread = m_session_data->m_debugger; @@ -477,7 +477,7 @@ Error ProcessWindowsLive::DoDestroy() { WINDOWS_LOG_PROCESS, "DoDestroy called while state = %u, but there is no active session.", private_state); - return Error(); + return Error::success(); } debugger_thread = m_session_data->m_debugger; diff --git a/lldb/source/Plugins/Process/Windows/MiniDump/ProcessWinMiniDump.cpp b/lldb/source/Plugins/Process/Windows/MiniDump/ProcessWinMiniDump.cpp index 128c4c16c36d..5aaeb98dc1b4 100644 --- a/lldb/source/Plugins/Process/Windows/MiniDump/ProcessWinMiniDump.cpp +++ b/lldb/source/Plugins/Process/Windows/MiniDump/ProcessWinMiniDump.cpp @@ -587,7 +587,7 @@ void ProcessWinMiniDump::RefreshStateAfterStop() { return m_impl_up->RefreshStateAfterStop(); } -Error ProcessWinMiniDump::DoDestroy() { return Error(); } +Error ProcessWinMiniDump::DoDestroy() { return Error::success(); } bool ProcessWinMiniDump::IsAlive() { return true; } diff --git a/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp b/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp index 840a79279f51..d9fa3f84476d 100644 --- a/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp +++ b/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp @@ -258,7 +258,7 @@ bool ProcessElfCore::UpdateThreadList(ThreadList &old_thread_list, void ProcessElfCore::RefreshStateAfterStop() {} -Error ProcessElfCore::DoDestroy() { return Error(); } +Error ProcessElfCore::DoDestroy() { return Error::success(); } //------------------------------------------------------------------ // Process Queries @@ -304,7 +304,7 @@ Error ProcessElfCore::GetMemoryRegionInfo(lldb::addr_t load_addr, region_info.SetExecutable(MemoryRegionInfo::eNo); region_info.SetMapped(MemoryRegionInfo::eNo); } - return Error(); + return Error::success(); } region_info.GetRange().SetRangeBase(load_addr); @@ -313,7 +313,7 @@ Error ProcessElfCore::GetMemoryRegionInfo(lldb::addr_t load_addr, region_info.SetWritable(MemoryRegionInfo::eNo); region_info.SetExecutable(MemoryRegionInfo::eNo); region_info.SetMapped(MemoryRegionInfo::eNo); - return Error(); + return Error::success(); } size_t ProcessElfCore::DoReadMemory(lldb::addr_t addr, void *buf, size_t size, diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp index 49733a5ba752..f0494a8f0f3c 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp @@ -2672,7 +2672,7 @@ lldb_private::Error GDBRemoteCommunicationClient::RunShellCommand( response.GetEscapedBinaryData(output); if (command_output) command_output->assign(output); - return Error(); + return Error::success(); } return Error("unable to send packet"); } diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp index 0897611e6d61..440651fac327 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp @@ -197,13 +197,13 @@ Error GDBRemoteCommunicationServerLLGS::SetLaunchArguments( __FUNCTION__); m_process_launch_info.SetArguments(const_cast(args), true); - return Error(); + return Error::success(); } Error GDBRemoteCommunicationServerLLGS::SetLaunchFlags( unsigned int launch_flags) { m_process_launch_info.GetFlags().Set(launch_flags); - return Error(); + return Error::success(); } Error GDBRemoteCommunicationServerLLGS::LaunchProcess() { @@ -988,7 +988,7 @@ Error GDBRemoteCommunicationServerLLGS::SetSTDIOFileDescriptor(int fd) { return error; } - return Error(); + return Error::success(); } void GDBRemoteCommunicationServerLLGS::StartSTDIOForwarding() { diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp index c0fbccb3e4f7..07d30803cbb4 100644 --- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp @@ -1252,7 +1252,7 @@ Error ProcessGDBRemote::WillResume() { m_continue_S_tids.clear(); m_jstopinfo_sp.reset(); m_jthreadsinfo_sp.reset(); - return Error(); + return Error::success(); } Error ProcessGDBRemote::DoResume() { @@ -3246,7 +3246,7 @@ Error ProcessGDBRemote::EstablishConnectionIfNeeded( const ProcessInfo &process_info) { // Make sure we aren't already connected? if (m_gdb_comm.IsConnected()) - return Error(); + return Error::success(); PlatformSP platform_sp(GetTarget().GetPlatform()); if (platform_sp && !platform_sp->IsHost()) @@ -4408,7 +4408,7 @@ Error ProcessGDBRemote::GetLoadedModuleList(LoadedModuleInfoList &list) { XMLNode root_element = doc.GetRootElement("library-list-svr4"); if (!root_element) - return Error(); + return Error::success(); // main link map structure llvm::StringRef main_lm = root_element.GetAttributeValue("main-lm"); @@ -4494,7 +4494,7 @@ Error ProcessGDBRemote::GetLoadedModuleList(LoadedModuleInfoList &list) { XMLNode root_element = doc.GetRootElement("library-list"); if (!root_element) - return Error(); + return Error::success(); root_element.ForEachChildElementWithName( "library", [log, &list](const XMLNode &library) -> bool { @@ -4538,7 +4538,7 @@ Error ProcessGDBRemote::GetLoadedModuleList(LoadedModuleInfoList &list) { return Error(0, ErrorType::eErrorTypeGeneric); } - return Error(); + return Error::success(); } lldb::ModuleSP ProcessGDBRemote::LoadModuleAtAddress(const FileSpec &file, @@ -4662,7 +4662,7 @@ Error ProcessGDBRemote::GetFileLoadAddress(const FileSpec &file, // The file is not loaded into the inferior is_loaded = false; load_addr = LLDB_INVALID_ADDRESS; - return Error(); + return Error::success(); } return Error( @@ -4672,7 +4672,7 @@ Error ProcessGDBRemote::GetFileLoadAddress(const FileSpec &file, if (response.IsNormalResponse()) { is_loaded = true; load_addr = response.GetHexMaxU64(false, LLDB_INVALID_ADDRESS); - return Error(); + return Error::success(); } return Error("Unknown error happened during sending the load address packet"); diff --git a/lldb/source/Plugins/Process/mach-core/ProcessMachCore.cpp b/lldb/source/Plugins/Process/mach-core/ProcessMachCore.cpp index f83499cdb233..1b3211778dbe 100644 --- a/lldb/source/Plugins/Process/mach-core/ProcessMachCore.cpp +++ b/lldb/source/Plugins/Process/mach-core/ProcessMachCore.cpp @@ -461,7 +461,7 @@ void ProcessMachCore::RefreshStateAfterStop() { // SetThreadStopInfo (m_last_stop_packet); } -Error ProcessMachCore::DoDestroy() { return Error(); } +Error ProcessMachCore::DoDestroy() { return Error::success(); } //------------------------------------------------------------------ // Process Queries @@ -564,7 +564,7 @@ Error ProcessMachCore::GetMemoryRegionInfo(addr_t load_addr, region_info.SetExecutable(MemoryRegionInfo::eNo); region_info.SetMapped(MemoryRegionInfo::eNo); } - return Error(); + return Error::success(); } region_info.GetRange().SetRangeBase(load_addr); @@ -573,7 +573,7 @@ Error ProcessMachCore::GetMemoryRegionInfo(addr_t load_addr, region_info.SetWritable(MemoryRegionInfo::eNo); region_info.SetExecutable(MemoryRegionInfo::eNo); region_info.SetMapped(MemoryRegionInfo::eNo); - return Error(); + return Error::success(); } void ProcessMachCore::Clear() { m_thread_list.Clear(); } diff --git a/lldb/source/Plugins/Process/minidump/ProcessMinidump.cpp b/lldb/source/Plugins/Process/minidump/ProcessMinidump.cpp index 46d8df8b16f1..5b390d831bcb 100644 --- a/lldb/source/Plugins/Process/minidump/ProcessMinidump.cpp +++ b/lldb/source/Plugins/Process/minidump/ProcessMinidump.cpp @@ -133,7 +133,7 @@ ConstString ProcessMinidump::GetPluginName() { return GetPluginNameStatic(); } uint32_t ProcessMinidump::GetPluginVersion() { return 1; } -Error ProcessMinidump::DoDestroy() { return Error(); } +Error ProcessMinidump::DoDestroy() { return Error::success(); } void ProcessMinidump::RefreshStateAfterStop() { if (!m_active_exception) diff --git a/lldb/source/Target/Platform.cpp b/lldb/source/Target/Platform.cpp index 270400a0e7bc..07d596804b19 100644 --- a/lldb/source/Target/Platform.cpp +++ b/lldb/source/Target/Platform.cpp @@ -172,7 +172,7 @@ Error Platform::GetFileWithUUID(const FileSpec &platform_file, const UUID *uuid_ptr, FileSpec &local_file) { // Default to the local case local_file = platform_file; - return Error(); + return Error::success(); } FileSpecList @@ -1089,7 +1089,7 @@ Error Platform::KillProcess(const lldb::pid_t pid) { "they are controlled by a process plugin"); } Host::Kill(pid, SIGTERM); - return Error(); + return Error::success(); } lldb::ProcessSP @@ -1597,7 +1597,7 @@ Error Platform::GetRemoteSharedModule(const ModuleSpec &module_spec, const auto error = module_resolver(resolved_module_spec); if (error.Fail()) { if (GetCachedSharedModule(resolved_module_spec, module_sp, did_create_ptr)) - return Error(); + return Error::success(); } return error; diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp index 67c1489b499b..60e1e33751da 100644 --- a/lldb/source/Target/Process.cpp +++ b/lldb/source/Target/Process.cpp @@ -3359,7 +3359,7 @@ Error Process::Halt(bool clear_thread_plans, bool use_run_lock) { RestoreProcessEvents(); SetExitStatus(SIGKILL, "Cancelled async attach."); Destroy(false); - return Error(); + return Error::success(); } // Wait for 10 second for the process to stop. @@ -3375,7 +3375,7 @@ Error Process::Halt(bool clear_thread_plans, bool use_run_lock) { BroadcastEvent(event_sp); - return Error(); + return Error::success(); } Error Process::StopForDestroyOrDetach(lldb::EventSP &exit_event_sp) { diff --git a/lldb/source/Target/Thread.cpp b/lldb/source/Target/Thread.cpp index 8e2a9c740d05..4034ed3da6ca 100644 --- a/lldb/source/Target/Thread.cpp +++ b/lldb/source/Target/Thread.cpp @@ -1766,7 +1766,7 @@ Error Thread::JumpToLine(const FileSpec &file, uint32_t line, if (!reg_ctx->SetPC(dest)) return Error("Cannot change PC to target address."); - return Error(); + return Error::success(); } void Thread::DumpUsingSettingsFormat(Stream &strm, uint32_t frame_idx, diff --git a/lldb/source/Utility/ModuleCache.cpp b/lldb/source/Utility/ModuleCache.cpp index 889cd8f94667..c53be9091642 100644 --- a/lldb/source/Utility/ModuleCache.cpp +++ b/lldb/source/Utility/ModuleCache.cpp @@ -70,7 +70,7 @@ Error MakeDirectory(const FileSpec &dir_path) { if (!dir_path.IsDirectory()) return Error("Invalid existing path"); - return Error(); + return Error::success(); } return FileSystem::MakeDirectory(dir_path, eFilePermissionsDirectoryDefault); @@ -141,7 +141,7 @@ Error CreateHostSysRootModuleLink(const FileSpec &root_dir_spec, platform_module_spec.GetPath().c_str()); if (sysroot_module_path_spec.Exists()) { if (!delete_existing) - return Error(); + return Error::success(); DecrementRefExistingModule(root_dir_spec, sysroot_module_path_spec); } @@ -210,7 +210,7 @@ Error ModuleCache::Put(const FileSpec &root_dir_spec, const char *hostname, if (error.Fail()) return Error("Failed to create link to %s: %s", module_file_path.GetPath().c_str(), error.AsCString()); - return Error(); + return Error::success(); } Error ModuleCache::Get(const FileSpec &root_dir_spec, const char *hostname, @@ -221,7 +221,7 @@ Error ModuleCache::Get(const FileSpec &root_dir_spec, const char *hostname, if (find_it != m_loaded_modules.end()) { cached_module_sp = (*find_it).second.lock(); if (cached_module_sp) - return Error(); + return Error::success(); m_loaded_modules.erase(find_it); } @@ -263,7 +263,7 @@ Error ModuleCache::Get(const FileSpec &root_dir_spec, const char *hostname, m_loaded_modules.insert( std::make_pair(module_spec.GetUUID().GetAsString(), cached_module_sp)); - return Error(); + return Error::success(); } Error ModuleCache::GetAndPut(const FileSpec &root_dir_spec, @@ -320,7 +320,7 @@ Error ModuleCache::GetAndPut(const FileSpec &root_dir_spec, // module might // contain the necessary symbols and the debugging is also possible without // a symfile. - return Error(); + return Error::success(); error = Put(root_dir_spec, escaped_hostname.c_str(), module_spec, tmp_download_sym_file_spec, @@ -332,5 +332,5 @@ Error ModuleCache::GetAndPut(const FileSpec &root_dir_spec, FileSpec symfile_spec = GetSymbolFileSpec(cached_module_sp->GetFileSpec()); cached_module_sp->SetSymbolFileFileSpec(symfile_spec); - return Error(); + return Error::success(); } diff --git a/lldb/tools/lldb-server/lldb-platform.cpp b/lldb/tools/lldb-server/lldb-platform.cpp index 21d422c41215..5bbe1cef14a0 100644 --- a/lldb/tools/lldb-server/lldb-platform.cpp +++ b/lldb/tools/lldb-server/lldb-platform.cpp @@ -130,7 +130,7 @@ static Error save_socket_id_to_file(const std::string &socket_id, file_spec.GetPath().c_str(), err_code.message().c_str()); tmp_file_remover.releaseFile(); - return Error(); + return Error::success(); } //---------------------------------------------------------------------- diff --git a/lldb/unittests/Utility/ModuleCacheTest.cpp b/lldb/unittests/Utility/ModuleCacheTest.cpp index 911c278c1626..eea26d1470d8 100644 --- a/lldb/unittests/Utility/ModuleCacheTest.cpp +++ b/lldb/unittests/Utility/ModuleCacheTest.cpp @@ -114,7 +114,7 @@ void ModuleCacheTest::TryGetAndPut(const FileSpec &cache_dir, std::error_code ec = llvm::sys::fs::copy_file( s_test_executable, tmp_download_file_spec.GetCString()); EXPECT_FALSE(ec); - return Error(); + return Error::success(); }, [](const ModuleSP &module_sp, const FileSpec &tmp_download_file_spec) { return Error("Not supported."); diff --git a/llvm/include/llvm/ExecutionEngine/Orc/OrcRemoteTargetClient.h b/llvm/include/llvm/ExecutionEngine/Orc/OrcRemoteTargetClient.h index a922d862976a..d549fc31debf 100644 --- a/llvm/include/llvm/ExecutionEngine/Orc/OrcRemoteTargetClient.h +++ b/llvm/include/llvm/ExecutionEngine/Orc/OrcRemoteTargetClient.h @@ -589,7 +589,7 @@ public: /// Channel is the ChannelT instance to communicate on. It is assumed that /// the channel is ready to be read from and written to. static Expected Create(ChannelT &Channel) { - Error Err; + Error Err = Error::success(); OrcRemoteTargetClient H(Channel, Err); if (Err) return std::move(Err); @@ -808,7 +808,7 @@ private: static Error doNothing() { return Error::success(); } ChannelT &Channel; - Error ExistingError; + Error ExistingError = Error::success(); std::string RemoteTargetTriple; uint32_t RemotePointerSize = 0; uint32_t RemotePageSize = 0; diff --git a/llvm/include/llvm/Support/Error.h b/llvm/include/llvm/Support/Error.h index cdd46a84b5c1..e4f352ab95ec 100644 --- a/llvm/include/llvm/Support/Error.h +++ b/llvm/include/llvm/Support/Error.h @@ -149,14 +149,14 @@ class LLVM_NODISCARD Error { // error. template friend class Expected; -public: +protected: /// Create a success value. Prefer using 'Error::success()' for readability - /// where possible. Error() : Payload(nullptr) { setPtr(nullptr); setChecked(false); } +public: /// Create a success value. This is equivalent to calling the default /// constructor, but should be preferred for readability where possible. static Error success() { return Error(); } diff --git a/llvm/lib/LTO/LTO.cpp b/llvm/lib/LTO/LTO.cpp index b599830d0926..12de8445568d 100644 --- a/llvm/lib/LTO/LTO.cpp +++ b/llvm/lib/LTO/LTO.cpp @@ -437,7 +437,7 @@ Error LTO::addThinLTO(std::unique_ptr Input, assert(ResI == Res.end()); ThinLTO.ModuleMap[MBRef.getBufferIdentifier()] = MBRef; - return Error(); + return Error::success(); } unsigned LTO::getMaxTasks() const { @@ -489,7 +489,7 @@ Error LTO::runRegularLTO(AddStreamFn AddStream) { if (Conf.PreOptModuleHook && !Conf.PreOptModuleHook(0, *RegularLTO.CombinedModule)) - return Error(); + return Error::success(); if (!Conf.CodeGenOnly) { for (const auto &R : GlobalResolutions) { @@ -512,7 +512,7 @@ Error LTO::runRegularLTO(AddStreamFn AddStream) { if (Conf.PostInternalizeModuleHook && !Conf.PostInternalizeModuleHook(0, *RegularLTO.CombinedModule)) - return Error(); + return Error::success(); } return backend(Conf, AddStream, RegularLTO.ParallelCodeGenParallelismLevel, std::move(RegularLTO.CombinedModule)); @@ -593,7 +593,7 @@ public: if (AddStreamFn CacheAddStream = Cache(Task, Key)) return RunThinBackend(CacheAddStream); - return Error(); + return Error::success(); } Error start( @@ -628,7 +628,7 @@ public: MBRef, std::ref(CombinedIndex), std::ref(ImportList), std::ref(ExportList), std::ref(ResolvedODR), std::ref(DefinedGlobals), std::ref(ModuleMap)); - return Error(); + return Error::success(); } Error wait() override { @@ -636,7 +636,7 @@ public: if (Err) return std::move(*Err); else - return Error(); + return Error::success(); } }; @@ -722,10 +722,10 @@ public: if (ShouldEmitImportsFiles) return errorCodeToError( EmitImportsFiles(ModulePath, NewModulePath + ".imports", ImportList)); - return Error(); + return Error::success(); } - Error wait() override { return Error(); } + Error wait() override { return Error::success(); } }; ThinBackend lto::createWriteIndexesThinBackend(std::string OldPrefix, @@ -744,10 +744,10 @@ ThinBackend lto::createWriteIndexesThinBackend(std::string OldPrefix, Error LTO::runThinLTO(AddStreamFn AddStream, NativeObjectCache Cache, bool HasRegularLTO) { if (ThinLTO.ModuleMap.empty()) - return Error(); + return Error::success(); if (Conf.CombinedIndexHook && !Conf.CombinedIndexHook(ThinLTO.CombinedIndex)) - return Error(); + return Error::success(); // Collect for each module the list of function it defines (GUID -> // Summary). diff --git a/llvm/lib/LTO/LTOBackend.cpp b/llvm/lib/LTO/LTOBackend.cpp index fb1cfed96bbe..4643b9af74ac 100644 --- a/llvm/lib/LTO/LTOBackend.cpp +++ b/llvm/lib/LTO/LTOBackend.cpp @@ -105,7 +105,7 @@ Error Config::addSaveTemps(std::string OutputFileName, return true; }; - return Error(); + return Error::success(); } namespace { @@ -302,7 +302,7 @@ Error lto::backend(Config &C, AddStreamFn AddStream, if (!C.CodeGenOnly) if (!opt(C, TM.get(), 0, *Mod, /*IsThinLto=*/false)) - return Error(); + return Error::success(); if (ParallelCodeGenParallelismLevel == 1) { codegen(C, TM.get(), AddStream, 0, *Mod); @@ -310,7 +310,7 @@ Error lto::backend(Config &C, AddStreamFn AddStream, splitCodeGen(C, TM.get(), AddStream, ParallelCodeGenParallelismLevel, std::move(Mod)); } - return Error(); + return Error::success(); } Error lto::thinBackend(Config &Conf, unsigned Task, AddStreamFn AddStream, @@ -329,25 +329,25 @@ Error lto::thinBackend(Config &Conf, unsigned Task, AddStreamFn AddStream, if (Conf.CodeGenOnly) { codegen(Conf, TM.get(), AddStream, Task, Mod); - return Error(); + return Error::success(); } if (Conf.PreOptModuleHook && !Conf.PreOptModuleHook(Task, Mod)) - return Error(); + return Error::success(); renameModuleForThinLTO(Mod, CombinedIndex); thinLTOResolveWeakForLinkerModule(Mod, DefinedGlobals); if (Conf.PostPromoteModuleHook && !Conf.PostPromoteModuleHook(Task, Mod)) - return Error(); + return Error::success(); if (!DefinedGlobals.empty()) thinLTOInternalizeModule(Mod, DefinedGlobals); if (Conf.PostInternalizeModuleHook && !Conf.PostInternalizeModuleHook(Task, Mod)) - return Error(); + return Error::success(); auto ModuleLoader = [&](StringRef Identifier) { assert(Mod.getContext().isODRUniquingDebugTypes() && @@ -363,11 +363,11 @@ Error lto::thinBackend(Config &Conf, unsigned Task, AddStreamFn AddStream, return Err; if (Conf.PostImportModuleHook && !Conf.PostImportModuleHook(Task, Mod)) - return Error(); + return Error::success(); if (!opt(Conf, TM.get(), Task, Mod, /*IsThinLto=*/true)) - return Error(); + return Error::success(); codegen(Conf, TM.get(), AddStream, Task, Mod); - return Error(); + return Error::success(); } diff --git a/llvm/lib/Object/Archive.cpp b/llvm/lib/Object/Archive.cpp index 4684c186fb41..f2021f796d12 100644 --- a/llvm/lib/Object/Archive.cpp +++ b/llvm/lib/Object/Archive.cpp @@ -458,7 +458,7 @@ Expected Archive::Child::getNext() const { return malformedError(Msg + NameOrErr.get()); } - Error Err; + Error Err = Error::success(); Child Ret(Parent, NextLoc, &Err); if (Err) return std::move(Err); @@ -508,7 +508,7 @@ Archive::Child::getAsBinary(LLVMContext *Context) const { } Expected> Archive::create(MemoryBufferRef Source) { - Error Err; + Error Err = Error::success(); std::unique_ptr Ret(new Archive(Source, Err)); if (Err) return std::move(Err); @@ -830,7 +830,7 @@ Expected Archive::Symbol::getMember() const { } const char *Loc = Parent->getData().begin() + Offset; - Error Err; + Error Err = Error::success(); Child C(Parent, Loc, &Err); if (Err) return std::move(Err); diff --git a/llvm/lib/Object/Error.cpp b/llvm/lib/Object/Error.cpp index 578da22c044f..7d43a84f3e0e 100644 --- a/llvm/lib/Object/Error.cpp +++ b/llvm/lib/Object/Error.cpp @@ -79,18 +79,17 @@ const std::error_category &object::object_category() { llvm::Error llvm::object::isNotObjectErrorInvalidFileType(llvm::Error Err) { if (auto Err2 = - handleErrors(std::move(Err), - [](std::unique_ptr M) { - // Try to handle 'M'. If successful, return a success value from - // the handler. - if (M->convertToErrorCode() == object_error::invalid_file_type) - return Error::success(); + handleErrors(std::move(Err), [](std::unique_ptr M) -> Error { + // Try to handle 'M'. If successful, return a success value from + // the handler. + if (M->convertToErrorCode() == object_error::invalid_file_type) + return Error::success(); - // We failed to handle 'M' - return it from the handler. - // This value will be passed back from catchErrors and - // wind up in Err2, where it will be returned from this function. - return Error(std::move(M)); - })) + // We failed to handle 'M' - return it from the handler. + // This value will be passed back from catchErrors and + // wind up in Err2, where it will be returned from this function. + return Error(std::move(M)); + })) return Err2; return Err; } diff --git a/llvm/lib/Object/MachOObjectFile.cpp b/llvm/lib/Object/MachOObjectFile.cpp index ad52235a50df..6650ace08455 100644 --- a/llvm/lib/Object/MachOObjectFile.cpp +++ b/llvm/lib/Object/MachOObjectFile.cpp @@ -1073,7 +1073,7 @@ Expected> MachOObjectFile::create(MemoryBufferRef Object, bool IsLittleEndian, bool Is64Bits, uint32_t UniversalCputype, uint32_t UniversalIndex) { - Error Err; + Error Err = Error::success(); std::unique_ptr Obj( new MachOObjectFile(std::move(Object), IsLittleEndian, Is64Bits, Err, UniversalCputype, diff --git a/llvm/lib/Object/MachOUniversal.cpp b/llvm/lib/Object/MachOUniversal.cpp index c57fdc677f5a..9ab0ae656bff 100644 --- a/llvm/lib/Object/MachOUniversal.cpp +++ b/llvm/lib/Object/MachOUniversal.cpp @@ -107,7 +107,7 @@ void MachOUniversalBinary::anchor() { } Expected> MachOUniversalBinary::create(MemoryBufferRef Source) { - Error Err; + Error Err = Error::success(); std::unique_ptr Ret( new MachOUniversalBinary(Source, Err)); if (Err) diff --git a/llvm/lib/ProfileData/Coverage/CoverageMappingReader.cpp b/llvm/lib/ProfileData/Coverage/CoverageMappingReader.cpp index 1a4b4f590841..a6c7031ccd3d 100644 --- a/llvm/lib/ProfileData/Coverage/CoverageMappingReader.cpp +++ b/llvm/lib/ProfileData/Coverage/CoverageMappingReader.cpp @@ -648,7 +648,7 @@ BinaryCoverageReader::create(std::unique_ptr &ObjectBuffer, StringRef Coverage; uint8_t BytesInAddress; support::endianness Endian; - Error E; + Error E = Error::success(); consumeError(std::move(E)); if (ObjectBuffer->getBuffer().startswith(TestingFormatMagic)) // This is a special format used for testing. diff --git a/llvm/tools/dsymutil/BinaryHolder.cpp b/llvm/tools/dsymutil/BinaryHolder.cpp index 0930b9dda2b7..eabbe8d83065 100644 --- a/llvm/tools/dsymutil/BinaryHolder.cpp +++ b/llvm/tools/dsymutil/BinaryHolder.cpp @@ -100,7 +100,7 @@ ErrorOr> BinaryHolder::GetArchiveMemberBuffers( Buffers.reserve(CurrentArchives.size()); for (const auto &CurrentArchive : CurrentArchives) { - Error Err; + Error Err = Error::success(); for (auto Child : CurrentArchive->children(Err)) { if (auto NameOrErr = Child.getName()) { if (*NameOrErr == Filename) { diff --git a/llvm/tools/llvm-ar/llvm-ar.cpp b/llvm/tools/llvm-ar/llvm-ar.cpp index a59eec9cf9f3..004ef018d610 100644 --- a/llvm/tools/llvm-ar/llvm-ar.cpp +++ b/llvm/tools/llvm-ar/llvm-ar.cpp @@ -423,7 +423,7 @@ static void performReadOperation(ArchiveOperation Operation, bool Filter = !Members.empty(); { - Error Err; + Error Err = Error::success(); for (auto &C : OldArchive->children(Err)) { Expected NameOrErr = C.getName(); failIfError(NameOrErr.takeError()); @@ -551,7 +551,7 @@ computeNewArchiveMembers(ArchiveOperation Operation, int InsertPos = -1; StringRef PosName = sys::path::filename(RelPos); if (OldArchive) { - Error Err; + Error Err = Error::success(); for (auto &Child : OldArchive->children(Err)) { int Pos = Ret.size(); Expected NameOrErr = Child.getName(); @@ -723,7 +723,7 @@ static int performOperation(ArchiveOperation Operation, fail("error opening '" + ArchiveName + "': " + EC.message() + "!"); if (!EC) { - Error Err; + Error Err = Error::success(); object::Archive Archive(Buf.get()->getMemBufferRef(), Err); EC = errorToErrorCode(std::move(Err)); failIfError(EC, @@ -785,7 +785,7 @@ static void runMRIScript() { Archives.push_back(std::move(*LibOrErr)); object::Archive &Lib = *Archives.back(); { - Error Err; + Error Err = Error::success(); for (auto &Member : Lib.children(Err)) addMember(NewMembers, Member); failIfError(std::move(Err)); diff --git a/llvm/tools/llvm-cxxdump/llvm-cxxdump.cpp b/llvm/tools/llvm-cxxdump/llvm-cxxdump.cpp index 518d414c7b92..b10759ad05c0 100644 --- a/llvm/tools/llvm-cxxdump/llvm-cxxdump.cpp +++ b/llvm/tools/llvm-cxxdump/llvm-cxxdump.cpp @@ -490,7 +490,7 @@ static void dumpCXXData(const ObjectFile *Obj) { } static void dumpArchive(const Archive *Arc) { - Error Err; + Error Err = Error::success(); for (auto &ArcC : Arc->children(Err)) { Expected> ChildOrErr = ArcC.getAsBinary(); if (!ChildOrErr) { diff --git a/llvm/tools/llvm-dwp/llvm-dwp.cpp b/llvm/tools/llvm-dwp/llvm-dwp.cpp index b1ec5035038c..5ee620a77b07 100644 --- a/llvm/tools/llvm-dwp/llvm-dwp.cpp +++ b/llvm/tools/llvm-dwp/llvm-dwp.cpp @@ -364,7 +364,7 @@ static Error handleCompressedSection( std::deque> &UncompressedSections, StringRef &Name, StringRef &Contents) { if (!Name.startswith("zdebug_")) - return Error(); + return Error::success(); UncompressedSections.emplace_back(); uint64_t OriginalSize; if (!zlib::isAvailable()) @@ -377,7 +377,7 @@ static Error handleCompressedSection( .str()); Name = Name.substr(1); Contents = UncompressedSections.back(); - return Error(); + return Error::success(); } static Error handleSection( @@ -392,10 +392,10 @@ static Error handleSection( StringRef &AbbrevSection, StringRef &CurCUIndexSection, StringRef &CurTUIndexSection) { if (Section.isBSS()) - return Error(); + return Error::success(); if (Section.isVirtual()) - return Error(); + return Error::success(); StringRef Name; if (std::error_code Err = Section.getName(Name)) @@ -412,7 +412,7 @@ static Error handleSection( auto SectionPair = KnownSections.find(Name); if (SectionPair == KnownSections.end()) - return Error(); + return Error::success(); if (DWARFSectionKind Kind = SectionPair->second.second) { auto Index = Kind - DW_SECT_INFO; @@ -449,7 +449,7 @@ static Error handleSection( Out.SwitchSection(OutSection); Out.EmitBytes(Contents); } - return Error(); + return Error::success(); } static Error @@ -600,7 +600,7 @@ static Error write(MCStreamer &Out, ArrayRef Inputs) { writeIndex(Out, MCOFI.getDwarfCUIndexSection(), ContributionOffsets, IndexEntries); - return Error(); + return Error::success(); } static int error(const Twine &Error, const Twine &Context) { diff --git a/llvm/tools/llvm-nm/llvm-nm.cpp b/llvm/tools/llvm-nm/llvm-nm.cpp index d9e7e1e09114..5e6dbcbf6628 100644 --- a/llvm/tools/llvm-nm/llvm-nm.cpp +++ b/llvm/tools/llvm-nm/llvm-nm.cpp @@ -1113,7 +1113,7 @@ static void dumpSymbolNamesFromFile(std::string &Filename) { } { - Error Err; + Error Err = Error::success(); for (auto &C : A->children(Err)) { Expected> ChildOrErr = C.getAsBinary(&Context); if (!ChildOrErr) { @@ -1178,7 +1178,7 @@ static void dumpSymbolNamesFromFile(std::string &Filename) { } else if (Expected> AOrErr = I->getAsArchive()) { std::unique_ptr &A = *AOrErr; - Error Err; + Error Err = Error::success(); for (auto &C : A->children(Err)) { Expected> ChildOrErr = C.getAsBinary(&Context); @@ -1249,7 +1249,7 @@ static void dumpSymbolNamesFromFile(std::string &Filename) { } else if (Expected> AOrErr = I->getAsArchive()) { std::unique_ptr &A = *AOrErr; - Error Err; + Error Err = Error::success(); for (auto &C : A->children(Err)) { Expected> ChildOrErr = C.getAsBinary(&Context); @@ -1316,7 +1316,7 @@ static void dumpSymbolNamesFromFile(std::string &Filename) { } else if (Expected> AOrErr = I->getAsArchive()) { std::unique_ptr &A = *AOrErr; - Error Err; + Error Err = Error::success(); for (auto &C : A->children(Err)) { Expected> ChildOrErr = C.getAsBinary(&Context); diff --git a/llvm/tools/llvm-objdump/MachODump.cpp b/llvm/tools/llvm-objdump/MachODump.cpp index 67ce0d553242..929e70d8cb57 100644 --- a/llvm/tools/llvm-objdump/MachODump.cpp +++ b/llvm/tools/llvm-objdump/MachODump.cpp @@ -1546,7 +1546,8 @@ static void printArchiveChild(StringRef Filename, const Archive::Child &C, static void printArchiveHeaders(StringRef Filename, Archive *A, bool verbose, bool print_offset, StringRef ArchitectureName = StringRef()) { - Error Err; + Error Err = Error::success(); + ; for (const auto &C : A->children(Err, false)) printArchiveChild(Filename, C, verbose, print_offset, ArchitectureName); @@ -1583,7 +1584,7 @@ void llvm::ParseInputMachO(StringRef Filename) { if (ArchiveHeaders) printArchiveHeaders(Filename, A, !NonVerbose, ArchiveMemberOffsets); - Error Err; + Error Err = Error::success(); for (auto &C : A->children(Err)) { Expected> ChildOrErr = C.getAsBinary(); if (!ChildOrErr) { @@ -1641,7 +1642,7 @@ void llvm::ParseInputMachO(StringRef Filename) { if (ArchiveHeaders) printArchiveHeaders(Filename, A.get(), !NonVerbose, ArchiveMemberOffsets, ArchitectureName); - Error Err; + Error Err = Error::success(); for (auto &C : A->children(Err)) { Expected> ChildOrErr = C.getAsBinary(); if (!ChildOrErr) { @@ -1697,7 +1698,7 @@ void llvm::ParseInputMachO(StringRef Filename) { if (ArchiveHeaders) printArchiveHeaders(Filename, A.get(), !NonVerbose, ArchiveMemberOffsets); - Error Err; + Error Err = Error::success(); for (auto &C : A->children(Err)) { Expected> ChildOrErr = C.getAsBinary(); if (!ChildOrErr) { @@ -1749,7 +1750,7 @@ void llvm::ParseInputMachO(StringRef Filename) { if (ArchiveHeaders) printArchiveHeaders(Filename, A.get(), !NonVerbose, ArchiveMemberOffsets, ArchitectureName); - Error Err; + Error Err = Error::success(); for (auto &C : A->children(Err)) { Expected> ChildOrErr = C.getAsBinary(); if (!ChildOrErr) { diff --git a/llvm/tools/llvm-objdump/llvm-objdump.cpp b/llvm/tools/llvm-objdump/llvm-objdump.cpp index 3f6ef52973fc..920ad4a7dd60 100644 --- a/llvm/tools/llvm-objdump/llvm-objdump.cpp +++ b/llvm/tools/llvm-objdump/llvm-objdump.cpp @@ -1969,7 +1969,7 @@ static void DumpObject(const COFFImportFile *I, const Archive *A) { /// @brief Dump each object file in \a a; static void DumpArchive(const Archive *a) { - Error Err; + Error Err = Error::success(); for (auto &C : a->children(Err)) { Expected> ChildOrErr = C.getAsBinary(); if (!ChildOrErr) { diff --git a/llvm/tools/llvm-readobj/llvm-readobj.cpp b/llvm/tools/llvm-readobj/llvm-readobj.cpp index ede1f0712bdd..afe7521ea893 100644 --- a/llvm/tools/llvm-readobj/llvm-readobj.cpp +++ b/llvm/tools/llvm-readobj/llvm-readobj.cpp @@ -458,7 +458,7 @@ static void dumpObject(const ObjectFile *Obj) { /// @brief Dumps each object file in \a Arc; static void dumpArchive(const Archive *Arc) { - Error Err; + Error Err = Error::success(); for (auto &Child : Arc->children(Err)) { Expected> ChildOrErr = Child.getAsBinary(); if (!ChildOrErr) { diff --git a/llvm/tools/llvm-size/llvm-size.cpp b/llvm/tools/llvm-size/llvm-size.cpp index 1e4c436157c8..a11532a7c98d 100644 --- a/llvm/tools/llvm-size/llvm-size.cpp +++ b/llvm/tools/llvm-size/llvm-size.cpp @@ -542,7 +542,7 @@ static void printFileSectionSizes(StringRef file) { if (Archive *a = dyn_cast(&Bin)) { // This is an archive. Iterate over each member and display its sizes. - Error Err; + Error Err = Error::success(); for (auto &C : a->children(Err)) { Expected> ChildOrErr = C.getAsBinary(); if (!ChildOrErr) { @@ -611,7 +611,7 @@ static void printFileSectionSizes(StringRef file) { std::unique_ptr &UA = *AOrErr; // This is an archive. Iterate over each member and display its // sizes. - Error Err; + Error Err = Error::success(); for (auto &C : UA->children(Err)) { Expected> ChildOrErr = C.getAsBinary(); if (!ChildOrErr) { @@ -700,7 +700,7 @@ static void printFileSectionSizes(StringRef file) { std::unique_ptr &UA = *AOrErr; // This is an archive. Iterate over each member and display its // sizes. - Error Err; + Error Err = Error::success(); for (auto &C : UA->children(Err)) { Expected> ChildOrErr = C.getAsBinary(); if (!ChildOrErr) { @@ -775,7 +775,7 @@ static void printFileSectionSizes(StringRef file) { I->getAsArchive()) { std::unique_ptr &UA = *AOrErr; // This is an archive. Iterate over each member and display its sizes. - Error Err; + Error Err = Error::success(); for (auto &C : UA->children(Err)) { Expected> ChildOrErr = C.getAsBinary(); if (!ChildOrErr) { diff --git a/llvm/tools/llvm-xray/xray-extract.cc b/llvm/tools/llvm-xray/xray-extract.cc index 4fbe5ec35656..e51b64c8ad6e 100644 --- a/llvm/tools/llvm-xray/xray-extract.cc +++ b/llvm/tools/llvm-xray/xray-extract.cc @@ -223,8 +223,8 @@ void InstrumentationMapExtractor::exportAsYAML(raw_ostream &OS) { Out << YAMLSleds; } -static CommandRegistration Unused(&Extract, [] { - Error Err; +static CommandRegistration Unused(&Extract, []() -> Error { + Error Err = Error::success(); xray::InstrumentationMapExtractor Extractor( ExtractInput, InstrumentationMapExtractor::InputFormats::ELF, Err); if (Err) diff --git a/llvm/tools/sancov/sancov.cc b/llvm/tools/sancov/sancov.cc index cea7d76fa2ff..2fbbad11a501 100644 --- a/llvm/tools/sancov/sancov.cc +++ b/llvm/tools/sancov/sancov.cc @@ -821,7 +821,7 @@ static void getObjectCoveragePoints(const object::ObjectFile &O, static void visitObjectFiles(const object::Archive &A, function_ref Fn) { - Error Err; + Error Err = Error::success(); for (auto &C : A.children(Err)) { Expected> ChildOrErr = C.getAsBinary(); failIfError(ChildOrErr); diff --git a/llvm/unittests/Support/ErrorTest.cpp b/llvm/unittests/Support/ErrorTest.cpp index 3d2f2089cf70..7468a857b89d 100644 --- a/llvm/unittests/Support/ErrorTest.cpp +++ b/llvm/unittests/Support/ErrorTest.cpp @@ -82,12 +82,14 @@ protected: char CustomSubError::ID = 0; -static Error handleCustomError(const CustomError &CE) { return Error(); } +static Error handleCustomError(const CustomError &CE) { + return Error::success(); +} static void handleCustomErrorVoid(const CustomError &CE) {} static Error handleCustomErrorUP(std::unique_ptr CE) { - return Error(); + return Error::success(); } static void handleCustomErrorUPVoid(std::unique_ptr CE) {}