From 343523d040d1ede65a35d8a6d514b0f7c198a3f2 Mon Sep 17 00:00:00 2001 From: Kazu Hirata Date: Sun, 4 Dec 2022 16:51:25 -0800 Subject: [PATCH] [lldb] Use std::nullopt instead of None (NFC) This patch mechanically replaces None with std::nullopt where the compiler would warn if None were deprecated. The intent is to reduce the amount of manual work required in migrating from Optional to std::optional. This is part of an effort to migrate from llvm::Optional to std::optional: https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716 --- .../lldb/Breakpoint/BreakpointResolver.h | 2 +- .../Breakpoint/BreakpointResolverFileLine.h | 2 +- lldb/include/lldb/Core/DataFileCache.h | 12 +-- lldb/include/lldb/Core/Debugger.h | 6 +- lldb/include/lldb/Core/SourceLocationSpec.h | 2 +- lldb/include/lldb/Host/File.h | 8 +- .../lldb/Interpreter/CommandInterpreter.h | 2 +- lldb/include/lldb/Interpreter/CommandObject.h | 2 +- .../Interpreter/ScriptedProcessInterface.h | 8 +- lldb/include/lldb/Symbol/TypeSystem.h | 2 +- lldb/include/lldb/Target/LanguageRuntime.h | 2 +- lldb/include/lldb/Target/Platform.h | 4 +- lldb/include/lldb/Target/Target.h | 2 +- lldb/include/lldb/Target/TraceDumper.h | 4 +- lldb/include/lldb/Utility/Event.h | 2 +- lldb/include/lldb/Utility/Predicate.h | 8 +- lldb/include/lldb/Utility/Timeout.h | 2 +- lldb/source/API/SBCommandInterpreter.cpp | 4 +- lldb/source/API/SBCommunication.cpp | 2 +- lldb/source/API/SBExpressionOptions.cpp | 4 +- lldb/source/API/SBListener.cpp | 6 +- lldb/source/API/SBPlatform.cpp | 4 +- lldb/source/API/SBThread.cpp | 2 +- lldb/source/Breakpoint/BreakpointID.cpp | 8 +- .../Breakpoint/BreakpointResolverFileLine.cpp | 2 +- .../BreakpointResolverFileRegex.cpp | 2 +- .../Commands/CommandObjectExpression.cpp | 4 +- .../Commands/CommandObjectMultiword.cpp | 6 +- lldb/source/Commands/CommandObjectThread.cpp | 16 ++-- .../Commands/CommandObjectWatchpoint.cpp | 2 +- lldb/source/Core/Debugger.cpp | 4 +- lldb/source/Core/DumpDataExtractor.cpp | 18 ++--- lldb/source/Core/IOHandler.cpp | 4 +- lldb/source/Core/Module.cpp | 4 +- lldb/source/Core/SourceLocationSpec.cpp | 4 +- lldb/source/Core/ThreadedCommunication.cpp | 2 +- lldb/source/Expression/IRExecutionUnit.cpp | 4 +- lldb/source/Host/common/Editline.cpp | 4 +- lldb/source/Host/common/File.cpp | 4 +- lldb/source/Host/common/HostInfoBase.cpp | 2 +- .../Host/common/NativeProcessProtocol.cpp | 6 +- lldb/source/Host/common/Terminal.cpp | 2 +- lldb/source/Host/linux/Host.cpp | 2 +- lldb/source/Host/linux/HostInfoLinux.cpp | 2 +- lldb/source/Host/posix/HostInfoPosix.cpp | 8 +- lldb/source/Interpreter/CommandHistory.cpp | 14 ++-- .../source/Interpreter/CommandInterpreter.cpp | 8 +- lldb/source/Interpreter/ScriptInterpreter.cpp | 2 +- .../Disassembler/LLVMC/DisassemblerLLVMC.cpp | 2 +- .../Clang/ClangExpressionParser.cpp | 4 +- .../Clang/ClangPersistentVariables.cpp | 4 +- .../Clang/CppModuleConfiguration.cpp | 4 +- .../Clang/CxxModuleHandler.cpp | 16 ++-- .../RISCV/EmulateInstructionRISCV.cpp | 16 ++-- .../CPlusPlus/CPlusPlusNameParser.cpp | 24 +++--- .../ObjC/ObjCLanguageRuntime.cpp | 10 +-- .../ObjectContainerMachOFileset.cpp | 2 +- .../ObjectFile/Breakpad/BreakpadRecords.cpp | 74 +++++++++---------- .../Breakpad/ObjectFileBreakpad.cpp | 2 +- .../Plugins/ObjectFile/ELF/ObjectFileELF.cpp | 8 +- .../ObjectFile/PECOFF/ObjectFilePECOFF.cpp | 2 +- .../ObjectFile/wasm/ObjectFileWasm.cpp | 8 +- .../gdb-server/PlatformRemoteGDBServer.cpp | 8 +- .../Process/Linux/IntelPTCollector.cpp | 6 +- .../Process/Linux/IntelPTMultiCoreTrace.cpp | 6 +- .../Process/Linux/IntelPTMultiCoreTrace.h | 2 +- .../Process/Linux/IntelPTSingleBufferTrace.h | 4 +- .../Linux/IntelPTThreadTraceCollection.cpp | 6 +- .../Process/Linux/NativeProcessLinux.cpp | 4 +- .../Linux/NativeRegisterContextLinux.h | 4 +- lldb/source/Plugins/Process/Linux/Perf.cpp | 4 +- lldb/source/Plugins/Process/Linux/Perf.h | 2 +- .../Process/POSIX/NativeProcessELF.cpp | 2 +- .../Plugins/Process/Utility/AuxVector.cpp | 2 +- .../Process/Utility/StopInfoMachException.cpp | 4 +- .../Process/elf-core/RegisterUtilities.cpp | 2 +- .../GDBRemoteCommunicationClient.cpp | 50 ++++++------- .../GDBRemoteCommunicationServerLLGS.cpp | 4 +- .../Process/gdb-remote/ProcessGDBRemote.cpp | 2 +- .../Process/minidump/MinidumpParser.cpp | 14 ++-- .../Process/minidump/MinidumpTypes.cpp | 4 +- .../Breakpad/SymbolFileBreakpad.cpp | 6 +- .../SymbolFile/Breakpad/SymbolFileBreakpad.h | 2 +- .../Plugins/SymbolFile/DWARF/DIERef.cpp | 4 +- lldb/source/Plugins/SymbolFile/DWARF/DIERef.h | 2 +- .../SymbolFile/DWARF/DWARFASTParser.cpp | 2 +- .../SymbolFile/DWARF/DWARFASTParserClang.cpp | 2 +- .../Plugins/SymbolFile/DWARF/DWARFBaseDIE.cpp | 4 +- .../Plugins/SymbolFile/DWARF/DWARFContext.cpp | 16 ++-- .../SymbolFile/DWARF/DWARFDebugInfoEntry.cpp | 2 +- .../SymbolFile/DWARF/DWARFFormValue.cpp | 2 +- .../Plugins/SymbolFile/DWARF/DWARFUnit.h | 4 +- .../SymbolFile/DWARF/DebugNamesDWARFIndex.cpp | 6 +- .../SymbolFile/DWARF/HashedNameToDIE.h | 2 +- .../SymbolFile/DWARF/SymbolFileDWARF.cpp | 8 +- .../SymbolFile/DWARF/SymbolFileDWARF.h | 2 +- .../DWARF/SymbolFileDWARFDebugMap.cpp | 2 +- .../NativePDB/DWARFLocationExpression.cpp | 4 +- .../SymbolFile/NativePDB/PdbAstBuilder.cpp | 10 +-- .../Plugins/SymbolFile/NativePDB/PdbIndex.cpp | 2 +- .../NativePDB/SymbolFileNativePDB.cpp | 24 +++--- .../Plugins/SymbolFile/PDB/PDBASTParser.cpp | 2 +- .../Plugins/SymbolFile/PDB/SymbolFilePDB.cpp | 2 +- .../SymbolFile/Symtab/SymbolFileSymtab.cpp | 2 +- .../Plugins/TraceExporter/common/TraceHTR.cpp | 4 +- .../ctf/CommandObjectThreadTraceExportCTF.cpp | 2 +- .../TypeSystem/Clang/TypeSystemClang.cpp | 18 ++--- .../TypeSystem/Clang/TypeSystemClang.h | 2 +- lldb/source/Symbol/CompileUnit.cpp | 5 +- lldb/source/Symbol/CompilerType.cpp | 2 +- lldb/source/Symbol/DWARFCallFrameInfo.cpp | 4 +- lldb/source/Symbol/Function.cpp | 2 +- lldb/source/Symbol/PostfixExpression.cpp | 6 +- lldb/source/Symbol/SymbolFileOnDemand.cpp | 2 +- lldb/source/Symbol/TypeSystem.cpp | 4 +- lldb/source/Symbol/UnwindPlan.cpp | 4 +- lldb/source/Symbol/UnwindTable.cpp | 2 +- lldb/source/Target/MemoryTagMap.cpp | 2 +- lldb/source/Target/PathMappingList.cpp | 2 +- lldb/source/Target/Platform.cpp | 2 +- lldb/source/Target/Process.cpp | 14 ++-- lldb/source/Target/ProcessTrace.cpp | 2 +- lldb/source/Target/RemoteAwarePlatform.cpp | 4 +- lldb/source/Target/Statistics.cpp | 2 +- lldb/source/Target/Target.cpp | 7 +- lldb/source/Target/Trace.cpp | 11 +-- lldb/source/Target/TraceDumper.cpp | 4 +- lldb/source/Utility/FileSpec.cpp | 2 +- .../Utility/StringExtractorGDBRemote.cpp | 4 +- lldb/source/Utility/UriParser.cpp | 10 +-- lldb/source/Utility/UserIDResolver.cpp | 8 +- lldb/tools/lldb-server/lldb-platform.cpp | 2 +- lldb/tools/lldb-vscode/JSONUtils.h | 11 +-- lldb/tools/lldb-vscode/ProgressEvent.cpp | 8 +- 134 files changed, 400 insertions(+), 396 deletions(-) diff --git a/lldb/include/lldb/Breakpoint/BreakpointResolver.h b/lldb/include/lldb/Breakpoint/BreakpointResolver.h index 7aa43b9f45df..0e99346f1511 100644 --- a/lldb/include/lldb/Breakpoint/BreakpointResolver.h +++ b/lldb/include/lldb/Breakpoint/BreakpointResolver.h @@ -205,7 +205,7 @@ protected: void SetSCMatchesByLine(SearchFilter &filter, SymbolContextList &sc_list, bool skip_prologue, llvm::StringRef log_ident, uint32_t line = 0, - llvm::Optional column = llvm::None); + llvm::Optional column = std::nullopt); void SetSCMatchesByLine(SearchFilter &, SymbolContextList &, bool, const char *) = delete; diff --git a/lldb/include/lldb/Breakpoint/BreakpointResolverFileLine.h b/lldb/include/lldb/Breakpoint/BreakpointResolverFileLine.h index bc1fdff92b8d..b3ccba546122 100644 --- a/lldb/include/lldb/Breakpoint/BreakpointResolverFileLine.h +++ b/lldb/include/lldb/Breakpoint/BreakpointResolverFileLine.h @@ -24,7 +24,7 @@ public: BreakpointResolverFileLine( const lldb::BreakpointSP &bkpt, lldb::addr_t offset, bool skip_prologue, const SourceLocationSpec &location_spec, - llvm::Optional removed_prefix_opt = llvm::None); + llvm::Optional removed_prefix_opt = std::nullopt); static BreakpointResolver * CreateFromStructuredData(const lldb::BreakpointSP &bkpt, diff --git a/lldb/include/lldb/Core/DataFileCache.h b/lldb/include/lldb/Core/DataFileCache.h index b6cc3cd8f1cc..b6c7123ccb7a 100644 --- a/lldb/include/lldb/Core/DataFileCache.h +++ b/lldb/include/lldb/Core/DataFileCache.h @@ -107,13 +107,13 @@ private: /// it is out of date. struct CacheSignature { /// UUID of object file or module. - llvm::Optional m_uuid = llvm::None; + llvm::Optional m_uuid = std::nullopt; /// Modification time of file on disk. - llvm::Optional m_mod_time = llvm::None; + llvm::Optional m_mod_time = std::nullopt; /// If this describes a .o file with a BSD archive, the BSD archive's /// modification time will be in m_mod_time, and the .o file's modification /// time will be in this m_obj_mod_time. - llvm::Optional m_obj_mod_time = llvm::None; + llvm::Optional m_obj_mod_time = std::nullopt; CacheSignature() = default; @@ -124,9 +124,9 @@ struct CacheSignature { CacheSignature(lldb_private::ObjectFile *objfile); void Clear() { - m_uuid = llvm::None; - m_mod_time = llvm::None; - m_obj_mod_time = llvm::None; + m_uuid = std::nullopt; + m_mod_time = std::nullopt; + m_obj_mod_time = std::nullopt; } /// Return true only if the CacheSignature is valid. diff --git a/lldb/include/lldb/Core/Debugger.h b/lldb/include/lldb/Core/Debugger.h index c1394c1d0ebd..2f630763cc71 100644 --- a/lldb/include/lldb/Core/Debugger.h +++ b/lldb/include/lldb/Core/Debugger.h @@ -402,7 +402,7 @@ public: /// ensure the given warning is only broadcast once. static void ReportWarning(std::string message, - llvm::Optional debugger_id = llvm::None, + llvm::Optional debugger_id = std::nullopt, std::once_flag *once = nullptr); /// Report error events. @@ -424,7 +424,7 @@ public: /// ensure the given error is only broadcast once. static void ReportError(std::string message, - llvm::Optional debugger_id = llvm::None, + llvm::Optional debugger_id = std::nullopt, std::once_flag *once = nullptr); /// Report info events. @@ -444,7 +444,7 @@ public: /// ensure the given info is only logged once. static void ReportInfo(std::string message, - llvm::Optional debugger_id = llvm::None, + llvm::Optional debugger_id = std::nullopt, std::once_flag *once = nullptr); static void ReportSymbolChange(const ModuleSpec &module_spec); diff --git a/lldb/include/lldb/Core/SourceLocationSpec.h b/lldb/include/lldb/Core/SourceLocationSpec.h index 808931186dba..3b58b2818d22 100644 --- a/lldb/include/lldb/Core/SourceLocationSpec.h +++ b/lldb/include/lldb/Core/SourceLocationSpec.h @@ -47,7 +47,7 @@ public: /// Whether to look for an exact match. /// explicit SourceLocationSpec(FileSpec file_spec, uint32_t line, - llvm::Optional column = llvm::None, + llvm::Optional column = std::nullopt, bool check_inlines = false, bool exact_match = false); diff --git a/lldb/include/lldb/Host/File.h b/lldb/include/lldb/Host/File.h index 85e8185ebc96..6d4d7dd8904a 100644 --- a/lldb/include/lldb/Host/File.h +++ b/lldb/include/lldb/Host/File.h @@ -437,10 +437,10 @@ private: class SerialPort : public NativeFile { public: struct Options { - llvm::Optional BaudRate = llvm::None; - llvm::Optional Parity = llvm::None; - llvm::Optional ParityCheck = llvm::None; - llvm::Optional StopBits = llvm::None; + llvm::Optional BaudRate = std::nullopt; + llvm::Optional Parity = std::nullopt; + llvm::Optional ParityCheck = std::nullopt; + llvm::Optional StopBits = std::nullopt; }; // Obtain Options corresponding to the passed URL query string diff --git a/lldb/include/lldb/Interpreter/CommandInterpreter.h b/lldb/include/lldb/Interpreter/CommandInterpreter.h index a72800b5409c..82f46469df61 100644 --- a/lldb/include/lldb/Interpreter/CommandInterpreter.h +++ b/lldb/include/lldb/Interpreter/CommandInterpreter.h @@ -627,7 +627,7 @@ public: /// \return \b true if the session transcript was successfully written to /// disk, \b false otherwise. bool SaveTranscript(CommandReturnObject &result, - llvm::Optional output_file = llvm::None); + llvm::Optional output_file = std::nullopt); FileSpec GetCurrentSourceDir(); diff --git a/lldb/include/lldb/Interpreter/CommandObject.h b/lldb/include/lldb/Interpreter/CommandObject.h index fc058eb50a5e..03f5aef7d5d6 100644 --- a/lldb/include/lldb/Interpreter/CommandObject.h +++ b/lldb/include/lldb/Interpreter/CommandObject.h @@ -279,7 +279,7 @@ public: /// If the string is empty, the command won't be allow repeating. virtual llvm::Optional GetRepeatCommand(Args ¤t_command_args, uint32_t index) { - return llvm::None; + return std::nullopt; } bool HasOverrideCallback() const { diff --git a/lldb/include/lldb/Interpreter/ScriptedProcessInterface.h b/lldb/include/lldb/Interpreter/ScriptedProcessInterface.h index 2795c2f487df..dfa22570f2c7 100644 --- a/lldb/include/lldb/Interpreter/ScriptedProcessInterface.h +++ b/lldb/include/lldb/Interpreter/ScriptedProcessInterface.h @@ -63,7 +63,7 @@ public: virtual bool IsAlive() { return true; } virtual llvm::Optional GetScriptedThreadPluginName() { - return llvm::None; + return std::nullopt; } virtual StructuredData::DictionarySP GetMetadata() { return {}; } @@ -86,11 +86,11 @@ public: virtual lldb::tid_t GetThreadID() { return LLDB_INVALID_THREAD_ID; } - virtual llvm::Optional GetName() { return llvm::None; } + virtual llvm::Optional GetName() { return std::nullopt; } virtual lldb::StateType GetState() { return lldb::eStateInvalid; } - virtual llvm::Optional GetQueue() { return llvm::None; } + virtual llvm::Optional GetQueue() { return std::nullopt; } virtual StructuredData::DictionarySP GetStopReason() { return {}; } @@ -99,7 +99,7 @@ public: virtual StructuredData::DictionarySP GetRegisterInfo() { return {}; } virtual llvm::Optional GetRegisterContext() { - return llvm::None; + return std::nullopt; } virtual StructuredData::ArraySP GetExtendedInfo() { return {}; } diff --git a/lldb/include/lldb/Symbol/TypeSystem.h b/lldb/include/lldb/Symbol/TypeSystem.h index c9e727faba66..69682d121f2f 100644 --- a/lldb/include/lldb/Symbol/TypeSystem.h +++ b/lldb/include/lldb/Symbol/TypeSystem.h @@ -572,7 +572,7 @@ private: /// \return The found type system or an error. llvm::Expected GetTypeSystemForLanguage( lldb::LanguageType language, - llvm::Optional create_callback = llvm::None); + llvm::Optional create_callback = std::nullopt); }; } // namespace lldb_private diff --git a/lldb/include/lldb/Target/LanguageRuntime.h b/lldb/include/lldb/Target/LanguageRuntime.h index 0cdb02a44901..502a7e359939 100644 --- a/lldb/include/lldb/Target/LanguageRuntime.h +++ b/lldb/include/lldb/Target/LanguageRuntime.h @@ -151,7 +151,7 @@ public: virtual bool IsAllowedRuntimeValue(ConstString name) { return false; } virtual llvm::Optional GetRuntimeType(CompilerType base_type) { - return llvm::None; + return std::nullopt; } void ModulesDidLoad(const ModuleList &module_list) override {} diff --git a/lldb/include/lldb/Target/Platform.h b/lldb/include/lldb/Target/Platform.h index 5f8cd467847d..ba105ffda038 100644 --- a/lldb/include/lldb/Target/Platform.h +++ b/lldb/include/lldb/Target/Platform.h @@ -232,11 +232,11 @@ public: virtual bool GetRemoteOSVersion() { return false; } virtual llvm::Optional GetRemoteOSBuildString() { - return llvm::None; + return std::nullopt; } virtual llvm::Optional GetRemoteOSKernelDescription() { - return llvm::None; + return std::nullopt; } // Remote Platform subclasses need to override this function diff --git a/lldb/include/lldb/Target/Target.h b/lldb/include/lldb/Target/Target.h index b2f72cd644a8..9e016a970cfa 100644 --- a/lldb/include/lldb/Target/Target.h +++ b/lldb/include/lldb/Target/Target.h @@ -455,7 +455,7 @@ private: lldb::DynamicValueType m_use_dynamic = lldb::eNoDynamicValues; Timeout m_timeout = default_timeout; - Timeout m_one_thread_timeout = llvm::None; + Timeout m_one_thread_timeout = std::nullopt; lldb::ExpressionCancelCallback m_cancel_callback = nullptr; void *m_cancel_callback_baton = nullptr; // If m_pound_line_file is not empty and m_pound_line_line is non-zero, use diff --git a/lldb/include/lldb/Target/TraceDumper.h b/lldb/include/lldb/Target/TraceDumper.h index 59f887878888..bc79705c6dd0 100644 --- a/lldb/include/lldb/Target/TraceDumper.h +++ b/lldb/include/lldb/Target/TraceDumper.h @@ -39,10 +39,10 @@ struct TraceDumperOptions { /// For each instruction, print the instruction kind. bool show_control_flow_kind = false; /// Optional custom id to start traversing from. - llvm::Optional id = llvm::None; + llvm::Optional id = std::nullopt; /// Optional number of instructions to skip from the starting position /// of the cursor. - llvm::Optional skip = llvm::None; + llvm::Optional skip = std::nullopt; }; /// Class used to dump the instructions of a \a TraceCursor using its current diff --git a/lldb/include/lldb/Utility/Event.h b/lldb/include/lldb/Utility/Event.h index f533fc5c47fa..8d2d94fe3fdb 100644 --- a/lldb/include/lldb/Utility/Event.h +++ b/lldb/include/lldb/Utility/Event.h @@ -112,7 +112,7 @@ public: ConstString GetFlavor() const override { return GetFlavorString(); } - bool WaitForEventReceived(const Timeout &timeout = llvm::None) { + bool WaitForEventReceived(const Timeout &timeout = std::nullopt) { return m_predicate.WaitForValueEqualTo(true, timeout); } diff --git a/lldb/include/lldb/Utility/Predicate.h b/lldb/include/lldb/Utility/Predicate.h index e5d80acb11bc..3496aff8ee95 100644 --- a/lldb/include/lldb/Utility/Predicate.h +++ b/lldb/include/lldb/Utility/Predicate.h @@ -127,7 +127,7 @@ public: } if (m_condition.wait_for(lock, *timeout, RealCond)) return m_value; - return llvm::None; + return std::nullopt; } /// Wait for \a m_value to be equal to \a value. /// @@ -152,9 +152,9 @@ public: /// true if the \a m_value is equal to \a value, false otherwise (timeout /// occurred). bool WaitForValueEqualTo(T value, - const Timeout &timeout = llvm::None) { + const Timeout &timeout = std::nullopt) { return WaitFor([&value](T current) { return value == current; }, timeout) != - llvm::None; + std::nullopt; } /// Wait for \a m_value to not be equal to \a value. @@ -180,7 +180,7 @@ public: /// m_value if m_value != value, None otherwise (timeout occurred). llvm::Optional WaitForValueNotEqualTo(T value, - const Timeout &timeout = llvm::None) { + const Timeout &timeout = std::nullopt) { return WaitFor([&value](T current) { return value != current; }, timeout); } diff --git a/lldb/include/lldb/Utility/Timeout.h b/lldb/include/lldb/Utility/Timeout.h index f656138eb44b..a873c4776f63 100644 --- a/lldb/include/lldb/Utility/Timeout.h +++ b/lldb/include/lldb/Utility/Timeout.h @@ -41,7 +41,7 @@ public: template ::type> Timeout(const Timeout &other) - : Base(other ? Base(Dur(*other)) : llvm::None) {} + : Base(other ? Base(Dur(*other)) : std::nullopt) {} template ::type> diff --git a/lldb/source/API/SBCommandInterpreter.cpp b/lldb/source/API/SBCommandInterpreter.cpp index aa46f1085dc9..8457b78e1599 100644 --- a/lldb/source/API/SBCommandInterpreter.cpp +++ b/lldb/source/API/SBCommandInterpreter.cpp @@ -45,7 +45,7 @@ public: m_backend(backend) { m_auto_repeat_command = auto_repeat_command == nullptr - ? llvm::None + ? std::nullopt : llvm::Optional(auto_repeat_command); // We don't know whether any given command coming from this interface takes // arguments or not so here we're just disabling the basic args check. @@ -62,7 +62,7 @@ public: llvm::Optional GetRepeatCommand(Args ¤t_command_args, uint32_t index) override { if (!m_auto_repeat_command) - return llvm::None; + return std::nullopt; else return m_auto_repeat_command; } diff --git a/lldb/source/API/SBCommunication.cpp b/lldb/source/API/SBCommunication.cpp index b9c8b498a38e..f93898718be6 100644 --- a/lldb/source/API/SBCommunication.cpp +++ b/lldb/source/API/SBCommunication.cpp @@ -107,7 +107,7 @@ size_t SBCommunication::Read(void *dst, size_t dst_len, uint32_t timeout_usec, size_t bytes_read = 0; Timeout timeout = timeout_usec == UINT32_MAX - ? Timeout(llvm::None) + ? Timeout(std::nullopt) : std::chrono::microseconds(timeout_usec); if (m_opaque) bytes_read = m_opaque->Read(dst, dst_len, timeout, status, nullptr); diff --git a/lldb/source/API/SBExpressionOptions.cpp b/lldb/source/API/SBExpressionOptions.cpp index 191e38fe5cfc..d07acbc0aa2d 100644 --- a/lldb/source/API/SBExpressionOptions.cpp +++ b/lldb/source/API/SBExpressionOptions.cpp @@ -94,7 +94,7 @@ uint32_t SBExpressionOptions::GetTimeoutInMicroSeconds() const { void SBExpressionOptions::SetTimeoutInMicroSeconds(uint32_t timeout) { LLDB_INSTRUMENT_VA(this, timeout); - m_opaque_up->SetTimeout(timeout == 0 ? Timeout(llvm::None) + m_opaque_up->SetTimeout(timeout == 0 ? Timeout(std::nullopt) : std::chrono::microseconds(timeout)); } @@ -110,7 +110,7 @@ void SBExpressionOptions::SetOneThreadTimeoutInMicroSeconds(uint32_t timeout) { LLDB_INSTRUMENT_VA(this, timeout); m_opaque_up->SetOneThreadTimeout(timeout == 0 - ? Timeout(llvm::None) + ? Timeout(std::nullopt) : std::chrono::microseconds(timeout)); } diff --git a/lldb/source/API/SBListener.cpp b/lldb/source/API/SBListener.cpp index a7008dc5224e..a4c847bec857 100644 --- a/lldb/source/API/SBListener.cpp +++ b/lldb/source/API/SBListener.cpp @@ -132,7 +132,7 @@ bool SBListener::WaitForEvent(uint32_t timeout_secs, SBEvent &event) { bool success = false; if (m_opaque_sp) { - Timeout timeout(llvm::None); + Timeout timeout(std::nullopt); if (timeout_secs != UINT32_MAX) { assert(timeout_secs != 0); // Take this out after all calls with timeout // set to zero have been removed.... @@ -156,7 +156,7 @@ bool SBListener::WaitForEventForBroadcaster(uint32_t num_seconds, LLDB_INSTRUMENT_VA(this, num_seconds, broadcaster, event); if (m_opaque_sp && broadcaster.IsValid()) { - Timeout timeout(llvm::None); + Timeout timeout(std::nullopt); if (num_seconds != UINT32_MAX) timeout = std::chrono::seconds(num_seconds); EventSP event_sp; @@ -176,7 +176,7 @@ bool SBListener::WaitForEventForBroadcasterWithType( LLDB_INSTRUMENT_VA(this, num_seconds, broadcaster, event_type_mask, event); if (m_opaque_sp && broadcaster.IsValid()) { - Timeout timeout(llvm::None); + Timeout timeout(std::nullopt); if (num_seconds != UINT32_MAX) timeout = std::chrono::seconds(num_seconds); EventSP event_sp; diff --git a/lldb/source/API/SBPlatform.cpp b/lldb/source/API/SBPlatform.cpp index 2a8e963c15a7..807d0085c7bc 100644 --- a/lldb/source/API/SBPlatform.cpp +++ b/lldb/source/API/SBPlatform.cpp @@ -69,7 +69,7 @@ struct PlatformShellCommand { std::string m_output; int m_status = 0; int m_signo = 0; - Timeout> m_timeout = llvm::None; + Timeout> m_timeout = std::nullopt; }; // SBPlatformConnectOptions SBPlatformConnectOptions::SBPlatformConnectOptions(const char *url) @@ -261,7 +261,7 @@ void SBPlatformShellCommand::SetTimeoutSeconds(uint32_t sec) { LLDB_INSTRUMENT_VA(this, sec); if (sec == UINT32_MAX) - m_opaque_ptr->m_timeout = llvm::None; + m_opaque_ptr->m_timeout = std::nullopt; else m_opaque_ptr->m_timeout = std::chrono::seconds(sec); } diff --git a/lldb/source/API/SBThread.cpp b/lldb/source/API/SBThread.cpp index a08cb741814b..616f047f6888 100644 --- a/lldb/source/API/SBThread.cpp +++ b/lldb/source/API/SBThread.cpp @@ -837,7 +837,7 @@ SBError SBThread::StepOverUntil(lldb::SBFrame &sb_frame, const bool stop_other_threads = false; // TODO: Handle SourceLocationSpec column information SourceLocationSpec location_spec( - step_file_spec, line, /*column=*/llvm::None, /*check_inlines=*/true, + step_file_spec, line, /*column=*/std::nullopt, /*check_inlines=*/true, /*exact_match=*/false); SymbolContextList sc_list; diff --git a/lldb/source/Breakpoint/BreakpointID.cpp b/lldb/source/Breakpoint/BreakpointID.cpp index 245cf7913335..048f09aa6b6e 100644 --- a/lldb/source/Breakpoint/BreakpointID.cpp +++ b/lldb/source/Breakpoint/BreakpointID.cpp @@ -68,21 +68,21 @@ BreakpointID::ParseCanonicalReference(llvm::StringRef input) { break_id_t loc_id = LLDB_INVALID_BREAK_ID; if (input.empty()) - return llvm::None; + return std::nullopt; // If it doesn't start with an integer, it's not valid. if (input.consumeInteger(0, bp_id)) - return llvm::None; + return std::nullopt; // period is optional, but if it exists, it must be followed by a number. if (input.consume_front(".")) { if (input.consumeInteger(0, loc_id)) - return llvm::None; + return std::nullopt; } // And at the end, the entire string must have been consumed. if (!input.empty()) - return llvm::None; + return std::nullopt; return BreakpointID(bp_id, loc_id); } diff --git a/lldb/source/Breakpoint/BreakpointResolverFileLine.cpp b/lldb/source/Breakpoint/BreakpointResolverFileLine.cpp index 9e1fbcb70dc1..59335951ecf8 100644 --- a/lldb/source/Breakpoint/BreakpointResolverFileLine.cpp +++ b/lldb/source/Breakpoint/BreakpointResolverFileLine.cpp @@ -210,7 +210,7 @@ void BreakpointResolverFileLine::DeduceSourceMapping( return a; } } - return llvm::None; + return std::nullopt; }; FileSpec request_file = m_location_spec.GetFileSpec(); diff --git a/lldb/source/Breakpoint/BreakpointResolverFileRegex.cpp b/lldb/source/Breakpoint/BreakpointResolverFileRegex.cpp index 4a11d82ecc6e..cb3ee5fb7427 100644 --- a/lldb/source/Breakpoint/BreakpointResolverFileRegex.cpp +++ b/lldb/source/Breakpoint/BreakpointResolverFileRegex.cpp @@ -109,7 +109,7 @@ Searcher::CallbackReturn BreakpointResolverFileRegex::SearchCallback( SymbolContextList sc_list; // TODO: Handle SourceLocationSpec column information SourceLocationSpec location_spec(cu_file_spec, line_matches[i], - /*column=*/llvm::None, + /*column=*/std::nullopt, /*check_inlines=*/false, m_exact_match); cu->ResolveSymbolContext(location_spec, eSymbolContextEverything, sc_list); // Find all the function names: diff --git a/lldb/source/Commands/CommandObjectExpression.cpp b/lldb/source/Commands/CommandObjectExpression.cpp index be306f20881d..b01e39f4ce3c 100644 --- a/lldb/source/Commands/CommandObjectExpression.cpp +++ b/lldb/source/Commands/CommandObjectExpression.cpp @@ -374,7 +374,7 @@ CommandObjectExpression::GetEvalOptions(const Target &target) { if (m_command_options.timeout > 0) options.SetTimeout(std::chrono::microseconds(m_command_options.timeout)); else - options.SetTimeout(llvm::None); + options.SetTimeout(std::nullopt); return options; } @@ -540,7 +540,7 @@ GetExprOptions(ExecutionContext &ctx, if (command_options.timeout > 0) expr_options.SetTimeout(std::chrono::microseconds(command_options.timeout)); else - expr_options.SetTimeout(llvm::None); + expr_options.SetTimeout(std::nullopt); return expr_options; } diff --git a/lldb/source/Commands/CommandObjectMultiword.cpp b/lldb/source/Commands/CommandObjectMultiword.cpp index e4fdb7365e72..8a815e46ffd2 100644 --- a/lldb/source/Commands/CommandObjectMultiword.cpp +++ b/lldb/source/Commands/CommandObjectMultiword.cpp @@ -295,11 +295,11 @@ CommandObjectMultiword::GetRepeatCommand(Args ¤t_command_args, uint32_t index) { index++; if (current_command_args.GetArgumentCount() <= index) - return llvm::None; + return std::nullopt; CommandObject *sub_command_object = GetSubcommandObject(current_command_args[index].ref()); if (sub_command_object == nullptr) - return llvm::None; + return std::nullopt; return sub_command_object->GetRepeatCommand(current_command_args, index); } @@ -426,7 +426,7 @@ CommandObjectProxy::GetRepeatCommand(Args ¤t_command_args, CommandObject *proxy_command = GetProxyCommandObject(); if (proxy_command) return proxy_command->GetRepeatCommand(current_command_args, index); - return llvm::None; + return std::nullopt; } llvm::StringRef CommandObjectProxy::GetUnsupportedError() { diff --git a/lldb/source/Commands/CommandObjectThread.cpp b/lldb/source/Commands/CommandObjectThread.cpp index 5e817635bbe6..47ae5968748c 100644 --- a/lldb/source/Commands/CommandObjectThread.cpp +++ b/lldb/source/Commands/CommandObjectThread.cpp @@ -147,21 +147,21 @@ public: if (arg_string.equals("-c") || count_opt.startswith(arg_string)) { idx++; if (idx == num_entries) - return llvm::None; + return std::nullopt; count_idx = idx; if (copy_args[idx].ref().getAsInteger(0, count_val)) - return llvm::None; + return std::nullopt; } else if (arg_string.equals("-s") || start_opt.startswith(arg_string)) { idx++; if (idx == num_entries) - return llvm::None; + return std::nullopt; start_idx = idx; if (copy_args[idx].ref().getAsInteger(0, start_val)) - return llvm::None; + return std::nullopt; } } if (count_idx == 0) - return llvm::None; + return std::nullopt; std::string new_start_val = llvm::formatv("{0}", start_val + count_val); if (start_idx == 0) { @@ -172,7 +172,7 @@ public: } std::string repeat_command; if (!copy_args.GetQuotedCommandString(repeat_command)) - return llvm::None; + return std::nullopt; return repeat_command; } @@ -2149,7 +2149,7 @@ public: void OptionParsingStarting(ExecutionContext *execution_context) override { m_dumper_options = {}; - m_output_file = llvm::None; + m_output_file = std::nullopt; } llvm::ArrayRef GetDefinitions() override { @@ -2321,7 +2321,7 @@ public: void OptionParsingStarting(ExecutionContext *execution_context) override { m_count = kDefaultCount; m_continue = false; - m_output_file = llvm::None; + m_output_file = std::nullopt; m_dumper_options = {}; } diff --git a/lldb/source/Commands/CommandObjectWatchpoint.cpp b/lldb/source/Commands/CommandObjectWatchpoint.cpp index f87a171daca6..29f780092978 100644 --- a/lldb/source/Commands/CommandObjectWatchpoint.cpp +++ b/lldb/source/Commands/CommandObjectWatchpoint.cpp @@ -1083,7 +1083,7 @@ protected: options.SetUnwindOnError(true); options.SetKeepInMemory(false); options.SetTryAllThreads(true); - options.SetTimeout(llvm::None); + options.SetTimeout(std::nullopt); ExpressionResults expr_result = target->EvaluateExpression(expr, frame, valobj_sp, options); diff --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp index 8afd215a1a91..b3d3f7e6a9ff 100644 --- a/lldb/source/Core/Debugger.cpp +++ b/lldb/source/Core/Debugger.cpp @@ -1732,7 +1732,7 @@ lldb::thread_result_t Debugger::DefaultEventHandler() { bool done = false; while (!done) { EventSP event_sp; - if (listener_sp->GetEvent(event_sp, llvm::None)) { + if (listener_sp->GetEvent(event_sp, std::nullopt)) { if (event_sp) { Broadcaster *broadcaster = event_sp->GetBroadcaster(); if (broadcaster) { @@ -1827,7 +1827,7 @@ bool Debugger::StartEventHandlerThread() { // event, we just need to wait an infinite amount of time for it (nullptr // timeout as the first parameter) lldb::EventSP event_sp; - listener_sp->GetEvent(event_sp, llvm::None); + listener_sp->GetEvent(event_sp, std::nullopt); } return m_event_handler_thread.IsJoinable(); } diff --git a/lldb/source/Core/DumpDataExtractor.cpp b/lldb/source/Core/DumpDataExtractor.cpp index ec98d6266241..85b0dd2d943a 100644 --- a/lldb/source/Core/DumpDataExtractor.cpp +++ b/lldb/source/Core/DumpDataExtractor.cpp @@ -54,7 +54,7 @@ static llvm::Optional GetAPInt(const DataExtractor &data, lldb::offset_t *offset_ptr, lldb::offset_t byte_size) { if (byte_size == 0) - return llvm::None; + return std::nullopt; llvm::SmallVector uint64_array; lldb::offset_t bytes_left = byte_size; @@ -92,7 +92,7 @@ static llvm::Optional GetAPInt(const DataExtractor &data, *offset_ptr += byte_size; return llvm::APInt(byte_size * 8, llvm::ArrayRef(uint64_array)); } - return llvm::None; + return std::nullopt; } static lldb::offset_t DumpAPInt(Stream *s, const DataExtractor &data, @@ -244,21 +244,21 @@ GetMemoryTags(lldb::addr_t addr, size_t length, assert(addr != LLDB_INVALID_ADDRESS); if (!exe_scope) - return llvm::None; + return std::nullopt; TargetSP target_sp = exe_scope->CalculateTarget(); if (!target_sp) - return llvm::None; + return std::nullopt; ProcessSP process_sp = target_sp->CalculateProcess(); if (!process_sp) - return llvm::None; + return std::nullopt; llvm::Expected tag_manager_or_err = process_sp->GetMemoryTagManager(); if (!tag_manager_or_err) { llvm::consumeError(tag_manager_or_err.takeError()); - return llvm::None; + return std::nullopt; } MemoryRegionInfos memory_regions; @@ -272,10 +272,10 @@ GetMemoryTags(lldb::addr_t addr, size_t length, // for an error. if (!tagged_ranges_or_err) { llvm::consumeError(tagged_ranges_or_err.takeError()); - return llvm::None; + return std::nullopt; } if (tagged_ranges_or_err->empty()) - return llvm::None; + return std::nullopt; MemoryTagMap memory_tag_map(*tag_manager_or_err); for (const MemoryTagManager::TagRange &range : *tagged_ranges_or_err) { @@ -289,7 +289,7 @@ GetMemoryTags(lldb::addr_t addr, size_t length, } if (memory_tag_map.Empty()) - return llvm::None; + return std::nullopt; return memory_tag_map; } diff --git a/lldb/source/Core/IOHandler.cpp b/lldb/source/Core/IOHandler.cpp index 9d8c6aadcc99..597c423b01a7 100644 --- a/lldb/source/Core/IOHandler.cpp +++ b/lldb/source/Core/IOHandler.cpp @@ -330,7 +330,7 @@ void IOHandlerEditline::TerminalSizeChanged() { static Optional SplitLine(std::string &line_buffer) { size_t pos = line_buffer.find('\n'); if (pos == std::string::npos) - return None; + return std::nullopt; std::string line = std::string(StringRef(line_buffer.c_str(), pos).rtrim("\n\r")); line_buffer = line_buffer.substr(pos + 1); @@ -341,7 +341,7 @@ static Optional SplitLine(std::string &line_buffer) { // it as a line anyway. static Optional SplitLineEOF(std::string &line_buffer) { if (llvm::all_of(line_buffer, llvm::isSpace)) - return None; + return std::nullopt; std::string line = std::move(line_buffer); line_buffer.clear(); return line; diff --git a/lldb/source/Core/Module.cpp b/lldb/source/Core/Module.cpp index 63b79b3b71d8..4060e04e9663 100644 --- a/lldb/source/Core/Module.cpp +++ b/lldb/source/Core/Module.cpp @@ -596,7 +596,7 @@ uint32_t Module::ResolveSymbolContextsForFileSpec( if (SymbolFile *symbols = GetSymbolFile()) { // TODO: Handle SourceLocationSpec column information - SourceLocationSpec location_spec(file_spec, line, /*column=*/llvm::None, + SourceLocationSpec location_spec(file_spec, line, /*column=*/std::nullopt, check_inlines, /*exact_match=*/false); symbols->ResolveSymbolContext(location_spec, resolve_scope, sc_list); @@ -937,7 +937,7 @@ void Module::FindAddressesForLine(const lldb::TargetSP target_sp, SearchFilterByModule filter(target_sp, m_file); // TODO: Handle SourceLocationSpec column information - SourceLocationSpec location_spec(file, line, /*column=*/llvm::None, + SourceLocationSpec location_spec(file, line, /*column=*/std::nullopt, /*check_inlines=*/true, /*exact_match=*/false); AddressResolverFileLine resolver(location_spec); diff --git a/lldb/source/Core/SourceLocationSpec.cpp b/lldb/source/Core/SourceLocationSpec.cpp index c83d2d89370d..b132d98c5027 100644 --- a/lldb/source/Core/SourceLocationSpec.cpp +++ b/lldb/source/Core/SourceLocationSpec.cpp @@ -69,13 +69,13 @@ std::string SourceLocationSpec::GetString() const { llvm::Optional SourceLocationSpec::GetLine() const { uint32_t line = m_declaration.GetLine(); if (line == 0 || line == LLDB_INVALID_LINE_NUMBER) - return llvm::None; + return std::nullopt; return line; } llvm::Optional SourceLocationSpec::GetColumn() const { uint16_t column = m_declaration.GetColumn(); if (column == LLDB_INVALID_COLUMN_NUMBER) - return llvm::None; + return std::nullopt; return column; } diff --git a/lldb/source/Core/ThreadedCommunication.cpp b/lldb/source/Core/ThreadedCommunication.cpp index bc4c6e0214ef..0ce97586f09f 100644 --- a/lldb/source/Core/ThreadedCommunication.cpp +++ b/lldb/source/Core/ThreadedCommunication.cpp @@ -362,7 +362,7 @@ void ThreadedCommunication::SynchronizeWithReadThread() { // Wait for the synchronization event. EventSP event_sp; - listener_sp->GetEvent(event_sp, llvm::None); + listener_sp->GetEvent(event_sp, std::nullopt); } void ThreadedCommunication::SetConnection( diff --git a/lldb/source/Expression/IRExecutionUnit.cpp b/lldb/source/Expression/IRExecutionUnit.cpp index 6b710084faf7..16114db6089d 100644 --- a/lldb/source/Expression/IRExecutionUnit.cpp +++ b/lldb/source/Expression/IRExecutionUnit.cpp @@ -704,7 +704,7 @@ public: llvm::Optional Resolve(SymbolContextList &sc_list) { if (sc_list.IsEmpty()) - return llvm::None; + return std::nullopt; lldb::addr_t load_address = LLDB_INVALID_ADDRESS; @@ -758,7 +758,7 @@ public: if (m_symbol_was_missing_weak) return 0; - return llvm::None; + return std::nullopt; } lldb::addr_t GetBestInternalLoadAddress() const { diff --git a/lldb/source/Host/common/Editline.cpp b/lldb/source/Host/common/Editline.cpp index c46e69d9be7f..608c5253d466 100644 --- a/lldb/source/Host/common/Editline.cpp +++ b/lldb/source/Host/common/Editline.cpp @@ -582,12 +582,12 @@ int Editline::GetCharacter(EditLineGetCharType *c) { // interrupted. m_output_mutex.unlock(); int read_count = - m_input_connection.Read(&ch, 1, llvm::None, status, nullptr); + m_input_connection.Read(&ch, 1, std::nullopt, status, nullptr); m_output_mutex.lock(); if (m_editor_status == EditorStatus::Interrupted) { while (read_count > 0 && status == lldb::eConnectionStatusSuccess) read_count = - m_input_connection.Read(&ch, 1, llvm::None, status, nullptr); + m_input_connection.Read(&ch, 1, std::nullopt, status, nullptr); lldbassert(status == lldb::eConnectionStatusInterrupted); return 0; } diff --git a/lldb/source/Host/common/File.cpp b/lldb/source/Host/common/File.cpp index ce5283a61375..5c69373db22c 100644 --- a/lldb/source/Host/common/File.cpp +++ b/lldb/source/Host/common/File.cpp @@ -783,7 +783,7 @@ SerialPort::OptionsFromURL(llvm::StringRef urlqs) { .Case("odd", Terminal::Parity::Odd) .Case("mark", Terminal::Parity::Mark) .Case("space", Terminal::Parity::Space) - .Default(llvm::None); + .Default(std::nullopt); if (!serial_options.Parity) return llvm::createStringError( llvm::inconvertibleErrorCode(), @@ -798,7 +798,7 @@ SerialPort::OptionsFromURL(llvm::StringRef urlqs) { // "mark" mode is not currently supported as it requires special // input processing // .Case("mark", Terminal::ParityCheck::Mark) - .Default(llvm::None); + .Default(std::nullopt); if (!serial_options.ParityCheck) return llvm::createStringError( llvm::inconvertibleErrorCode(), diff --git a/lldb/source/Host/common/HostInfoBase.cpp b/lldb/source/Host/common/HostInfoBase.cpp index 9a7b77c19de1..18fb3814c891 100644 --- a/lldb/source/Host/common/HostInfoBase.cpp +++ b/lldb/source/Host/common/HostInfoBase.cpp @@ -113,7 +113,7 @@ HostInfoBase::ParseArchitectureKind(llvm::StringRef kind) { .Case(LLDB_ARCH_DEFAULT, eArchKindDefault) .Case(LLDB_ARCH_DEFAULT_32BIT, eArchKind32) .Case(LLDB_ARCH_DEFAULT_64BIT, eArchKind64) - .Default(llvm::None); + .Default(std::nullopt); } FileSpec HostInfoBase::GetShlibDir() { diff --git a/lldb/source/Host/common/NativeProcessProtocol.cpp b/lldb/source/Host/common/NativeProcessProtocol.cpp index 21f382da2f22..ef8475a8732a 100644 --- a/lldb/source/Host/common/NativeProcessProtocol.cpp +++ b/lldb/source/Host/common/NativeProcessProtocol.cpp @@ -70,7 +70,7 @@ llvm::Optional NativeProcessProtocol::GetExitStatus() { if (m_state == lldb::eStateExited) return m_exit_status; - return llvm::None; + return std::nullopt; } bool NativeProcessProtocol::SetExitStatus(WaitStatus status, @@ -136,7 +136,7 @@ NativeProcessProtocol::GetHardwareDebugSupportInfo() const { const_cast(this)->GetThreadAtIndex(0)); if (!thread) { LLDB_LOG(log, "failed to find a thread to grab a NativeRegisterContext!"); - return llvm::None; + return std::nullopt; } NativeRegisterContext ®_ctx = thread->GetRegisterContext(); @@ -245,7 +245,7 @@ Status NativeProcessProtocol::SetHardwareBreakpoint(lldb::addr_t addr, // Exit here if target does not have required hardware breakpoint capability. auto hw_debug_cap = GetHardwareDebugSupportInfo(); - if (hw_debug_cap == llvm::None || hw_debug_cap->first == 0 || + if (hw_debug_cap == std::nullopt || hw_debug_cap->first == 0 || hw_debug_cap->first <= m_hw_breakpoints_map.size()) return Status("Target does not have required no of hardware breakpoints"); diff --git a/lldb/source/Host/common/Terminal.cpp b/lldb/source/Host/common/Terminal.cpp index 5da5ee8f1468..5a6fca95987b 100644 --- a/lldb/source/Host/common/Terminal.cpp +++ b/lldb/source/Host/common/Terminal.cpp @@ -264,7 +264,7 @@ static llvm::Optional baudRateToConst(unsigned int baud_rate) { return B4000000; #endif default: - return llvm::None; + return std::nullopt; } } #endif diff --git a/lldb/source/Host/linux/Host.cpp b/lldb/source/Host/linux/Host.cpp index 2196b8ed5a3f..2f8b9c94e419 100644 --- a/lldb/source/Host/linux/Host.cpp +++ b/lldb/source/Host/linux/Host.cpp @@ -324,6 +324,6 @@ llvm::Optional lldb_private::getPIDForTID(lldb::pid_t tid) { if (!GetStatusInfo(tid, process_info, state, tracerpid, tgid) || tgid == LLDB_INVALID_PROCESS_ID) - return llvm::None; + return std::nullopt; return tgid; } diff --git a/lldb/source/Host/linux/HostInfoLinux.cpp b/lldb/source/Host/linux/HostInfoLinux.cpp index 837b103a64b0..e7a136c7c4d5 100644 --- a/lldb/source/Host/linux/HostInfoLinux.cpp +++ b/lldb/source/Host/linux/HostInfoLinux.cpp @@ -71,7 +71,7 @@ llvm::Optional HostInfoLinux::GetOSBuildString() { ::memset(&un, 0, sizeof(utsname)); if (uname(&un) < 0) - return llvm::None; + return std::nullopt; return std::string(un.release); } diff --git a/lldb/source/Host/posix/HostInfoPosix.cpp b/lldb/source/Host/posix/HostInfoPosix.cpp index 8718e90b3241..e11463041669 100644 --- a/lldb/source/Host/posix/HostInfoPosix.cpp +++ b/lldb/source/Host/posix/HostInfoPosix.cpp @@ -41,7 +41,7 @@ bool HostInfoPosix::GetHostname(std::string &s) { llvm::Optional HostInfoPosix::GetOSKernelDescription() { struct utsname un; if (uname(&un) < 0) - return llvm::None; + return std::nullopt; return std::string(un.version); } @@ -85,13 +85,13 @@ static llvm::Optional GetPassword(id_t uid) { return PasswdEntry{user_info_ptr->pw_name, user_info_ptr->pw_shell}; } #endif - return llvm::None; + return std::nullopt; } llvm::Optional PosixUserIDResolver::DoGetUserName(id_t uid) { if (llvm::Optional password = GetPassword(uid)) return password->username; - return llvm::None; + return std::nullopt; } llvm::Optional PosixUserIDResolver::DoGetGroupName(id_t gid) { @@ -113,7 +113,7 @@ llvm::Optional PosixUserIDResolver::DoGetGroupName(id_t gid) { return std::string(group_info_ptr->gr_name); } #endif - return llvm::None; + return std::nullopt; } static llvm::ManagedStatic g_user_id_resolver; diff --git a/lldb/source/Interpreter/CommandHistory.cpp b/lldb/source/Interpreter/CommandHistory.cpp index 8f399840b802..425939fb2092 100644 --- a/lldb/source/Interpreter/CommandHistory.cpp +++ b/lldb/source/Interpreter/CommandHistory.cpp @@ -27,14 +27,14 @@ llvm::Optional CommandHistory::FindString(llvm::StringRef input_str) const { std::lock_guard guard(m_mutex); if (input_str.size() < 2) - return llvm::None; + return std::nullopt; if (input_str[0] != g_repeat_char) - return llvm::None; + return std::nullopt; if (input_str[1] == g_repeat_char) { if (m_history.empty()) - return llvm::None; + return std::nullopt; return llvm::StringRef(m_history.back()); } @@ -43,15 +43,15 @@ CommandHistory::FindString(llvm::StringRef input_str) const { size_t idx = 0; if (input_str.front() == '-') { if (input_str.drop_front(1).getAsInteger(0, idx)) - return llvm::None; + return std::nullopt; if (idx >= m_history.size()) - return llvm::None; + return std::nullopt; idx = m_history.size() - idx; } else { if (input_str.getAsInteger(0, idx)) - return llvm::None; + return std::nullopt; if (idx >= m_history.size()) - return llvm::None; + return std::nullopt; } return llvm::StringRef(m_history[idx]); diff --git a/lldb/source/Interpreter/CommandInterpreter.cpp b/lldb/source/Interpreter/CommandInterpreter.cpp index ac7bd4bf1fca..180ff9cb9ed5 100644 --- a/lldb/source/Interpreter/CommandInterpreter.cpp +++ b/lldb/source/Interpreter/CommandInterpreter.cpp @@ -1764,7 +1764,7 @@ Status CommandInterpreter::PreprocessCommand(std::string &command) { options.SetIgnoreBreakpoints(true); options.SetKeepInMemory(false); options.SetTryAllThreads(true); - options.SetTimeout(llvm::None); + options.SetTimeout(std::nullopt); ExpressionResults expr_result = target.EvaluateExpression(expr_str.c_str(), exe_ctx.GetFramePtr(), @@ -2113,14 +2113,14 @@ void CommandInterpreter::HandleCompletion(CompletionRequest &request) { llvm::Optional CommandInterpreter::GetAutoSuggestionForCommand(llvm::StringRef line) { if (line.empty()) - return llvm::None; + return std::nullopt; const size_t s = m_command_history.GetSize(); for (int i = s - 1; i >= 0; --i) { llvm::StringRef entry = m_command_history.GetStringAtIndex(i); if (entry.consume_front(line)) return entry.str(); } - return llvm::None; + return std::nullopt; } void CommandInterpreter::UpdatePrompt(llvm::StringRef new_prompt) { @@ -3192,7 +3192,7 @@ bool CommandInterpreter::IOHandlerInterrupt(IOHandler &io_handler) { bool CommandInterpreter::SaveTranscript( CommandReturnObject &result, llvm::Optional output_file) { - if (output_file == llvm::None || output_file->empty()) { + if (output_file == std::nullopt || output_file->empty()) { std::string now = llvm::to_string(std::chrono::system_clock::now()); std::replace(now.begin(), now.end(), ' ', '_'); const std::string file_name = "lldb_session_" + now + ".log"; diff --git a/lldb/source/Interpreter/ScriptInterpreter.cpp b/lldb/source/Interpreter/ScriptInterpreter.cpp index bc8a542afc87..082075554562 100644 --- a/lldb/source/Interpreter/ScriptInterpreter.cpp +++ b/lldb/source/Interpreter/ScriptInterpreter.cpp @@ -91,7 +91,7 @@ llvm::Optional ScriptInterpreter::GetOpaqueTypeFromSBMemoryRegionInfo( const lldb::SBMemoryRegionInfo &mem_region) const { if (!mem_region.m_opaque_up) - return llvm::None; + return std::nullopt; return *mem_region.m_opaque_up.get(); } diff --git a/lldb/source/Plugins/Disassembler/LLVMC/DisassemblerLLVMC.cpp b/lldb/source/Plugins/Disassembler/LLVMC/DisassemblerLLVMC.cpp index b4cdfec25113..b49738623f48 100644 --- a/lldb/source/Plugins/Disassembler/LLVMC/DisassemblerLLVMC.cpp +++ b/lldb/source/Plugins/Disassembler/LLVMC/DisassemblerLLVMC.cpp @@ -266,7 +266,7 @@ InstructionLengthDecode(const uint8_t *inst_bytes, int bytes_len, // in `src/pt_ild.c` while (!prefix_done) { if (op_idx >= bytes_len) - return llvm::None; + return std::nullopt; ret.primary_opcode = inst_bytes[op_idx]; switch (ret.primary_opcode) { diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp index 84ce21f5ddd1..2386946161dc 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp @@ -921,9 +921,9 @@ private: // We also filter some internal lldb identifiers here. The user // shouldn't see these. if (llvm::StringRef(ToInsert).startswith("$__lldb_")) - return llvm::None; + return std::nullopt; if (ToInsert.empty()) - return llvm::None; + return std::nullopt; // Merge the suggested Token into the existing command line to comply // with the kind of result the lldb API expects. std::string CompletionSuggestion = diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.cpp index 93a33edfae95..5f7bb1262f8c 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.cpp @@ -74,14 +74,14 @@ ClangPersistentVariables::GetCompilerTypeFromPersistentDecl( PersistentDecl p = m_persistent_decls.lookup(type_name.GetCString()); if (p.m_decl == nullptr) - return llvm::None; + return std::nullopt; if (clang::TypeDecl *tdecl = llvm::dyn_cast(p.m_decl)) { opaque_compiler_type_t t = static_cast( const_cast(tdecl->getTypeForDecl())); return CompilerType(p.m_context, t); } - return llvm::None; + return std::nullopt; } void ClangPersistentVariables::RegisterPersistentDecl(ConstString name, diff --git a/lldb/source/Plugins/ExpressionParser/Clang/CppModuleConfiguration.cpp b/lldb/source/Plugins/ExpressionParser/Clang/CppModuleConfiguration.cpp index 245f307d4007..65ad74862467 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/CppModuleConfiguration.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/CppModuleConfiguration.cpp @@ -50,10 +50,10 @@ getTargetIncludePaths(const llvm::Triple &triple) { static llvm::Optional guessIncludePath(llvm::StringRef path_to_file, llvm::StringRef pattern) { if (pattern.empty()) - return llvm::None; + return std::nullopt; size_t pos = path_to_file.find(pattern); if (pos == llvm::StringRef::npos) - return llvm::None; + return std::nullopt; return path_to_file.substr(0, pos + pattern.size()); } diff --git a/lldb/source/Plugins/ExpressionParser/Clang/CxxModuleHandler.cpp b/lldb/source/Plugins/ExpressionParser/Clang/CxxModuleHandler.cpp index 9453cdc3a451..199cef5592bf 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/CxxModuleHandler.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/CxxModuleHandler.cpp @@ -186,21 +186,21 @@ llvm::Optional CxxModuleHandler::tryInstantiateStdTemplate(Decl *d) { // If we don't have a template to instiantiate, then there is nothing to do. auto td = dyn_cast(d); if (!td) - return llvm::None; + return std::nullopt; // We only care about templates in the std namespace. if (!td->getDeclContext()->isStdNamespace()) - return llvm::None; + return std::nullopt; // We have a list of supported template names. if (!m_supported_templates.contains(td->getName())) - return llvm::None; + return std::nullopt; // Early check if we even support instantiating this template. We do this // before we import anything into the target AST. auto &foreign_args = td->getTemplateInstantiationArgs(); if (!templateArgsAreSupported(foreign_args.asArray())) - return llvm::None; + return std::nullopt; // Find the local DeclContext that corresponds to the DeclContext of our // decl we want to import. @@ -211,7 +211,7 @@ llvm::Optional CxxModuleHandler::tryInstantiateStdTemplate(Decl *d) { "Got error while searching equal local DeclContext for decl " "'{1}':\n{0}", td->getName()); - return llvm::None; + return std::nullopt; } // Look up the template in our local context. @@ -224,7 +224,7 @@ llvm::Optional CxxModuleHandler::tryInstantiateStdTemplate(Decl *d) { break; } if (!new_class_template) - return llvm::None; + return std::nullopt; // Import the foreign template arguments. llvm::SmallVector imported_args; @@ -236,7 +236,7 @@ llvm::Optional CxxModuleHandler::tryInstantiateStdTemplate(Decl *d) { llvm::Expected type = m_importer->Import(arg.getAsType()); if (!type) { LLDB_LOG_ERROR(log, type.takeError(), "Couldn't import type: {0}"); - return llvm::None; + return std::nullopt; } imported_args.push_back(TemplateArgument(*type)); break; @@ -247,7 +247,7 @@ llvm::Optional CxxModuleHandler::tryInstantiateStdTemplate(Decl *d) { m_importer->Import(arg.getIntegralType()); if (!type) { LLDB_LOG_ERROR(log, type.takeError(), "Couldn't import type: {0}"); - return llvm::None; + return std::nullopt; } imported_args.push_back( TemplateArgument(d->getASTContext(), integral, *type)); diff --git a/lldb/source/Plugins/Instruction/RISCV/EmulateInstructionRISCV.cpp b/lldb/source/Plugins/Instruction/RISCV/EmulateInstructionRISCV.cpp index 7c29bce14771..862c8f57b7ab 100644 --- a/lldb/source/Plugins/Instruction/RISCV/EmulateInstructionRISCV.cpp +++ b/lldb/source/Plugins/Instruction/RISCV/EmulateInstructionRISCV.cpp @@ -39,7 +39,7 @@ static llvm::Optional> zipOpt(llvm::Optional &&...ts) { return llvm::Optional>( std::make_tuple(std::move(*ts)...)); else - return llvm::None; + return std::nullopt; } // The funct3 is the type of compare in B instructions. @@ -134,7 +134,7 @@ llvm::Optional Rs::Read(EmulateInstructionRISCV &emulator) { RegisterValue value; return emulator.ReadRegister(eRegisterKindLLDB, lldbReg, value) ? llvm::Optional(value.GetAsUInt64()) - : llvm::None; + : std::nullopt; } llvm::Optional Rs::ReadI32(EmulateInstructionRISCV &emulator) { @@ -157,7 +157,7 @@ llvm::Optional Rs::ReadAPFloat(EmulateInstructionRISCV &emulator, uint32_t lldbReg = FPREncodingToLLDB(rs); RegisterValue value; if (!emulator.ReadRegister(eRegisterKindLLDB, lldbReg, value)) - return llvm::None; + return std::nullopt; uint64_t bits = value.GetAsUInt64(); llvm::APInt api(64, bits, false); return llvm::APFloat(isDouble ? llvm::APFloat(api.bitsToDouble()) @@ -251,9 +251,9 @@ static std::enable_if_t || is_amo_bit_op || is_amo_swap || AtomicAddr(EmulateInstructionRISCV &emulator, I inst, unsigned int align) { return inst.rs1.Read(emulator) .transform([&](uint64_t rs1) { - return rs1 % align == 0 ? llvm::Optional(rs1) : llvm::None; + return rs1 % align == 0 ? llvm::Optional(rs1) : std::nullopt; }) - .value_or(llvm::None); + .value_or(std::nullopt); } template @@ -575,7 +575,7 @@ llvm::Optional EmulateInstructionRISCV::Decode(uint32_t inst) { } LLDB_LOGF(log, "EmulateInstructionRISCV::%s: inst(0x%x) was unsupported", __FUNCTION__, inst); - return llvm::None; + return std::nullopt; } class Executor { @@ -1467,7 +1467,7 @@ llvm::Optional EmulateInstructionRISCV::ReadInstructionAt(lldb::addr_t addr) { return ReadMem(addr) .transform([&](uint32_t inst) { return Decode(inst); }) - .value_or(llvm::None); + .value_or(std::nullopt); } bool EmulateInstructionRISCV::ReadInstruction() { @@ -1490,7 +1490,7 @@ llvm::Optional EmulateInstructionRISCV::ReadPC() { bool success = false; auto addr = ReadRegisterUnsigned(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_PC, LLDB_INVALID_ADDRESS, &success); - return success ? llvm::Optional(addr) : llvm::None; + return success ? llvm::Optional(addr) : std::nullopt; } bool EmulateInstructionRISCV::WritePC(lldb::addr_t pc) { diff --git a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusNameParser.cpp b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusNameParser.cpp index 70d8652f40cf..419e1d7c5e4f 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusNameParser.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusNameParser.cpp @@ -23,7 +23,7 @@ namespace tok = clang::tok; Optional CPlusPlusNameParser::ParseAsFunctionDefinition() { m_next_token_index = 0; - Optional result(None); + Optional result(std::nullopt); // Try to parse the name as function without a return type specified e.g. // main(int, char*[]) @@ -44,7 +44,7 @@ Optional CPlusPlusNameParser::ParseAsFunctionDefinition() { // e.g. int main(int, char*[]) result = ParseFunctionImpl(true); if (HasMoreTokens()) - return None; + return std::nullopt; return result; } @@ -52,9 +52,9 @@ Optional CPlusPlusNameParser::ParseAsFullName() { m_next_token_index = 0; Optional name_ranges = ParseFullNameImpl(); if (!name_ranges) - return None; + return std::nullopt; if (HasMoreTokens()) - return None; + return std::nullopt; ParsedName result; result.basename = GetTextForRange(name_ranges.value().basename_range); result.context = GetTextForRange(name_ranges.value().context_range); @@ -111,7 +111,7 @@ CPlusPlusNameParser::ParseFunctionImpl(bool expect_return_type) { size_t return_start = GetCurrentPosition(); // Consume return type if it's expected. if (!ConsumeToken(tok::kw_auto) && !ConsumeTypename()) - return None; + return std::nullopt; size_t return_end = GetCurrentPosition(); result.return_type = GetTextForRange(Range(return_start, return_end)); @@ -119,12 +119,12 @@ CPlusPlusNameParser::ParseFunctionImpl(bool expect_return_type) { auto maybe_name = ParseFullNameImpl(); if (!maybe_name) { - return None; + return std::nullopt; } size_t argument_start = GetCurrentPosition(); if (!ConsumeArguments()) { - return None; + return std::nullopt; } size_t qualifiers_start = GetCurrentPosition(); @@ -155,7 +155,7 @@ CPlusPlusNameParser::ParseFuncPtr(bool expect_return_type) { if (expect_return_type) { // Consume return type. if (!ConsumeTypename()) - return None; + return std::nullopt; } // Step 2: @@ -165,9 +165,9 @@ CPlusPlusNameParser::ParseFuncPtr(bool expect_return_type) { // Leaves us with: // (*func(long))(int))(float) if (!ConsumeToken(tok::l_paren)) - return None; + return std::nullopt; if (!ConsumePtrsAndRefs()) - return None; + return std::nullopt; // Step 3: // @@ -214,7 +214,7 @@ CPlusPlusNameParser::ParseFuncPtr(bool expect_return_type) { return maybe_inner_function_ptr_name; } - return None; + return std::nullopt; } bool CPlusPlusNameParser::ConsumeArguments() { @@ -721,7 +721,7 @@ CPlusPlusNameParser::ParseFullNameImpl() { start_position.Remove(); return result; } else { - return None; + return std::nullopt; } } diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.cpp index e2c3c17a946d..fcc68c87ace4 100644 --- a/lldb/source/Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.cpp +++ b/lldb/source/Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.cpp @@ -423,18 +423,18 @@ ObjCLanguageRuntime::GetRuntimeType(CompilerType base_type) { else if (TypeSystemClang::IsObjCObjectOrInterfaceType(base_type)) class_type = base_type; else - return llvm::None; + return std::nullopt; if (!class_type) - return llvm::None; + return std::nullopt; ConstString class_name(class_type.GetTypeName()); if (!class_name) - return llvm::None; + return std::nullopt; TypeSP complete_objc_class_type_sp = LookupInCompleteClassCache(class_name); if (!complete_objc_class_type_sp) - return llvm::None; + return std::nullopt; CompilerType complete_class( complete_objc_class_type_sp->GetFullCompilerType()); @@ -445,5 +445,5 @@ ObjCLanguageRuntime::GetRuntimeType(CompilerType base_type) { return complete_class; } - return llvm::None; + return std::nullopt; } diff --git a/lldb/source/Plugins/ObjectContainer/Mach-O-Fileset/ObjectContainerMachOFileset.cpp b/lldb/source/Plugins/ObjectContainer/Mach-O-Fileset/ObjectContainerMachOFileset.cpp index 22f3e41aaac4..30a0ed58cbe9 100644 --- a/lldb/source/Plugins/ObjectContainer/Mach-O-Fileset/ObjectContainerMachOFileset.cpp +++ b/lldb/source/Plugins/ObjectContainer/Mach-O-Fileset/ObjectContainerMachOFileset.cpp @@ -135,7 +135,7 @@ static llvm::Optional ParseMachOHeader(DataExtractor &data) { static bool ParseFileset(DataExtractor &data, mach_header header, std::vector &entries, - llvm::Optional load_addr = llvm::None) { + llvm::Optional load_addr = std::nullopt) { lldb::offset_t offset = MachHeaderSizeFromMagic(header.magic); lldb::offset_t slide = 0; for (uint32_t i = 0; i < header.ncmds; ++i) { diff --git a/lldb/source/Plugins/ObjectFile/Breakpad/BreakpadRecords.cpp b/lldb/source/Plugins/ObjectFile/Breakpad/BreakpadRecords.cpp index 0c1b36514d26..e747c1537a05 100644 --- a/lldb/source/Plugins/ObjectFile/Breakpad/BreakpadRecords.cpp +++ b/lldb/source/Plugins/ObjectFile/Breakpad/BreakpadRecords.cpp @@ -147,7 +147,7 @@ llvm::Optional Record::classify(llvm::StringRef Line) { case Token::Win: return Record::StackWin; default: - return llvm::None; + return std::nullopt; } case Token::Inline: return Record::Inline; @@ -164,7 +164,7 @@ llvm::Optional Record::classify(llvm::StringRef Line) { case Token::Init: case Token::Win: // These should never appear at the start of a valid record. - return llvm::None; + return std::nullopt; } llvm_unreachable("Fully covered switch above!"); } @@ -172,21 +172,21 @@ llvm::Optional Record::classify(llvm::StringRef Line) { llvm::Optional ModuleRecord::parse(llvm::StringRef Line) { // MODULE Linux x86_64 E5894855C35DCCCCCCCCCCCCCCCCCCCC0 a.out if (consume(Line) != Token::Module) - return llvm::None; + return std::nullopt; llvm::Triple::OSType OS = consume(Line); if (OS == llvm::Triple::UnknownOS) - return llvm::None; + return std::nullopt; llvm::Triple::ArchType Arch = consume(Line); if (Arch == llvm::Triple::UnknownArch) - return llvm::None; + return std::nullopt; llvm::StringRef Str; std::tie(Str, Line) = getToken(Line); UUID ID = parseModuleId(OS, Str); if (!ID) - return llvm::None; + return std::nullopt; return ModuleRecord(OS, Arch, std::move(ID)); } @@ -201,10 +201,10 @@ llvm::raw_ostream &breakpad::operator<<(llvm::raw_ostream &OS, llvm::Optional InfoRecord::parse(llvm::StringRef Line) { // INFO CODE_ID 554889E55DC3CCCCCCCCCCCCCCCCCCCC [a.exe] if (consume(Line) != Token::Info) - return llvm::None; + return std::nullopt; if (consume(Line) != Token::CodeID) - return llvm::None; + return std::nullopt; llvm::StringRef Str; std::tie(Str, Line) = getToken(Line); @@ -213,7 +213,7 @@ llvm::Optional InfoRecord::parse(llvm::StringRef Line) { UUID ID; if (Line.trim().empty()) { if (Str.empty() || !ID.SetFromStringRef(Str)) - return llvm::None; + return std::nullopt; } return InfoRecord(std::move(ID)); } @@ -228,17 +228,17 @@ static llvm::Optional parseNumberName(llvm::StringRef Line, Token TokenType) { // TOKEN number name if (consume(Line) != TokenType) - return llvm::None; + return std::nullopt; llvm::StringRef Str; size_t Number; std::tie(Str, Line) = getToken(Line); if (!to_integer(Str, Number)) - return llvm::None; + return std::nullopt; llvm::StringRef Name = Line.trim(); if (Name.empty()) - return llvm::None; + return std::nullopt; return T(Number, Name); } @@ -310,7 +310,7 @@ llvm::Optional FuncRecord::parse(llvm::StringRef Line) { if (parsePublicOrFunc(Line, Multiple, Address, &Size, ParamSize, Name)) return FuncRecord(Multiple, Address, Size, ParamSize, Name); - return llvm::None; + return std::nullopt; } bool breakpad::operator==(const FuncRecord &L, const FuncRecord &R) { @@ -328,12 +328,12 @@ llvm::Optional InlineRecord::parse(llvm::StringRef Line) { // INLINE inline_nest_level call_site_line call_site_file_num origin_num // [address size]+ if (consume(Line) != Token::Inline) - return llvm::None; + return std::nullopt; llvm::SmallVector Tokens; SplitString(Line, Tokens, " "); if (Tokens.size() < 6 || Tokens.size() % 2 == 1) - return llvm::None; + return std::nullopt; size_t InlineNestLevel; uint32_t CallSiteLineNum; @@ -343,17 +343,17 @@ llvm::Optional InlineRecord::parse(llvm::StringRef Line) { to_integer(Tokens[1], CallSiteLineNum) && to_integer(Tokens[2], CallSiteFileNum) && to_integer(Tokens[3], OriginNum))) - return llvm::None; + return std::nullopt; InlineRecord Record = InlineRecord(InlineNestLevel, CallSiteLineNum, CallSiteFileNum, OriginNum); for (size_t i = 4; i < Tokens.size(); i += 2) { lldb::addr_t Address; if (!to_integer(Tokens[i], Address, 16)) - return llvm::None; + return std::nullopt; lldb::addr_t Size; if (!to_integer(Tokens[i + 1].trim(), Size, 16)) - return llvm::None; + return std::nullopt; Record.Ranges.emplace_back(Address, Size); } return Record; @@ -381,22 +381,22 @@ llvm::Optional LineRecord::parse(llvm::StringRef Line) { llvm::StringRef Str; std::tie(Str, Line) = getToken(Line); if (!to_integer(Str, Address, 16)) - return llvm::None; + return std::nullopt; lldb::addr_t Size; std::tie(Str, Line) = getToken(Line); if (!to_integer(Str, Size, 16)) - return llvm::None; + return std::nullopt; uint32_t LineNum; std::tie(Str, Line) = getToken(Line); if (!to_integer(Str, LineNum)) - return llvm::None; + return std::nullopt; size_t FileNum; std::tie(Str, Line) = getToken(Line); if (!to_integer(Str, FileNum)) - return llvm::None; + return std::nullopt; return LineRecord(Address, Size, LineNum, FileNum); } @@ -419,7 +419,7 @@ llvm::Optional PublicRecord::parse(llvm::StringRef Line) { if (parsePublicOrFunc(Line, Multiple, Address, nullptr, ParamSize, Name)) return PublicRecord(Multiple, Address, ParamSize, Name); - return llvm::None; + return std::nullopt; } bool breakpad::operator==(const PublicRecord &L, const PublicRecord &R) { @@ -440,9 +440,9 @@ llvm::Optional StackCFIRecord::parse(llvm::StringRef Line) { // No token in exprN ends with a colon. if (consume(Line) != Token::Stack) - return llvm::None; + return std::nullopt; if (consume(Line) != Token::CFI) - return llvm::None; + return std::nullopt; llvm::StringRef Str; std::tie(Str, Line) = getToken(Line); @@ -453,14 +453,14 @@ llvm::Optional StackCFIRecord::parse(llvm::StringRef Line) { lldb::addr_t Address; if (!to_integer(Str, Address, 16)) - return llvm::None; + return std::nullopt; llvm::Optional Size; if (IsInitRecord) { Size.emplace(); std::tie(Str, Line) = getToken(Line); if (!to_integer(Str, *Size, 16)) - return llvm::None; + return std::nullopt; } return StackCFIRecord(Address, Size, Line.trim()); @@ -488,26 +488,26 @@ llvm::Optional StackWinRecord::parse(llvm::StringRef Line) { // program_string_OR_allocates_base_pointer if (consume(Line) != Token::Stack) - return llvm::None; + return std::nullopt; if (consume(Line) != Token::Win) - return llvm::None; + return std::nullopt; llvm::StringRef Str; uint8_t Type; std::tie(Str, Line) = getToken(Line); // Right now we only support the "FrameData" frame type. if (!to_integer(Str, Type) || FrameType(Type) != FrameType::FrameData) - return llvm::None; + return std::nullopt; lldb::addr_t RVA; std::tie(Str, Line) = getToken(Line); if (!to_integer(Str, RVA, 16)) - return llvm::None; + return std::nullopt; lldb::addr_t CodeSize; std::tie(Str, Line) = getToken(Line); if (!to_integer(Str, CodeSize, 16)) - return llvm::None; + return std::nullopt; // Skip fields which we aren't using right now. std::tie(Str, Line) = getToken(Line); // prologue_size @@ -516,27 +516,27 @@ llvm::Optional StackWinRecord::parse(llvm::StringRef Line) { lldb::addr_t ParameterSize; std::tie(Str, Line) = getToken(Line); if (!to_integer(Str, ParameterSize, 16)) - return llvm::None; + return std::nullopt; lldb::addr_t SavedRegisterSize; std::tie(Str, Line) = getToken(Line); if (!to_integer(Str, SavedRegisterSize, 16)) - return llvm::None; + return std::nullopt; lldb::addr_t LocalSize; std::tie(Str, Line) = getToken(Line); if (!to_integer(Str, LocalSize, 16)) - return llvm::None; + return std::nullopt; std::tie(Str, Line) = getToken(Line); // max_stack_size uint8_t HasProgramString; std::tie(Str, Line) = getToken(Line); if (!to_integer(Str, HasProgramString)) - return llvm::None; + return std::nullopt; // FrameData records should always have a program string. if (!HasProgramString) - return llvm::None; + return std::nullopt; return StackWinRecord(RVA, CodeSize, ParameterSize, SavedRegisterSize, LocalSize, Line.trim()); diff --git a/lldb/source/Plugins/ObjectFile/Breakpad/ObjectFileBreakpad.cpp b/lldb/source/Plugins/ObjectFile/Breakpad/ObjectFileBreakpad.cpp index c591a4a7534c..3d2e2003c8ed 100644 --- a/lldb/source/Plugins/ObjectFile/Breakpad/ObjectFileBreakpad.cpp +++ b/lldb/source/Plugins/ObjectFile/Breakpad/ObjectFileBreakpad.cpp @@ -31,7 +31,7 @@ llvm::Optional
Header::parse(llvm::StringRef text) { std::tie(line, text) = text.split('\n'); auto Module = ModuleRecord::parse(line); if (!Module) - return llvm::None; + return std::nullopt; llvm::Triple triple; triple.setArch(Module->Arch); diff --git a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp index cf1b375001d6..fee30ecb6240 100644 --- a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp +++ b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp @@ -822,7 +822,7 @@ UUID ObjectFileELF::GetUUID() { llvm::Optional ObjectFileELF::GetDebugLink() { if (m_gnu_debuglink_file.empty()) - return llvm::None; + return std::nullopt; return FileSpec(m_gnu_debuglink_file); } @@ -1770,13 +1770,13 @@ public: if (H.p_memsz == 0) { LLDB_LOG(Log, "Ignoring zero-sized {0} segment. Corrupt object file?", SegmentName); - return llvm::None; + return std::nullopt; } if (Segments.overlaps(H.p_vaddr, H.p_vaddr + H.p_memsz)) { LLDB_LOG(Log, "Ignoring overlapping {0} segment. Corrupt object file?", SegmentName); - return llvm::None; + return std::nullopt; } return VMRange(H.p_vaddr, H.p_memsz); } @@ -1801,7 +1801,7 @@ public: if (Range.GetByteSize() > 0 && Sections.overlaps(Range.GetRangeBase(), Range.GetRangeEnd())) { LLDB_LOG(Log, "Ignoring overlapping section. Corrupt object file?"); - return llvm::None; + return std::nullopt; } if (Segment) Range.Slide(-Segment->GetFileAddress()); diff --git a/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp b/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp index 72fc82c3cd80..d13f0881cf9b 100644 --- a/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp +++ b/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp @@ -1092,7 +1092,7 @@ llvm::Optional ObjectFilePECOFF::GetDebugLink() { uint32_t gnu_debuglink_crc; if (GetDebugLinkContents(*m_binary, gnu_debuglink_file, gnu_debuglink_crc)) return FileSpec(gnu_debuglink_file); - return llvm::None; + return std::nullopt; } uint32_t ObjectFilePECOFF::ParseDependentModules() { diff --git a/lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.cpp b/lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.cpp index 905e9637493b..a8f47ffedd40 100644 --- a/lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.cpp +++ b/lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.cpp @@ -57,18 +57,18 @@ GetWasmString(llvm::DataExtractor &data, llvm::DataExtractor::Cursor &c) { uint64_t len = data.getULEB128(c); if (!c) { consumeError(c.takeError()); - return llvm::None; + return std::nullopt; } if (len >= (uint64_t(1) << 32)) { - return llvm::None; + return std::nullopt; } llvm::SmallVector str_storage; data.getU8(c, str_storage, len); if (!c) { consumeError(c.takeError()); - return llvm::None; + return std::nullopt; } llvm::StringRef str = toStringRef(makeArrayRef(str_storage)); @@ -427,7 +427,7 @@ llvm::Optional ObjectFileWasm::GetExternalDebugInfoFileSpec() { return FileSpec(symbols_url->GetStringRef()); } } - return llvm::None; + return std::nullopt; } void ObjectFileWasm::Dump(Stream *s) { diff --git a/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp b/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp index a20643ad21c2..780f51cc18c2 100644 --- a/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp +++ b/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp @@ -153,14 +153,14 @@ bool PlatformRemoteGDBServer::GetRemoteOSVersion() { llvm::Optional PlatformRemoteGDBServer::GetRemoteOSBuildString() { if (!m_gdb_client_up) - return llvm::None; + return std::nullopt; return m_gdb_client_up->GetOSBuildString(); } llvm::Optional PlatformRemoteGDBServer::GetRemoteOSKernelDescription() { if (!m_gdb_client_up) - return llvm::None; + return std::nullopt; return m_gdb_client_up->GetOSKernelDescription(); } @@ -288,7 +288,7 @@ PlatformRemoteGDBServer::DoGetUserName(UserIDResolver::id_t uid) { std::string name; if (m_gdb_client_up && m_gdb_client_up->GetUserName(uid, name)) return std::move(name); - return llvm::None; + return std::nullopt; } llvm::Optional @@ -296,7 +296,7 @@ PlatformRemoteGDBServer::DoGetGroupName(UserIDResolver::id_t gid) { std::string name; if (m_gdb_client_up && m_gdb_client_up->GetGroupName(gid, name)) return std::move(name); - return llvm::None; + return std::nullopt; } uint32_t PlatformRemoteGDBServer::FindProcesses( diff --git a/lldb/source/Plugins/Process/Linux/IntelPTCollector.cpp b/lldb/source/Plugins/Process/Linux/IntelPTCollector.cpp index 5f4be5b00fdb..2051b5b1572b 100644 --- a/lldb/source/Plugins/Process/Linux/IntelPTCollector.cpp +++ b/lldb/source/Plugins/Process/Linux/IntelPTCollector.cpp @@ -73,7 +73,7 @@ static Optional GetCGroupFileDescriptor(lldb::pid_t pid) { std::ifstream ifile; ifile.open(formatv("/proc/{0}/cgroup", pid)); if (!ifile) - return None; + return std::nullopt; std::string line; while (std::getline(ifile, line)) { @@ -82,7 +82,7 @@ static Optional GetCGroupFileDescriptor(lldb::pid_t pid) { std::string slice = line.substr(line.find_first_of("/")); if (slice.empty()) - return None; + return std::nullopt; std::string cgroup_file = formatv("/sys/fs/cgroup/{0}", slice); // This cgroup should for the duration of the target, so we don't need to // invoke close ourselves. @@ -92,7 +92,7 @@ static Optional GetCGroupFileDescriptor(lldb::pid_t pid) { return fd; } } - return None; + return std::nullopt; } Error IntelPTCollector::TraceStart(const TraceIntelPTStartRequest &request) { diff --git a/lldb/source/Plugins/Process/Linux/IntelPTMultiCoreTrace.cpp b/lldb/source/Plugins/Process/Linux/IntelPTMultiCoreTrace.cpp index d8ee3e5600c9..0453de25faf4 100644 --- a/lldb/source/Plugins/Process/Linux/IntelPTMultiCoreTrace.cpp +++ b/lldb/source/Plugins/Process/Linux/IntelPTMultiCoreTrace.cpp @@ -51,7 +51,7 @@ IntelPTMultiCoreTrace::StartOnAllCores(const TraceIntelPTStartRequest &request, for (cpu_id_t cpu_id : *cpu_ids) { Expected core_trace = - IntelPTSingleBufferTrace::Start(request, /*tid=*/None, cpu_id, + IntelPTSingleBufferTrace::Start(request, /*tid=*/std::nullopt, cpu_id, /*disabled=*/true, cgroup_fd); if (!core_trace) return IncludePerfEventParanoidMessageInError(core_trace.takeError()); @@ -149,7 +149,7 @@ Expected>> IntelPTMultiCoreTrace::TryGetBinaryData( const TraceGetBinaryDataRequest &request) { if (!request.cpu_id) - return None; + return std::nullopt; auto it = m_traces_per_core.find(*request.cpu_id); if (it == m_traces_per_core.end()) return createStringError( @@ -160,5 +160,5 @@ IntelPTMultiCoreTrace::TryGetBinaryData( return it->second.first.GetIptTrace(); if (request.kind == IntelPTDataKinds::kPerfContextSwitchTrace) return it->second.second.GetReadOnlyDataBuffer(); - return None; + return std::nullopt; } diff --git a/lldb/source/Plugins/Process/Linux/IntelPTMultiCoreTrace.h b/lldb/source/Plugins/Process/Linux/IntelPTMultiCoreTrace.h index b522e9fede65..38503b13230a 100644 --- a/lldb/source/Plugins/Process/Linux/IntelPTMultiCoreTrace.h +++ b/lldb/source/Plugins/Process/Linux/IntelPTMultiCoreTrace.h @@ -43,7 +43,7 @@ public: static llvm::Expected> StartOnAllCores(const TraceIntelPTStartRequest &request, NativeProcessProtocol &process, - llvm::Optional cgroup_fd = llvm::None); + llvm::Optional cgroup_fd = std::nullopt); /// Execute the provided callback on each core that is being traced. /// diff --git a/lldb/source/Plugins/Process/Linux/IntelPTSingleBufferTrace.h b/lldb/source/Plugins/Process/Linux/IntelPTSingleBufferTrace.h index 29369cc5e46d..677038bf9603 100644 --- a/lldb/source/Plugins/Process/Linux/IntelPTSingleBufferTrace.h +++ b/lldb/source/Plugins/Process/Linux/IntelPTSingleBufferTrace.h @@ -52,8 +52,8 @@ public: static llvm::Expected Start(const TraceIntelPTStartRequest &request, llvm::Optional tid, - llvm::Optional cpu_id = llvm::None, - bool disabled = false, llvm::Optional cgroup_fd = llvm::None); + llvm::Optional cpu_id = std::nullopt, + bool disabled = false, llvm::Optional cgroup_fd = std::nullopt); /// \return /// The bytes requested by a jLLDBTraceGetBinaryData packet that was routed diff --git a/lldb/source/Plugins/Process/Linux/IntelPTThreadTraceCollection.cpp b/lldb/source/Plugins/Process/Linux/IntelPTThreadTraceCollection.cpp index f2c86e347e8f..e42f6276e922 100644 --- a/lldb/source/Plugins/Process/Linux/IntelPTThreadTraceCollection.cpp +++ b/lldb/source/Plugins/Process/Linux/IntelPTThreadTraceCollection.cpp @@ -76,12 +76,12 @@ llvm::Expected>> IntelPTThreadTraceCollection::TryGetBinaryData( const TraceGetBinaryDataRequest &request) { if (!request.tid) - return None; + return std::nullopt; if (request.kind != IntelPTDataKinds::kIptTrace) - return None; + return std::nullopt; if (!TracesThread(*request.tid)) - return None; + return std::nullopt; if (Expected trace = GetTracedThread(*request.tid)) diff --git a/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp b/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp index a76cc6a8f0ac..ffa15f4023db 100644 --- a/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp +++ b/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp @@ -1877,13 +1877,13 @@ static llvm::Optional HandlePid(::pid_t pid) { -1, ::waitpid, pid, &status, __WALL | __WNOTHREAD | WNOHANG); if (wait_pid == 0) - return llvm::None; + return std::nullopt; if (wait_pid == -1) { Status error(errno, eErrorTypePOSIX); LLDB_LOG(log, "waitpid({0}, &status, _) failed: {1}", pid, error); - return llvm::None; + return std::nullopt; } assert(wait_pid == pid); diff --git a/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux.h b/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux.h index 9e2326c3a784..f715d5894184 100644 --- a/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux.h +++ b/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux.h @@ -53,7 +53,7 @@ public: }; /// Return architecture-specific data needed to make inferior syscalls, if /// they are supported. - virtual llvm::Optional GetSyscallData() { return llvm::None; } + virtual llvm::Optional GetSyscallData() { return std::nullopt; } struct MmapData { // Syscall numbers can be found (e.g.) in /usr/include/asm/unistd.h for the @@ -63,7 +63,7 @@ public: }; /// Return the architecture-specific data needed to make mmap syscalls, if /// they are supported. - virtual llvm::Optional GetMmapData() { return llvm::None; } + virtual llvm::Optional GetMmapData() { return std::nullopt; } struct MemoryTaggingDetails { /// Object with tag handling utilities. If the function below returns diff --git a/lldb/source/Plugins/Process/Linux/Perf.cpp b/lldb/source/Plugins/Process/Linux/Perf.cpp index 9617c2df849a..a3095c8c103b 100644 --- a/lldb/source/Plugins/Process/Linux/Perf.cpp +++ b/lldb/source/Plugins/Process/Linux/Perf.cpp @@ -366,8 +366,8 @@ lldb_private::process_linux::CreateContextSwitchTracePerfEvent( if (parent_perf_event) group_fd = parent_perf_event->GetFd(); - if (Expected perf_event = - PerfEvent::Init(attr, /*pid=*/None, cpu_id, group_fd, /*flags=*/0)) { + if (Expected perf_event = PerfEvent::Init( + attr, /*pid=*/std::nullopt, cpu_id, group_fd, /*flags=*/0)) { if (Error mmap_err = perf_event->MmapMetadataAndBuffers( data_buffer_numpages, 0, /*data_buffer_write=*/false)) { return std::move(mmap_err); diff --git a/lldb/source/Plugins/Process/Linux/Perf.h b/lldb/source/Plugins/Process/Linux/Perf.h index 86056c7c9927..fb3fd244664f 100644 --- a/lldb/source/Plugins/Process/Linux/Perf.h +++ b/lldb/source/Plugins/Process/Linux/Perf.h @@ -126,7 +126,7 @@ public: /// all threads and processes are monitored. static llvm::Expected Init(perf_event_attr &attr, llvm::Optional pid, - llvm::Optional core = llvm::None); + llvm::Optional core = std::nullopt); /// Mmap the metadata page and the data and aux buffers of the perf event and /// expose them through \a PerfEvent::GetMetadataPage() , \a diff --git a/lldb/source/Plugins/Process/POSIX/NativeProcessELF.cpp b/lldb/source/Plugins/Process/POSIX/NativeProcessELF.cpp index fe64da873d22..a09cb9810d91 100644 --- a/lldb/source/Plugins/Process/POSIX/NativeProcessELF.cpp +++ b/lldb/source/Plugins/Process/POSIX/NativeProcessELF.cpp @@ -17,7 +17,7 @@ NativeProcessELF::GetAuxValue(enum AuxVector::EntryType type) { if (m_aux_vector == nullptr) { auto buffer_or_error = GetAuxvData(); if (!buffer_or_error) - return llvm::None; + return std::nullopt; DataExtractor auxv_data(buffer_or_error.get()->getBufferStart(), buffer_or_error.get()->getBufferSize(), GetByteOrder(), GetAddressByteSize()); diff --git a/lldb/source/Plugins/Process/Utility/AuxVector.cpp b/lldb/source/Plugins/Process/Utility/AuxVector.cpp index c4f45f759a33..821f56958daf 100644 --- a/lldb/source/Plugins/Process/Utility/AuxVector.cpp +++ b/lldb/source/Plugins/Process/Utility/AuxVector.cpp @@ -34,7 +34,7 @@ AuxVector::GetAuxValue(enum EntryType entry_type) const { auto it = m_auxv_entries.find(static_cast(entry_type)); if (it != m_auxv_entries.end()) return it->second; - return llvm::None; + return std::nullopt; } void AuxVector::DumpToLog(lldb_private::Log *log) const { diff --git a/lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp b/lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp index 04614ea3f662..de4a23d4d505 100644 --- a/lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp +++ b/lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp @@ -50,12 +50,12 @@ GetPtrauthInstructionInfo(Target &target, const ArchSpec &arch, DisassemblerSP disassembler_sp = Disassembler::DisassembleRange( arch, plugin_name, flavor, target, range_bounds, prefer_file_cache); if (!disassembler_sp) - return llvm::None; + return std::nullopt; InstructionList &insn_list = disassembler_sp->GetInstructionList(); InstructionSP insn = insn_list.GetInstructionAtIndex(0); if (!insn) - return llvm::None; + return std::nullopt; return PtrauthInstructionInfo{insn->IsAuthenticated(), insn->IsLoad(), insn->DoesBranch()}; diff --git a/lldb/source/Plugins/Process/elf-core/RegisterUtilities.cpp b/lldb/source/Plugins/Process/elf-core/RegisterUtilities.cpp index 6f3bf02cd303..8482ae8f47d6 100644 --- a/lldb/source/Plugins/Process/elf-core/RegisterUtilities.cpp +++ b/lldb/source/Plugins/Process/elf-core/RegisterUtilities.cpp @@ -22,7 +22,7 @@ getNoteType(const llvm::Triple &Triple, continue; return Entry.Note; } - return llvm::None; + return std::nullopt; } DataExtractor lldb_private::getRegset(llvm::ArrayRef Notes, diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp index 347c47b078f4..a8af26a82b08 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp @@ -947,7 +947,7 @@ llvm::Optional GDBRemoteCommunicationClient::GetOSBuildString() { if (!m_os_build.empty()) return m_os_build; } - return llvm::None; + return std::nullopt; } llvm::Optional @@ -956,7 +956,7 @@ GDBRemoteCommunicationClient::GetOSKernelDescription() { if (!m_os_kernel.empty()) return m_os_kernel; } - return llvm::None; + return std::nullopt; } bool GDBRemoteCommunicationClient::GetHostname(std::string &s) { @@ -2706,7 +2706,7 @@ GDBRemoteCommunicationClient::SendSetCurrentThreadPacket(uint64_t tid, if (response.IsUnsupportedResponse() && IsConnected()) return {{1, 1}}; } - return llvm::None; + return std::nullopt; } bool GDBRemoteCommunicationClient::SetCurrentThread(uint64_t tid, @@ -3082,20 +3082,20 @@ GDBRemoteCommunicationClient::FStat(lldb::user_id_t fd) { if (SendPacketAndWaitForResponse(stream.GetString(), response) == PacketResult::Success) { if (response.GetChar() != 'F') - return llvm::None; + return std::nullopt; int64_t size = response.GetS64(-1, 16); if (size > 0 && response.GetChar() == ';') { std::string buffer; if (response.GetEscapedBinaryData(buffer)) { GDBRemoteFStatData out; if (buffer.size() != sizeof(out)) - return llvm::None; + return std::nullopt; memcpy(&out, buffer.data(), sizeof(out)); return out; } } } - return llvm::None; + return std::nullopt; } llvm::Optional @@ -3103,7 +3103,7 @@ GDBRemoteCommunicationClient::Stat(const lldb_private::FileSpec &file_spec) { Status error; lldb::user_id_t fd = OpenFile(file_spec, File::eOpenOptionReadOnly, 0, error); if (fd == UINT64_MAX) - return llvm::None; + return std::nullopt; llvm::Optional st = FStat(fd); CloseFile(fd, error); return st; @@ -3710,9 +3710,9 @@ llvm::Optional GDBRemoteCommunicationClient::GetQOffsets() { StringExtractorGDBRemote response; if (SendPacketAndWaitForResponse("qOffsets", response) != PacketResult::Success) - return llvm::None; + return std::nullopt; if (!response.IsNormalResponse()) - return llvm::None; + return std::nullopt; QOffsets result; llvm::StringRef ref = response.GetStringRef(); @@ -3727,9 +3727,9 @@ llvm::Optional GDBRemoteCommunicationClient::GetQOffsets() { if (ref.consume_front("Text=")) { result.segments = false; if (!GetOffset()) - return llvm::None; + return std::nullopt; if (!ref.consume_front(";Data=") || !GetOffset()) - return llvm::None; + return std::nullopt; if (ref.empty()) return result; if (ref.consume_front(";Bss=") && GetOffset() && ref.empty()) @@ -3737,13 +3737,13 @@ llvm::Optional GDBRemoteCommunicationClient::GetQOffsets() { } else if (ref.consume_front("TextSeg=")) { result.segments = true; if (!GetOffset()) - return llvm::None; + return std::nullopt; if (ref.empty()) return result; if (ref.consume_front(";DataSeg=") && GetOffset() && ref.empty()) return result; } - return llvm::None; + return std::nullopt; } bool GDBRemoteCommunicationClient::GetModuleInfo( @@ -3816,30 +3816,30 @@ static llvm::Optional ParseModuleSpec(StructuredData::Dictionary *dict) { ModuleSpec result; if (!dict) - return llvm::None; + return std::nullopt; llvm::StringRef string; uint64_t integer; if (!dict->GetValueForKeyAsString("uuid", string)) - return llvm::None; + return std::nullopt; if (!result.GetUUID().SetFromStringRef(string)) - return llvm::None; + return std::nullopt; if (!dict->GetValueForKeyAsInteger("file_offset", integer)) - return llvm::None; + return std::nullopt; result.SetObjectOffset(integer); if (!dict->GetValueForKeyAsInteger("file_size", integer)) - return llvm::None; + return std::nullopt; result.SetObjectSize(integer); if (!dict->GetValueForKeyAsString("triple", string)) - return llvm::None; + return std::nullopt; result.GetArchitecture().SetTriple(string); if (!dict->GetValueForKeyAsString("file_path", string)) - return llvm::None; + return std::nullopt; result.GetFileSpec() = FileSpec(string, result.GetArchitecture().GetTriple()); return result; @@ -3851,7 +3851,7 @@ GDBRemoteCommunicationClient::GetModulesInfo( namespace json = llvm::json; if (!m_supports_jModulesInfo) - return llvm::None; + return std::nullopt; json::Array module_array; for (const FileSpec &module_file_spec : module_file_specs) { @@ -3874,21 +3874,21 @@ GDBRemoteCommunicationClient::GetModulesInfo( if (SendPacketAndWaitForResponse(payload.GetString(), response) != PacketResult::Success || response.IsErrorResponse()) - return llvm::None; + return std::nullopt; if (response.IsUnsupportedResponse()) { m_supports_jModulesInfo = false; - return llvm::None; + return std::nullopt; } StructuredData::ObjectSP response_object_sp = StructuredData::ParseJSON(std::string(response.GetStringRef())); if (!response_object_sp) - return llvm::None; + return std::nullopt; StructuredData::Array *response_array = response_object_sp->GetAsArray(); if (!response_array) - return llvm::None; + return std::nullopt; std::vector result; for (size_t i = 0; i < response_array->GetSize(); ++i) { diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp index 4ea8472c008c..13446d560d87 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp @@ -655,7 +655,7 @@ GetRegistersAsJSON(NativeThreadProtocol &thread) { reg_ctx.GetExpeditedRegisters(ExpeditedRegs::Minimal); #endif if (expedited_regs.empty()) - return llvm::None; + return std::nullopt; for (auto ®_num : expedited_regs) { const RegisterInfo *const reg_info_p = @@ -3658,7 +3658,7 @@ GDBRemoteCommunicationServerLLGS::Handle_qWatchpointSupportInfo( auto hw_debug_cap = m_current_process->GetHardwareDebugSupportInfo(); StreamGDBRemote response; - if (hw_debug_cap == llvm::None) + if (hw_debug_cap == std::nullopt) response.Printf("num:0;"); else response.Printf("num:%d;", hw_debug_cap->second); diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp index 83b496b3b978..3c67e26fd84f 100644 --- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp @@ -3448,7 +3448,7 @@ thread_result_t ProcessGDBRemote::AsyncThread() { ") listener.WaitForEvent (NULL, event_sp)...", __FUNCTION__, GetID()); - if (m_async_listener_sp->GetEvent(event_sp, llvm::None)) { + if (m_async_listener_sp->GetEvent(event_sp, std::nullopt)) { const uint32_t event_type = event_sp->GetType(); if (event_sp->BroadcasterIs(&m_async_broadcaster)) { LLDB_LOGF(log, diff --git a/lldb/source/Plugins/Process/minidump/MinidumpParser.cpp b/lldb/source/Plugins/Process/minidump/MinidumpParser.cpp index d14b707f7209..379189a518f4 100644 --- a/lldb/source/Plugins/Process/minidump/MinidumpParser.cpp +++ b/lldb/source/Plugins/Process/minidump/MinidumpParser.cpp @@ -224,7 +224,7 @@ llvm::Optional MinidumpParser::GetLinuxProcStatus() { llvm::ArrayRef data = GetStream(StreamType::LinuxProcStatus); if (data.size() == 0) - return llvm::None; + return std::nullopt; return LinuxProcStatus::Parse(data); } @@ -240,7 +240,7 @@ llvm::Optional MinidumpParser::GetPid() { return proc_status->GetPid(); } - return llvm::None; + return std::nullopt; } llvm::ArrayRef MinidumpParser::GetModuleList() { @@ -442,14 +442,14 @@ MinidumpParser::FindMemoryRange(lldb::addr_t addr) { const size_t range_size = loc_desc.DataSize; if (loc_desc.RVA + loc_desc.DataSize > GetData().size()) - return llvm::None; + return std::nullopt; if (range_start <= addr && addr < range_start + range_size) { auto ExpectedSlice = GetMinidumpFile().getRawData(loc_desc); if (!ExpectedSlice) { LLDB_LOG_ERROR(log, ExpectedSlice.takeError(), "Failed to get memory slice: {0}"); - return llvm::None; + return std::nullopt; } return minidump::Range(range_start, *ExpectedSlice); } @@ -468,14 +468,14 @@ MinidumpParser::FindMemoryRange(lldb::addr_t addr) { MinidumpMemoryDescriptor64::ParseMemory64List(data64); if (memory64_list.empty()) - return llvm::None; + return std::nullopt; for (const auto &memory_desc64 : memory64_list) { const lldb::addr_t range_start = memory_desc64.start_of_memory_range; const size_t range_size = memory_desc64.data_size; if (base_rva + range_size > GetData().size()) - return llvm::None; + return std::nullopt; if (range_start <= addr && addr < range_start + range_size) { return minidump::Range(range_start, @@ -485,7 +485,7 @@ MinidumpParser::FindMemoryRange(lldb::addr_t addr) { } } - return llvm::None; + return std::nullopt; } llvm::ArrayRef MinidumpParser::GetMemory(lldb::addr_t addr, diff --git a/lldb/source/Plugins/Process/minidump/MinidumpTypes.cpp b/lldb/source/Plugins/Process/minidump/MinidumpTypes.cpp index abddd79ad7dc..b3ff6bfa1b21 100644 --- a/lldb/source/Plugins/Process/minidump/MinidumpTypes.cpp +++ b/lldb/source/Plugins/Process/minidump/MinidumpTypes.cpp @@ -29,7 +29,7 @@ llvm::Optional MinidumpMiscInfo::GetPid() const { if (flags1 & pid_flag) return llvm::Optional(process_id); - return llvm::None; + return std::nullopt; } // Linux Proc Status @@ -52,7 +52,7 @@ LinuxProcStatus::Parse(llvm::ArrayRef &data) { } } - return llvm::None; + return std::nullopt; } lldb::pid_t LinuxProcStatus::GetPid() const { return pid; } diff --git a/lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp b/lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp index 2884003c9894..07bc35785a2a 100644 --- a/lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp +++ b/lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp @@ -495,7 +495,7 @@ void SymbolFileBreakpad::AddSymbols(Symtab &symtab) { for (llvm::StringRef line : lines(Record::Public)) { if (auto record = PublicRecord::parse(line)) - add_symbol(record->Address, llvm::None, record->Name); + add_symbol(record->Address, std::nullopt, record->Name); else LLDB_LOG(log, "Failed to parse: {0}. Skipping record.", line); } @@ -528,7 +528,7 @@ GetRule(llvm::StringRef &unwind_rules) { llvm::StringRef lhs, rest; std::tie(lhs, rest) = getToken(unwind_rules); if (!lhs.consume_back(":")) - return llvm::None; + return std::nullopt; // Seek forward to the next register: expression pair llvm::StringRef::size_type pos = rest.find(": "); @@ -541,7 +541,7 @@ GetRule(llvm::StringRef &unwind_rules) { // Go back one token to find the end of the current rule. pos = rest.rfind(' ', pos); if (pos == llvm::StringRef::npos) - return llvm::None; + return std::nullopt; llvm::StringRef rhs = rest.take_front(pos); unwind_rules = rest.drop_front(pos); diff --git a/lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.h b/lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.h index 39ed8e577ac9..2ffff5140ece 100644 --- a/lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.h +++ b/lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.h @@ -95,7 +95,7 @@ public: llvm::Optional GetDynamicArrayInfoForUID( lldb::user_id_t type_uid, const lldb_private::ExecutionContext *exe_ctx) override { - return llvm::None; + return std::nullopt; } bool CompleteType(CompilerType &compiler_type) override { return false; } diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DIERef.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DIERef.cpp index 25cb368763c1..909db83e9284 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DIERef.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DIERef.cpp @@ -36,11 +36,11 @@ llvm::Optional DIERef::Decode(const DataExtractor &data, // it will return 0 dw_offset_t die_offset = data.GetU32(offset_ptr); if (die_offset == 0) - return llvm::None; + return std::nullopt; if (dwo_num_valid) return DIERef(dwo_num, section, die_offset); else - return DIERef(llvm::None, section, die_offset); + return DIERef(std::nullopt, section, die_offset); } void DIERef::Encode(DataEncoder &encoder) const { diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DIERef.h b/lldb/source/Plugins/SymbolFile/DWARF/DIERef.h index ce0a054eee08..e980f686958e 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DIERef.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/DIERef.h @@ -37,7 +37,7 @@ public: llvm::Optional dwo_num() const { if (m_dwo_num_valid) return m_dwo_num; - return llvm::None; + return std::nullopt; } Section section() const { return static_cast
(m_section); } diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParser.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParser.cpp index 364d34c73375..0292e743004a 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParser.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParser.cpp @@ -23,7 +23,7 @@ DWARFASTParser::ParseChildArrayInfo(const DWARFDIE &parent_die, const ExecutionContext *exe_ctx) { SymbolFile::ArrayInfo array_info; if (!parent_die) - return llvm::None; + return std::nullopt; for (DWARFDIE die : parent_die.children()) { const dw_tag_t tag = die.Tag(); diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp index fa09eea9ad7a..905df91ecaeb 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp @@ -1273,7 +1273,7 @@ TypeSP DWARFASTParserClang::ParseSubroutine(const DWARFDIE &die, } } return std::make_shared( - die.GetID(), dwarf, attrs.name, llvm::None, nullptr, LLDB_INVALID_UID, + die.GetID(), dwarf, attrs.name, std::nullopt, nullptr, LLDB_INVALID_UID, Type::eEncodingIsUID, &attrs.decl, clang_type, Type::ResolveState::Full); } diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.cpp index e5cf59871900..23835d8c3b27 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.cpp @@ -20,7 +20,7 @@ using namespace lldb_private; llvm::Optional DWARFBaseDIE::GetDIERef() const { if (!IsValid()) - return llvm::None; + return std::nullopt; return DIERef(m_cu->GetSymbolFileDWARF().GetDwoNum(), m_cu->GetDebugSection(), m_die->GetOffset()); @@ -57,7 +57,7 @@ llvm::Optional DWARFBaseDIE::GetAttributeValueAsOptionalUnsigned(const dw_attr_t attr) const { if (IsValid()) return m_die->GetAttributeValueAsOptionalUnsigned(GetCU(), attr); - return llvm::None; + return std::nullopt; } uint64_t DWARFBaseDIE::GetAttributeValueAsAddress(const dw_attr_t attr, diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFContext.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFContext.cpp index 37e28a09f3c4..d76ff198d003 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFContext.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFContext.cpp @@ -41,12 +41,12 @@ DWARFContext::LoadOrGetSection(llvm::Optional main_section_type, } const DWARFDataExtractor &DWARFContext::getOrLoadCuIndexData() { - return LoadOrGetSection(llvm::None, eSectionTypeDWARFDebugCuIndex, + return LoadOrGetSection(std::nullopt, eSectionTypeDWARFDebugCuIndex, m_data_debug_cu_index); } const DWARFDataExtractor &DWARFContext::getOrLoadTuIndexData() { - return LoadOrGetSection(llvm::None, eSectionTypeDWARFDebugTuIndex, + return LoadOrGetSection(std::nullopt, eSectionTypeDWARFDebugTuIndex, m_data_debug_tu_index); } @@ -56,12 +56,12 @@ const DWARFDataExtractor &DWARFContext::getOrLoadAbbrevData() { } const DWARFDataExtractor &DWARFContext::getOrLoadArangesData() { - return LoadOrGetSection(eSectionTypeDWARFDebugAranges, llvm::None, + return LoadOrGetSection(eSectionTypeDWARFDebugAranges, std::nullopt, m_data_debug_aranges); } const DWARFDataExtractor &DWARFContext::getOrLoadAddrData() { - return LoadOrGetSection(eSectionTypeDWARFDebugAddr, llvm::None, + return LoadOrGetSection(eSectionTypeDWARFDebugAddr, std::nullopt, m_data_debug_addr); } @@ -71,12 +71,12 @@ const DWARFDataExtractor &DWARFContext::getOrLoadDebugInfoData() { } const DWARFDataExtractor &DWARFContext::getOrLoadLineData() { - return LoadOrGetSection(eSectionTypeDWARFDebugLine, llvm::None, + return LoadOrGetSection(eSectionTypeDWARFDebugLine, std::nullopt, m_data_debug_line); } const DWARFDataExtractor &DWARFContext::getOrLoadLineStrData() { - return LoadOrGetSection(eSectionTypeDWARFDebugLineStr, llvm::None, + return LoadOrGetSection(eSectionTypeDWARFDebugLineStr, std::nullopt, m_data_debug_line_str); } @@ -92,12 +92,12 @@ const DWARFDataExtractor &DWARFContext::getOrLoadLocListsData() { } const DWARFDataExtractor &DWARFContext::getOrLoadMacroData() { - return LoadOrGetSection(eSectionTypeDWARFDebugMacro, llvm::None, + return LoadOrGetSection(eSectionTypeDWARFDebugMacro, std::nullopt, m_data_debug_macro); } const DWARFDataExtractor &DWARFContext::getOrLoadRangesData() { - return LoadOrGetSection(eSectionTypeDWARFDebugRanges, llvm::None, + return LoadOrGetSection(eSectionTypeDWARFDebugRanges, std::nullopt, m_data_debug_ranges); } diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp index c10eae311a93..481a8cc81110 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp @@ -555,7 +555,7 @@ DWARFDebugInfoEntry::GetAttributeValueAsOptionalUnsigned( if (GetAttributeValue(cu, attr, form_value, nullptr, check_specification_or_abstract_origin)) return form_value.Unsigned(); - return llvm::None; + return std::nullopt; } // GetAttributeValueAsReference diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp index 08b241683776..4efb5a2029e8 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp @@ -193,7 +193,7 @@ DWARFFormValue::GetFixedSize(dw_form_t form, const DWARFUnit *u) { return g_form_sizes[form].size; if (form == DW_FORM_addr && u) return u->GetAddressByteSize(); - return llvm::None; + return std::nullopt; } llvm::Optional DWARFFormValue::GetFixedSize() const { diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h index 9fdab3c5273f..5c05f83d8881 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h @@ -241,12 +241,12 @@ public: llvm::Optional GetLoclistOffset(uint32_t Index) { if (!m_loclist_table_header) - return llvm::None; + return std::nullopt; std::optional Offset = m_loclist_table_header->getOffsetEntry( m_dwarf.GetDWARFContext().getOrLoadLocListsData().GetAsLLVM(), Index); if (!Offset) - return llvm::None; + return std::nullopt; return *Offset + m_loclists_base; } diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp index d0b2ef66d401..7dee031d1438 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp @@ -45,18 +45,18 @@ llvm::Optional DebugNamesDWARFIndex::ToDIERef(const DebugNames::Entry &entry) { std::optional cu_offset = entry.getCUOffset(); if (!cu_offset) - return llvm::None; + return std::nullopt; DWARFUnit *cu = m_debug_info.GetUnitAtOffset(DIERef::Section::DebugInfo, *cu_offset); if (!cu) - return llvm::None; + return std::nullopt; cu = &cu->GetNonSkeletonUnit(); if (std::optional die_offset = entry.getDIEUnitOffset()) return DIERef(cu->GetSymbolFileDWARF().GetDwoNum(), DIERef::Section::DebugInfo, cu->GetOffset() + *die_offset); - return llvm::None; + return std::nullopt; } bool DebugNamesDWARFIndex::ProcessEntry( diff --git a/lldb/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h b/lldb/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h index efc08e47a280..0006949865de 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h @@ -65,7 +65,7 @@ public: DIEInfo(dw_offset_t o, dw_tag_t t, uint32_t f, uint32_t h); explicit operator DIERef() const { - return DIERef(llvm::None, DIERef::Section::DebugInfo, die_offset); + return DIERef(std::nullopt, DIERef::Section::DebugInfo, die_offset); } }; diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp index bd29d4120e9b..880b5211491f 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp @@ -798,7 +798,7 @@ llvm::Optional SymbolFileDWARF::GetDWARFUnitIndex(uint32_t cu_idx) { if (m_lldb_cu_to_dwarf_unit.empty()) return cu_idx; if (cu_idx >= m_lldb_cu_to_dwarf_unit.size()) - return llvm::None; + return std::nullopt; return m_lldb_cu_to_dwarf_unit[cu_idx]; } @@ -1422,11 +1422,11 @@ SymbolFileDWARF::DecodeUID(lldb::user_id_t uid) { SymbolFileDWARF *dwarf = debug_map->GetSymbolFileByOSOIndex( debug_map->GetOSOIndexFromUserID(uid)); return DecodedUID{ - *dwarf, {llvm::None, DIERef::Section::DebugInfo, dw_offset_t(uid)}}; + *dwarf, {std::nullopt, DIERef::Section::DebugInfo, dw_offset_t(uid)}}; } dw_offset_t die_offset = uid; if (die_offset == DW_INVALID_OFFSET) - return llvm::None; + return std::nullopt; DIERef::Section section = uid >> 63 ? DIERef::Section::DebugTypes : DIERef::Section::DebugInfo; @@ -1507,7 +1507,7 @@ SymbolFileDWARF::GetDynamicArrayInfoForUID( if (DWARFDIE type_die = GetDIE(type_uid)) return DWARFASTParser::ParseChildArrayInfo(type_die, exe_ctx); else - return llvm::None; + return std::nullopt; } Type *SymbolFileDWARF::ResolveTypeUID(const DIERef &die_ref) { diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h index 89f935bb848b..5b5327d77a59 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h @@ -278,7 +278,7 @@ public: GetDwoSymbolFileForCompileUnit(DWARFUnit &dwarf_cu, const DWARFDebugInfoEntry &cu_die); - virtual llvm::Optional GetDwoNum() { return llvm::None; } + virtual llvm::Optional GetDwoNum() { return std::nullopt; } /// If this is a DWARF object with a single CU, return its DW_AT_dwo_id. llvm::Optional GetDWOId(); diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp index 2dfd5dc7e942..cbe166281b4b 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp @@ -784,7 +784,7 @@ SymbolFileDWARFDebugMap::GetDynamicArrayInfoForUID( SymbolFileDWARF *oso_dwarf = GetSymbolFileByOSOIndex(oso_idx); if (oso_dwarf) return oso_dwarf->GetDynamicArrayInfoForUID(type_uid, exe_ctx); - return llvm::None; + return std::nullopt; } bool SymbolFileDWARFDebugMap::CompleteType(CompilerType &compiler_type) { diff --git a/lldb/source/Plugins/SymbolFile/NativePDB/DWARFLocationExpression.cpp b/lldb/source/Plugins/SymbolFile/NativePDB/DWARFLocationExpression.cpp index b29c15336759..3d644256c8e6 100644 --- a/lldb/source/Plugins/SymbolFile/NativePDB/DWARFLocationExpression.cpp +++ b/lldb/source/Plugins/SymbolFile/NativePDB/DWARFLocationExpression.cpp @@ -165,7 +165,7 @@ static DWARFExpression MakeRegisterBasedLocationExpressionInternal( DWARFExpression lldb_private::npdb::MakeEnregisteredLocationExpression( llvm::codeview::RegisterId reg, lldb::ModuleSP module) { - return MakeRegisterBasedLocationExpressionInternal(reg, llvm::None, module); + return MakeRegisterBasedLocationExpressionInternal(reg, std::nullopt, module); } DWARFExpression lldb_private::npdb::MakeRegRelLocationExpression( @@ -275,7 +275,7 @@ lldb_private::npdb::MakeEnregisteredLocationExpressionForComposite( } MemberValLocation loc = offset_loc.second; llvm::Optional offset = - loc.is_at_reg ? llvm::None + loc.is_at_reg ? std::nullopt : llvm::Optional(loc.reg_offset); if (!MakeRegisterBasedLocationExpressionInternal( stream, (RegisterId)loc.reg_id, register_kind, offset, diff --git a/lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp b/lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp index b3b05d47f201..2b41b69a9e0b 100644 --- a/lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp +++ b/lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp @@ -150,7 +150,7 @@ TranslateCallingConvention(llvm::codeview::CallingConvention conv) { case CC::NearVector: return clang::CallingConv::CC_X86VectorCall; default: - return llvm::None; + return std::nullopt; } } @@ -284,19 +284,19 @@ llvm::Optional PdbAstBuilder::GetOrCreateDeclForUid(PdbSymUid uid) case PdbSymUidKind::Type: { clang::QualType qt = GetOrCreateType(uid.asTypeSym()); if (qt.isNull()) - return llvm::None; + return std::nullopt; if (auto *tag = qt->getAsTagDecl()) { result = tag; break; } - return llvm::None; + return std::nullopt; } default: - return llvm::None; + return std::nullopt; } if (!result) - return llvm::None; + return std::nullopt; m_uid_to_decl[toOpaqueUid(uid)] = result; return ToCompilerDecl(*result); } diff --git a/lldb/source/Plugins/SymbolFile/NativePDB/PdbIndex.cpp b/lldb/source/Plugins/SymbolFile/NativePDB/PdbIndex.cpp index 3a76f8bff316..b1e96ed838a6 100644 --- a/lldb/source/Plugins/SymbolFile/NativePDB/PdbIndex.cpp +++ b/lldb/source/Plugins/SymbolFile/NativePDB/PdbIndex.cpp @@ -80,7 +80,7 @@ PdbIndex::GetModuleIndexForAddr(uint16_t segment, uint32_t offset) const { llvm::Optional PdbIndex::GetModuleIndexForVa(lldb::addr_t va) const { auto iter = m_va_to_modi.find(va); if (iter == m_va_to_modi.end()) - return llvm::None; + return std::nullopt; return iter.value(); } diff --git a/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp b/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp index 5b8176f84c64..5e686751d762 100644 --- a/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp +++ b/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp @@ -246,12 +246,12 @@ GetNestedTagDefinition(const NestedTypeRecord &Record, // If it's a simple type, then this is something like `using foo = int`. if (Record.Type.isSimple()) - return llvm::None; + return std::nullopt; CVType cvt = tpi.getType(Record.Type); if (!IsTagRecord(cvt)) - return llvm::None; + return std::nullopt; // If it's an inner definition, then treat whatever name we have here as a // single component of a mangled name. So we can inject it into the parent's @@ -259,7 +259,7 @@ GetNestedTagDefinition(const NestedTypeRecord &Record, CVTagRecord child = CVTagRecord::create(cvt); std::string qname = std::string(parent.asTag().getUniqueName()); if (qname.size() < 4 || child.asTag().getUniqueName().size() < 4) - return llvm::None; + return std::nullopt; // qname[3] is the tag type identifier (struct, class, union, etc). Since the // inner tag type is not necessarily the same as the outer tag type, re-write @@ -272,7 +272,7 @@ GetNestedTagDefinition(const NestedTypeRecord &Record, piece.push_back('@'); qname.insert(4, std::move(piece)); if (qname != child.asTag().UniqueName) - return llvm::None; + return std::nullopt; return std::move(child); } @@ -1508,10 +1508,10 @@ void SymbolFileNativePDB::ParseInlineSite(PdbCompilandSymId id, file_offset = *next_file_offset; if (next_line_offset) { cur_line_offset = next_line_offset; - next_line_offset = llvm::None; + next_line_offset = std::nullopt; } - code_offset_base = is_terminal_entry ? llvm::None : code_offset_end; - code_offset_end = next_file_offset = llvm::None; + code_offset_base = is_terminal_entry ? std::nullopt : code_offset_end; + code_offset_end = next_file_offset = std::nullopt; } if (code_offset_base && cur_line_offset) { if (is_terminal_entry) { @@ -2108,7 +2108,7 @@ Type *SymbolFileNativePDB::ResolveTypeUID(lldb::user_id_t type_uid) { llvm::Optional SymbolFileNativePDB::GetDynamicArrayInfoForUID( lldb::user_id_t type_uid, const lldb_private::ExecutionContext *exe_ctx) { - return llvm::None; + return std::nullopt; } bool SymbolFileNativePDB::CompleteType(CompilerType &compiler_type) { @@ -2276,7 +2276,7 @@ SymbolFileNativePDB::FindSymbolScope(PdbCompilandSymId id) { // Global symbols have parent offset of 0. Return llvm::None to indicate // this. if (id.offset == 0) - return llvm::None; + return std::nullopt; return id; } @@ -2293,7 +2293,7 @@ SymbolFileNativePDB::FindSymbolScope(PdbCompilandSymId id) { if (begin.offset() > id.offset) { // We passed it. We couldn't even find this symbol record. lldbassert(false && "Invalid compiland symbol id!"); - return llvm::None; + return std::nullopt; } // We haven't found the symbol yet. Check if we need to open or close the @@ -2314,7 +2314,7 @@ SymbolFileNativePDB::FindSymbolScope(PdbCompilandSymId id) { ++begin; } if (scope_stack.empty()) - return llvm::None; + return std::nullopt; // We have a match! Return the top of the stack return scope_stack.back(); } @@ -2323,6 +2323,6 @@ llvm::Optional SymbolFileNativePDB::GetParentType(llvm::codeview::TypeIndex ti) { auto parent_iter = m_parent_types.find(ti); if (parent_iter == m_parent_types.end()) - return llvm::None; + return std::nullopt; return parent_iter->second; } diff --git a/lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp b/lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp index 7dbc13c1f01f..6e6c0e8c90cb 100644 --- a/lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp +++ b/lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp @@ -663,7 +663,7 @@ lldb::TypeSP PDBASTParser::CreateLLDBTypeFromPDBType(const PDBSymbol &type) { GetDeclarationForSymbol(type, decl); return std::make_shared( type.getSymIndexId(), m_ast.GetSymbolFile(), ConstString(name), - llvm::None, nullptr, LLDB_INVALID_UID, + std::nullopt, nullptr, LLDB_INVALID_UID, lldb_private::Type::eEncodingIsUID, decl, func_sig_ast_type, lldb_private::Type::ResolveState::Full); } break; diff --git a/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp b/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp index 3e0b733913af..7875f8a6580a 100644 --- a/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp +++ b/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp @@ -592,7 +592,7 @@ lldb_private::Type *SymbolFilePDB::ResolveTypeUID(lldb::user_id_t type_uid) { llvm::Optional SymbolFilePDB::GetDynamicArrayInfoForUID( lldb::user_id_t type_uid, const lldb_private::ExecutionContext *exe_ctx) { - return llvm::None; + return std::nullopt; } bool SymbolFilePDB::CompleteType(lldb_private::CompilerType &compiler_type) { diff --git a/lldb/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp b/lldb/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp index cc22eaeef779..262943119b00 100644 --- a/lldb/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp +++ b/lldb/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp @@ -232,7 +232,7 @@ Type *SymbolFileSymtab::ResolveTypeUID(lldb::user_id_t type_uid) { llvm::Optional SymbolFileSymtab::GetDynamicArrayInfoForUID( lldb::user_id_t type_uid, const lldb_private::ExecutionContext *exe_ctx) { - return llvm::None; + return std::nullopt; } bool SymbolFileSymtab::CompleteType(lldb_private::CompilerType &compiler_type) { diff --git a/lldb/source/Plugins/TraceExporter/common/TraceHTR.cpp b/lldb/source/Plugins/TraceExporter/common/TraceHTR.cpp index aab2223dd396..a99324db1da2 100644 --- a/lldb/source/Plugins/TraceExporter/common/TraceHTR.cpp +++ b/lldb/source/Plugins/TraceExporter/common/TraceHTR.cpp @@ -349,7 +349,7 @@ HTRBlockLayerUP lldb_private::BasicSuperBlockMerge(IHTRLayer &layer) { // Tail logic construct_next_layer(i - superblock_size + 1, superblock_size); // Reset the block_head since the prev super block has come to and end - superblock_head = llvm::None; + superblock_head = std::nullopt; superblock_size = 0; } else if (isHead) { if (superblock_size) { // this handles (tail, head) adjacency - @@ -369,7 +369,7 @@ HTRBlockLayerUP lldb_private::BasicSuperBlockMerge(IHTRLayer &layer) { // End previous super block construct_next_layer(i - superblock_size + 1, superblock_size); // Reset the block_head since the prev super block has come to and end - superblock_head = llvm::None; + superblock_head = std::nullopt; superblock_size = 0; } else { if (!superblock_head) diff --git a/lldb/source/Plugins/TraceExporter/ctf/CommandObjectThreadTraceExportCTF.cpp b/lldb/source/Plugins/TraceExporter/ctf/CommandObjectThreadTraceExportCTF.cpp index df8da3967fc6..cc4ebfff6595 100644 --- a/lldb/source/Plugins/TraceExporter/ctf/CommandObjectThreadTraceExportCTF.cpp +++ b/lldb/source/Plugins/TraceExporter/ctf/CommandObjectThreadTraceExportCTF.cpp @@ -54,7 +54,7 @@ Status CommandObjectThreadTraceExportCTF::CommandOptions::SetOptionValue( void CommandObjectThreadTraceExportCTF::CommandOptions::OptionParsingStarting( ExecutionContext *execution_context) { m_file.clear(); - m_thread_index = None; + m_thread_index = std::nullopt; } llvm::ArrayRef diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp index a55a4911e023..bd017dab20bf 100644 --- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp +++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp @@ -3716,15 +3716,15 @@ bool TypeSystemClang::SupportsLanguage(lldb::LanguageType language) { Optional TypeSystemClang::GetCXXClassName(const CompilerType &type) { if (!type) - return llvm::None; + return std::nullopt; clang::QualType qual_type(ClangUtil::GetCanonicalQualType(type)); if (qual_type.isNull()) - return llvm::None; + return std::nullopt; clang::CXXRecordDecl *cxx_record_decl = qual_type->getAsCXXRecordDecl(); if (!cxx_record_decl) - return llvm::None; + return std::nullopt; return std::string(cxx_record_decl->getIdentifier()->getNameStart()); } @@ -4719,7 +4719,7 @@ TypeSystemClang::GetBitSize(lldb::opaque_compiler_type_t type, if (GetCompleteType(type)) return getASTContext().getTypeSize(qual_type); else - return None; + return std::nullopt; break; case clang::Type::ObjCInterface: @@ -4769,7 +4769,7 @@ TypeSystemClang::GetBitSize(lldb::opaque_compiler_type_t type, return bit_size; } } - return None; + return std::nullopt; } llvm::Optional @@ -5345,7 +5345,7 @@ GetDynamicArrayInfo(TypeSystemClang &ast, SymbolFile *sym_file, if (auto *metadata = ast.GetMetadata(qual_type.getTypePtr())) return sym_file->GetDynamicArrayInfoForUID(metadata->GetUserID(), exe_ctx); - return llvm::None; + return std::nullopt; } uint32_t TypeSystemClang::GetNumChildren(lldb::opaque_compiler_type_t type, @@ -7290,11 +7290,11 @@ TypeSystemClang::GetIntegralTemplateArgument(lldb::opaque_compiler_type_t type, const clang::ClassTemplateSpecializationDecl *template_decl = GetAsTemplateSpecialization(type); if (!template_decl) - return llvm::None; + return std::nullopt; const auto *arg = GetNthTemplateArgument(template_decl, idx, expand_pack); if (!arg || arg->getKind() != clang::TemplateArgument::Integral) - return llvm::None; + return std::nullopt; return {{arg->getAsIntegral(), GetType(arg->getIntegralType())}}; } @@ -9890,7 +9890,7 @@ public: } // namespace char ScratchTypeSystemClang::ID; -const std::nullopt_t ScratchTypeSystemClang::DefaultAST = llvm::None; +const std::nullopt_t ScratchTypeSystemClang::DefaultAST = std::nullopt; ScratchTypeSystemClang::ScratchTypeSystemClang(Target &target, llvm::Triple triple) diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h index 276b66b3b153..9cf7cd339e92 100644 --- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h +++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h @@ -744,7 +744,7 @@ public: ExecutionContextScope *exe_scope) { if (llvm::Optional bit_size = GetBitSize(type, exe_scope)) return (*bit_size + 7) / 8; - return llvm::None; + return std::nullopt; } llvm::Optional diff --git a/lldb/source/Symbol/CompileUnit.cpp b/lldb/source/Symbol/CompileUnit.cpp index 8b979d352fc8..6d2233e42734 100644 --- a/lldb/source/Symbol/CompileUnit.cpp +++ b/lldb/source/Symbol/CompileUnit.cpp @@ -237,7 +237,8 @@ uint32_t CompileUnit::FindLineEntry(uint32_t start_idx, uint32_t line, return UINT32_MAX; // TODO: Handle SourceLocationSpec column information - SourceLocationSpec location_spec(*file_spec_ptr, line, /*column=*/llvm::None, + SourceLocationSpec location_spec(*file_spec_ptr, line, + /*column=*/std::nullopt, /*check_inlines=*/false, exact); LineTable *line_table = GetLineTable(); @@ -321,7 +322,7 @@ void CompileUnit::ResolveSymbolContext( const llvm::Optional column = src_location_spec.GetColumn() ? llvm::Optional(line_entry.column) - : llvm::None; + : std::nullopt; SourceLocationSpec found_entry(line_entry.file, line_entry.line, column, inlines, exact); diff --git a/lldb/source/Symbol/CompilerType.cpp b/lldb/source/Symbol/CompilerType.cpp index 34dc7140c1fd..20e63f65584c 100644 --- a/lldb/source/Symbol/CompilerType.cpp +++ b/lldb/source/Symbol/CompilerType.cpp @@ -765,7 +765,7 @@ CompilerType::GetIntegralTemplateArgument(size_t idx, bool expand_pack) const { if (IsValid()) if (auto type_system_sp = GetTypeSystem()) return type_system_sp->GetIntegralTemplateArgument(m_type, idx, expand_pack); - return llvm::None; + return std::nullopt; } CompilerType CompilerType::GetTypeForFormatters() const { diff --git a/lldb/source/Symbol/DWARFCallFrameInfo.cpp b/lldb/source/Symbol/DWARFCallFrameInfo.cpp index 4e51bd411a75..30d781aaf455 100644 --- a/lldb/source/Symbol/DWARFCallFrameInfo.cpp +++ b/lldb/source/Symbol/DWARFCallFrameInfo.cpp @@ -197,7 +197,7 @@ bool DWARFCallFrameInfo::GetAddressRange(Address addr, AddressRange &range) { llvm::Optional DWARFCallFrameInfo::GetFirstFDEEntryInRange(const AddressRange &range) { if (!m_section_sp || m_section_sp->IsEncrypted()) - return llvm::None; + return std::nullopt; GetFDEIndex(); @@ -208,7 +208,7 @@ DWARFCallFrameInfo::GetFirstFDEEntryInRange(const AddressRange &range) { FDEEntryMap::Range(start_file_addr, range.GetByteSize()))) return *fde; - return llvm::None; + return std::nullopt; } void DWARFCallFrameInfo::GetFunctionAddressAndSizeVector( diff --git a/lldb/source/Symbol/Function.cpp b/lldb/source/Symbol/Function.cpp index 8ec4bc90cd13..5ed0e66bdacb 100644 --- a/lldb/source/Symbol/Function.cpp +++ b/lldb/source/Symbol/Function.cpp @@ -306,7 +306,7 @@ llvm::ArrayRef> Function::GetCallEdges() { Block &block = GetBlock(/*can_create*/true); SymbolFile *sym_file = block.GetSymbolFile(); if (!sym_file) - return llvm::None; + return std::nullopt; // Lazily read call site information from the SymbolFile. m_call_edges = sym_file->ParseCallEdgesInFunction(GetID()); diff --git a/lldb/source/Symbol/PostfixExpression.cpp b/lldb/source/Symbol/PostfixExpression.cpp index e80e134f29bb..62be3ba254de 100644 --- a/lldb/source/Symbol/PostfixExpression.cpp +++ b/lldb/source/Symbol/PostfixExpression.cpp @@ -23,7 +23,7 @@ using namespace lldb_private::dwarf; static llvm::Optional GetBinaryOpType(llvm::StringRef token) { if (token.size() != 1) - return llvm::None; + return std::nullopt; switch (token[0]) { case '@': return BinaryOpNode::Align; @@ -32,14 +32,14 @@ GetBinaryOpType(llvm::StringRef token) { case '+': return BinaryOpNode::Plus; } - return llvm::None; + return std::nullopt; } static llvm::Optional GetUnaryOpType(llvm::StringRef token) { if (token == "^") return UnaryOpNode::Deref; - return llvm::None; + return std::nullopt; } Node *postfix::ParseOneExpression(llvm::StringRef expr, diff --git a/lldb/source/Symbol/SymbolFileOnDemand.cpp b/lldb/source/Symbol/SymbolFileOnDemand.cpp index 7f8a2bc146ad..796d306716f1 100644 --- a/lldb/source/Symbol/SymbolFileOnDemand.cpp +++ b/lldb/source/Symbol/SymbolFileOnDemand.cpp @@ -203,7 +203,7 @@ SymbolFileOnDemand::GetDynamicArrayInfoForUID( if (!m_debug_info_enabled) { LLDB_LOG(GetLog(), "[{0}] {1} is skipped", GetSymbolFileName(), __FUNCTION__); - return llvm::None; + return std::nullopt; } return m_sym_file_impl->GetDynamicArrayInfoForUID(type_uid, exe_ctx); } diff --git a/lldb/source/Symbol/TypeSystem.cpp b/lldb/source/Symbol/TypeSystem.cpp index 7671f11847f4..d1d78fc1eec5 100644 --- a/lldb/source/Symbol/TypeSystem.cpp +++ b/lldb/source/Symbol/TypeSystem.cpp @@ -135,7 +135,7 @@ CompilerType TypeSystem::GetTypeTemplateArgument(opaque_compiler_type_t type, llvm::Optional TypeSystem::GetIntegralTemplateArgument(opaque_compiler_type_t type, size_t idx, bool expand_pack) { - return llvm::None; + return std::nullopt; } LazyBool TypeSystem::ShouldPrintAsOneLiner(void *type, ValueObject *valobj) { @@ -177,7 +177,7 @@ TypeSystem::CreateUtilityFunction(std::string text, std::string name) { } llvm::Optional TypeSystem::ReportStatistics() { - return llvm::None; + return std::nullopt; } #pragma mark TypeSystemMap diff --git a/lldb/source/Symbol/UnwindPlan.cpp b/lldb/source/Symbol/UnwindPlan.cpp index bd4690547c6b..51301e4ee43f 100644 --- a/lldb/source/Symbol/UnwindPlan.cpp +++ b/lldb/source/Symbol/UnwindPlan.cpp @@ -71,10 +71,10 @@ void UnwindPlan::Row::RegisterLocation::SetIsDWARFExpression( static llvm::Optional> GetByteOrderAndAddrSize(Thread *thread) { if (!thread) - return llvm::None; + return std::nullopt; ProcessSP process_sp = thread->GetProcess(); if (!process_sp) - return llvm::None; + return std::nullopt; ArchSpec arch = process_sp->GetTarget().GetArchitecture(); return std::make_pair(arch.GetByteOrder(), arch.GetAddressByteSize()); } diff --git a/lldb/source/Symbol/UnwindTable.cpp b/lldb/source/Symbol/UnwindTable.cpp index fe69e41b3638..77681c477a4a 100644 --- a/lldb/source/Symbol/UnwindTable.cpp +++ b/lldb/source/Symbol/UnwindTable.cpp @@ -108,7 +108,7 @@ llvm::Optional UnwindTable::GetAddressRange(const Address &addr, if (m_debug_frame_up && m_debug_frame_up->GetAddressRange(addr, range)) return range; - return llvm::None; + return std::nullopt; } FuncUnwindersSP diff --git a/lldb/source/Target/MemoryTagMap.cpp b/lldb/source/Target/MemoryTagMap.cpp index 846eef9209da..4fe5c8b2b338 100644 --- a/lldb/source/Target/MemoryTagMap.cpp +++ b/lldb/source/Target/MemoryTagMap.cpp @@ -59,6 +59,6 @@ llvm::Optional MemoryTagMap::GetTag(lldb::addr_t addr) const { // were inserted. auto found = m_addr_to_tag.find(addr); if (found == m_addr_to_tag.end()) - return llvm::None; + return std::nullopt; return found->second; } diff --git a/lldb/source/Target/PathMappingList.cpp b/lldb/source/Target/PathMappingList.cpp index cbee5934846a..61a4841fbe5f 100644 --- a/lldb/source/Target/PathMappingList.cpp +++ b/lldb/source/Target/PathMappingList.cpp @@ -235,7 +235,7 @@ PathMappingList::ReverseRemapPath(const FileSpec &file, FileSpec &fixed) const { AppendPathComponents(fixed, path_ref, orig_style); return removed_prefix; } - return llvm::None; + return std::nullopt; } llvm::Optional PathMappingList::FindFile(const FileSpec &orig_spec) const { diff --git a/lldb/source/Target/Platform.cpp b/lldb/source/Target/Platform.cpp index 7bb2b1ccf7cb..0e258f0f96a6 100644 --- a/lldb/source/Target/Platform.cpp +++ b/lldb/source/Target/Platform.cpp @@ -1810,7 +1810,7 @@ lldb::ProcessSP Platform::DoConnectProcess(llvm::StringRef connect_url, if (synchronous) { EventSP event_sp; - process_sp->WaitForProcessToStop(llvm::None, &event_sp, true, listener_sp, + process_sp->WaitForProcessToStop(std::nullopt, &event_sp, true, listener_sp, nullptr); process_sp->RestoreProcessEvents(); bool pop_process_io_handler = false; diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp index 694e5dc93e67..f12a01df86b7 100644 --- a/lldb/source/Target/Process.cpp +++ b/lldb/source/Target/Process.cpp @@ -1372,8 +1372,8 @@ Status Process::ResumeSynchronous(Stream *stream) { Status error = PrivateResume(); if (error.Success()) { - StateType state = WaitForProcessToStop(llvm::None, nullptr, true, - listener_sp, stream); + StateType state = + WaitForProcessToStop(std::nullopt, nullptr, true, listener_sp, stream); const bool must_be_alive = false; // eStateExited is ok, so this must be false if (!StateIsStoppedState(state, must_be_alive)) @@ -2636,7 +2636,7 @@ Status Process::LoadCore() { // Wait for a stopped event since we just posted one above... lldb::EventSP event_sp; StateType state = - WaitForProcessToStop(llvm::None, &event_sp, true, listener_sp); + WaitForProcessToStop(std::nullopt, &event_sp, true, listener_sp); if (!StateIsStoppedState(state, false)) { Log *log = GetLog(LLDBLog::Process); @@ -3038,7 +3038,7 @@ Status Process::ConnectRemote(llvm::StringRef remote_url) { if (error.Success()) { if (GetID() != LLDB_INVALID_PROCESS_ID) { EventSP event_sp; - StateType state = WaitForProcessStopPrivate(event_sp, llvm::None); + StateType state = WaitForProcessStopPrivate(event_sp, std::nullopt); if (state == eStateStopped || state == eStateCrashed) { // If we attached and actually have a process on the other end, then @@ -3785,7 +3785,7 @@ thread_result_t Process::RunPrivateStateThread(bool is_secondary_thread) { bool interrupt_requested = false; while (!exit_now) { EventSP event_sp; - GetEventsPrivate(event_sp, llvm::None, control_only); + GetEventsPrivate(event_sp, std::nullopt, control_only); if (event_sp->BroadcasterIs(&m_private_state_control_broadcaster)) { LLDB_LOGF(log, "Process::%s (arg = %p, pid = %" PRIu64 @@ -4609,7 +4609,7 @@ GetExpressionTimeout(const EvaluateExpressionOptions &options, return GetOneThreadExpressionTimeout(options); if (!options.GetTimeout()) - return llvm::None; + return std::nullopt; else return *options.GetTimeout() - GetOneThreadExpressionTimeout(options); } @@ -4663,7 +4663,7 @@ HandleStoppedEvent(lldb::tid_t thread_id, const ThreadPlanSP &thread_plan_sp, if (!handle_interrupts && Process::ProcessEventData::GetInterruptedFromEvent(event_sp.get())) - return llvm::None; + return std::nullopt; LLDB_LOG(log, "thread plan did not successfully complete"); if (!options.DoesUnwindOnError()) diff --git a/lldb/source/Target/ProcessTrace.cpp b/lldb/source/Target/ProcessTrace.cpp index 6b147cb285a7..061af9e0e520 100644 --- a/lldb/source/Target/ProcessTrace.cpp +++ b/lldb/source/Target/ProcessTrace.cpp @@ -63,7 +63,7 @@ void ProcessTrace::DidAttach(ArchSpec &process_arch) { SetPrivateState(eStateStopped); EventSP event_sp; - WaitForProcessToStop(llvm::None, &event_sp, true, listener_sp); + WaitForProcessToStop(std::nullopt, &event_sp, true, listener_sp); RestoreProcessEvents(); diff --git a/lldb/source/Target/RemoteAwarePlatform.cpp b/lldb/source/Target/RemoteAwarePlatform.cpp index c7b0ade845cf..ea3011eebdc1 100644 --- a/lldb/source/Target/RemoteAwarePlatform.cpp +++ b/lldb/source/Target/RemoteAwarePlatform.cpp @@ -308,13 +308,13 @@ bool RemoteAwarePlatform::GetRemoteOSVersion() { llvm::Optional RemoteAwarePlatform::GetRemoteOSBuildString() { if (m_remote_platform_sp) return m_remote_platform_sp->GetRemoteOSBuildString(); - return llvm::None; + return std::nullopt; } llvm::Optional RemoteAwarePlatform::GetRemoteOSKernelDescription() { if (m_remote_platform_sp) return m_remote_platform_sp->GetRemoteOSKernelDescription(); - return llvm::None; + return std::nullopt; } ArchSpec RemoteAwarePlatform::GetRemoteSystemArchitecture() { diff --git a/lldb/source/Target/Statistics.cpp b/lldb/source/Target/Statistics.cpp index 268b7ccaf3f9..c739ac7058ca 100644 --- a/lldb/source/Target/Statistics.cpp +++ b/lldb/source/Target/Statistics.cpp @@ -158,7 +158,7 @@ json::Value TargetStats::ToJSON(Target &target) { void TargetStats::SetLaunchOrAttachTime() { m_launch_or_attach_time = StatsClock::now(); - m_first_private_stop_time = llvm::None; + m_first_private_stop_time = std::nullopt; } void TargetStats::SetFirstPrivateStopTime() { diff --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp index 22071b76a805..bbb685f117ab 100644 --- a/lldb/source/Target/Target.cpp +++ b/lldb/source/Target/Target.cpp @@ -3176,7 +3176,7 @@ Status Target::Launch(ProcessLaunchInfo &launch_info, Stream *stream) { assert(launch_info.GetHijackListener()); EventSP first_stop_event_sp; - state = m_process_sp->WaitForProcessToStop(llvm::None, &first_stop_event_sp, + state = m_process_sp->WaitForProcessToStop(std::nullopt, &first_stop_event_sp, rebroadcast_first_stop, launch_info.GetHijackListener()); m_process_sp->RestoreProcessEvents(); @@ -3332,8 +3332,9 @@ Status Target::Attach(ProcessAttachInfo &attach_info, Stream *stream) { if (async) { process_sp->RestoreProcessEvents(); } else { - state = process_sp->WaitForProcessToStop( - llvm::None, nullptr, false, attach_info.GetHijackListener(), stream); + state = process_sp->WaitForProcessToStop(std::nullopt, nullptr, false, + attach_info.GetHijackListener(), + stream); process_sp->RestoreProcessEvents(); if (state != eStateStopped) { diff --git a/lldb/source/Target/Trace.cpp b/lldb/source/Target/Trace.cpp index 68220253c45e..f4c35bf1b124 100644 --- a/lldb/source/Target/Trace.cpp +++ b/lldb/source/Target/Trace.cpp @@ -52,7 +52,7 @@ template static Optional Lookup(DenseMap &map, K k) { auto it = map.find(k); if (it == map.end()) - return None; + return std::nullopt; return it->second; } @@ -69,7 +69,7 @@ template static Optional Lookup(DenseMap> &map, K1 k1, K2 k2) { auto it = map.find(k1); if (it == map.end()) - return None; + return std::nullopt; return Lookup(it->second, k2); } @@ -236,7 +236,7 @@ Trace::GetLiveThreadBinaryData(lldb::tid_t tid, llvm::StringRef kind) { kind.data(), tid); TraceGetBinaryDataRequest request{GetPluginName().str(), kind.str(), tid, - /*cpu_id=*/None}; + /*cpu_id=*/std::nullopt}; return GetLiveTraceBinaryData(request, *size); } @@ -254,7 +254,7 @@ Trace::GetLiveCpuBinaryData(lldb::cpu_id_t cpu_id, llvm::StringRef kind) { kind.data(), cpu_id); TraceGetBinaryDataRequest request{GetPluginName().str(), kind.str(), - /*tid=*/None, cpu_id}; + /*tid=*/std::nullopt, cpu_id}; return m_live_process->TraceGetBinaryData(request); } @@ -267,7 +267,8 @@ Trace::GetLiveProcessBinaryData(llvm::StringRef kind) { "Tracing data \"%s\" is not available for the process.", kind.data()); TraceGetBinaryDataRequest request{GetPluginName().str(), kind.str(), - /*tid=*/None, /*cpu_id*/ None}; + /*tid=*/std::nullopt, + /*cpu_id*/ std::nullopt}; return GetLiveTraceBinaryData(request, *size); } diff --git a/lldb/source/Target/TraceDumper.cpp b/lldb/source/Target/TraceDumper.cpp index 268dc039365f..374c8ad92265 100644 --- a/lldb/source/Target/TraceDumper.cpp +++ b/lldb/source/Target/TraceDumper.cpp @@ -22,7 +22,7 @@ using namespace llvm; /// The given string or \b None if it's empty. static Optional ToOptionalString(const char *s) { if (!s) - return None; + return std::nullopt; return s; } @@ -409,7 +409,7 @@ public: m_j.attribute("timestamp_ns", item.timestamp ? Optional( std::to_string(*item.timestamp)) - : None); + : std::nullopt); if (item.event) { DumpEvent(item); diff --git a/lldb/source/Utility/FileSpec.cpp b/lldb/source/Utility/FileSpec.cpp index e4d5405445ea..519e516a50c3 100644 --- a/lldb/source/Utility/FileSpec.cpp +++ b/lldb/source/Utility/FileSpec.cpp @@ -313,7 +313,7 @@ llvm::Optional FileSpec::GuessPathStyle(llvm::StringRef absolut (absolute_path.substr(1, 2) == R"(:\)" || absolute_path.substr(1, 2) == R"(:/)")) return Style::windows; - return llvm::None; + return std::nullopt; } // Dump the object to the supplied stream. If the object contains a valid diff --git a/lldb/source/Utility/StringExtractorGDBRemote.cpp b/lldb/source/Utility/StringExtractorGDBRemote.cpp index fc740615dd05..882af91988c0 100644 --- a/lldb/source/Utility/StringExtractorGDBRemote.cpp +++ b/lldb/source/Utility/StringExtractorGDBRemote.cpp @@ -652,7 +652,7 @@ StringExtractorGDBRemote::GetPidTid(lldb::pid_t default_pid) { } else if (view.consumeInteger(16, pid) || pid == 0) { // not a valid hex integer OR unsupported pid 0 m_index = UINT64_MAX; - return llvm::None; + return std::nullopt; } // "." must follow if we expect TID too; otherwise, we assume -1 @@ -671,7 +671,7 @@ StringExtractorGDBRemote::GetPidTid(lldb::pid_t default_pid) { } else if (view.consumeInteger(16, tid) || tid == 0 || pid == AllProcesses) { // not a valid hex integer OR tid 0 OR pid -1 + a specific tid m_index = UINT64_MAX; - return llvm::None; + return std::nullopt; } // update m_index diff --git a/lldb/source/Utility/UriParser.cpp b/lldb/source/Utility/UriParser.cpp index b7771d57aefd..3da90f1d5b86 100644 --- a/lldb/source/Utility/UriParser.cpp +++ b/lldb/source/Utility/UriParser.cpp @@ -30,7 +30,7 @@ llvm::Optional URI::Parse(llvm::StringRef uri) { const llvm::StringRef kSchemeSep("://"); auto pos = uri.find(kSchemeSep); if (pos == std::string::npos) - return llvm::None; + return std::nullopt; // Extract path. ret.scheme = uri.substr(0, pos); @@ -50,12 +50,12 @@ llvm::Optional URI::Parse(llvm::StringRef uri) { // hostname is enclosed with square brackets. pos = host_port.rfind(']'); if (pos == std::string::npos) - return llvm::None; + return std::nullopt; ret.hostname = host_port.substr(1, pos - 1); host_port = host_port.drop_front(pos + 1); if (!host_port.empty() && !host_port.consume_front(":")) - return llvm::None; + return std::nullopt; } else { std::tie(ret.hostname, host_port) = host_port.split(':'); } @@ -64,10 +64,10 @@ llvm::Optional URI::Parse(llvm::StringRef uri) { if (!host_port.empty()) { uint16_t port_value = 0; if (host_port.getAsInteger(0, port_value)) - return llvm::None; + return std::nullopt; ret.port = port_value; } else - ret.port = llvm::None; + ret.port = std::nullopt; return ret; } diff --git a/lldb/source/Utility/UserIDResolver.cpp b/lldb/source/Utility/UserIDResolver.cpp index 73bdde77cc0f..20a377924369 100644 --- a/lldb/source/Utility/UserIDResolver.cpp +++ b/lldb/source/Utility/UserIDResolver.cpp @@ -18,23 +18,23 @@ llvm::Optional UserIDResolver::Get( llvm::Optional (UserIDResolver::*do_get)(id_t)) { std::lock_guard guard(m_mutex); - auto iter_bool = cache.try_emplace(id, llvm::None); + auto iter_bool = cache.try_emplace(id, std::nullopt); if (iter_bool.second) iter_bool.first->second = (this->*do_get)(id); if (iter_bool.first->second) return llvm::StringRef(*iter_bool.first->second); - return llvm::None; + return std::nullopt; } namespace { class NoopResolver : public UserIDResolver { protected: llvm::Optional DoGetUserName(id_t uid) override { - return llvm::None; + return std::nullopt; } llvm::Optional DoGetGroupName(id_t gid) override { - return llvm::None; + return std::nullopt; } }; } // namespace diff --git a/lldb/tools/lldb-server/lldb-platform.cpp b/lldb/tools/lldb-server/lldb-platform.cpp index 9f8b4c7d67ee..0211de77bb75 100644 --- a/lldb/tools/lldb-server/lldb-platform.cpp +++ b/lldb/tools/lldb-server/lldb-platform.cpp @@ -366,7 +366,7 @@ int main_platform(int argc, char *argv[]) { bool interrupt = false; bool done = false; while (!interrupt && !done) { - if (platform.GetPacketAndSendResponse(llvm::None, error, interrupt, + if (platform.GetPacketAndSendResponse(std::nullopt, error, interrupt, done) != GDBRemoteCommunication::PacketResult::Success) break; diff --git a/lldb/tools/lldb-vscode/JSONUtils.h b/lldb/tools/lldb-vscode/JSONUtils.h index c812ec87beab..011c107b9ab1 100644 --- a/lldb/tools/lldb-vscode/JSONUtils.h +++ b/lldb/tools/lldb-vscode/JSONUtils.h @@ -208,9 +208,10 @@ void SetValueForKey(lldb::SBValue &v, llvm::json::Object &object, /// It is useful to ensure the same line /// provided by the setBreakpoints request are returned to the IDE as a /// fallback. -void AppendBreakpoint(lldb::SBBreakpoint &bp, llvm::json::Array &breakpoints, - llvm::Optional request_path = llvm::None, - llvm::Optional request_line = llvm::None); +void AppendBreakpoint( + lldb::SBBreakpoint &bp, llvm::json::Array &breakpoints, + llvm::Optional request_path = std::nullopt, + llvm::Optional request_line = std::nullopt); /// Converts breakpoint location to a Visual Studio Code "Breakpoint" /// @@ -235,8 +236,8 @@ void AppendBreakpoint(lldb::SBBreakpoint &bp, llvm::json::Array &breakpoints, /// definition outlined by Microsoft. llvm::json::Value CreateBreakpoint(lldb::SBBreakpoint &bp, - llvm::Optional request_path = llvm::None, - llvm::Optional request_line = llvm::None); + llvm::Optional request_path = std::nullopt, + llvm::Optional request_line = std::nullopt); /// Converts a LLDB module to a VS Code DAP module for use in "modules" events. /// diff --git a/lldb/tools/lldb-vscode/ProgressEvent.cpp b/lldb/tools/lldb-vscode/ProgressEvent.cpp index 5c1f8c63ebef..69a8a2eabb95 100644 --- a/lldb/tools/lldb-vscode/ProgressEvent.cpp +++ b/lldb/tools/lldb-vscode/ProgressEvent.cpp @@ -69,14 +69,14 @@ Optional ProgressEvent::Create(uint64_t progress_id, const ProgressEvent *prev_event) { // If it's an update without a previous event, we abort if (completed > 0 && completed < total && !prev_event) - return None; + return std::nullopt; ProgressEvent event(progress_id, message, completed, total, prev_event); // We shouldn't show unnamed start events in the IDE if (event.GetEventType() == progressStart && event.GetEventName().empty()) - return None; + return std::nullopt; if (prev_event && prev_event->EqualsForIDE(event)) - return None; + return std::nullopt; return event; } @@ -163,7 +163,7 @@ const ProgressEvent &ProgressEventManager::GetMostRecentEvent() const { void ProgressEventManager::Update(uint64_t progress_id, uint64_t completed, uint64_t total) { if (Optional event = ProgressEvent::Create( - progress_id, None, completed, total, &GetMostRecentEvent())) { + progress_id, std::nullopt, completed, total, &GetMostRecentEvent())) { if (event->GetEventType() == progressEnd) m_finished = true;