From 8b5c302efb26634126bb57c20727a13ec2237558 Mon Sep 17 00:00:00 2001 From: Kazu Hirata Date: Sat, 10 Dec 2022 17:06:43 -0800 Subject: [PATCH] [lldb] Use std::optional instead of None in comments (NFC) 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/include/lldb/Target/TraceCursor.h | 3 ++- lldb/include/lldb/Target/UnixSignals.h | 4 ++-- lldb/include/lldb/Utility/Predicate.h | 6 ++++-- lldb/include/lldb/Utility/TraceGDBRemotePackets.h | 2 +- .../Plugins/ExpressionParser/Clang/CppModuleConfiguration.cpp | 2 +- .../Plugins/Instruction/RISCV/EmulateInstructionRISCV.cpp | 2 +- lldb/source/Plugins/Process/Linux/IntelPTProcessTrace.h | 6 +++--- lldb/source/Plugins/Trace/intel-pt/LibiptDecoder.h | 6 +++--- lldb/source/Plugins/Trace/intel-pt/TraceCursorIntelPT.h | 10 +++++----- lldb/source/Plugins/Trace/intel-pt/TraceIntelPTBundleSaver.cpp | 6 +++--- .../Plugins/Trace/intel-pt/TraceIntelPTMultiCpuDecoder.h | 4 ++-- lldb/source/Plugins/TraceExporter/common/TraceHTR.h | 6 +++--- lldb/source/Target/TraceDumper.cpp | 2 +- 13 files changed, 31 insertions(+), 28 deletions(-) diff --git a/lldb/include/lldb/Target/TraceCursor.h b/lldb/include/lldb/Target/TraceCursor.h index ee5014f..dfb113f 100644 --- a/lldb/include/lldb/Target/TraceCursor.h +++ b/lldb/include/lldb/Target/TraceCursor.h @@ -278,7 +278,8 @@ public: /// /// \return /// A string representing some metadata associated with a - /// \a eTraceEventSyncPoint event. \b None if no metadata is available. + /// \a eTraceEventSyncPoint event. \b std::nullopt if no metadata is + /// available. virtual llvm::Optional GetSyncPointMetadata() const = 0; /// \} diff --git a/lldb/include/lldb/Target/UnixSignals.h b/lldb/include/lldb/Target/UnixSignals.h index 34f4e30..6646078 100644 --- a/lldb/include/lldb/Target/UnixSignals.h +++ b/lldb/include/lldb/Target/UnixSignals.h @@ -101,8 +101,8 @@ public: uint64_t GetVersion() const; // Returns a vector of signals that meet criteria provided in arguments. Each - // should_[suppress|stop|notify] flag can be None - no filtering by this - // flag true - only signals that have it set to true are returned false - + // should_[suppress|stop|notify] flag can be std::nullopt - no filtering by + // this flag true - only signals that have it set to true are returned false - // only signals that have it set to true are returned std::vector GetFilteredSignals(llvm::Optional should_suppress, llvm::Optional should_stop, diff --git a/lldb/include/lldb/Utility/Predicate.h b/lldb/include/lldb/Utility/Predicate.h index 3496aff..9b65ec1 100644 --- a/lldb/include/lldb/Utility/Predicate.h +++ b/lldb/include/lldb/Utility/Predicate.h @@ -116,7 +116,8 @@ public: /// How long to wait for the condition to hold. /// /// \return - /// m_value if Cond(m_value) is true, None otherwise (timeout occurred). + /// m_value if Cond(m_value) is true, std::nullopt otherwise (timeout + /// occurred). template llvm::Optional WaitFor(C Cond, const Timeout &timeout) { std::unique_lock lock(m_mutex); @@ -177,7 +178,8 @@ public: /// How long to wait for the condition to hold. /// /// \return - /// m_value if m_value != value, None otherwise (timeout occurred). + /// m_value if m_value != value, std::nullopt otherwise (timeout + /// occurred). llvm::Optional WaitForValueNotEqualTo(T value, const Timeout &timeout = std::nullopt) { diff --git a/lldb/include/lldb/Utility/TraceGDBRemotePackets.h b/lldb/include/lldb/Utility/TraceGDBRemotePackets.h index bfa6821..1b35b05 100644 --- a/lldb/include/lldb/Utility/TraceGDBRemotePackets.h +++ b/lldb/include/lldb/Utility/TraceGDBRemotePackets.h @@ -49,7 +49,7 @@ struct TraceStartRequest { llvm::Optional> tids; /// \return - /// \b true if \a tids is \a None, i.e. whole process tracing. + /// \b true if \a tids is \a std::nullopt, i.e. whole process tracing. bool IsProcessTracing() const; }; diff --git a/lldb/source/Plugins/ExpressionParser/Clang/CppModuleConfiguration.cpp b/lldb/source/Plugins/ExpressionParser/Clang/CppModuleConfiguration.cpp index 65ad748..36ecc59 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/CppModuleConfiguration.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/CppModuleConfiguration.cpp @@ -46,7 +46,7 @@ getTargetIncludePaths(const llvm::Triple &triple) { } /// Returns the include path matching the given pattern for the given file -/// path (or None if the path doesn't match the pattern). +/// path (or std::nullopt if the path doesn't match the pattern). static llvm::Optional guessIncludePath(llvm::StringRef path_to_file, llvm::StringRef pattern) { if (pattern.empty()) diff --git a/lldb/source/Plugins/Instruction/RISCV/EmulateInstructionRISCV.cpp b/lldb/source/Plugins/Instruction/RISCV/EmulateInstructionRISCV.cpp index 96d2c3f..b3fefb2f 100644 --- a/lldb/source/Plugins/Instruction/RISCV/EmulateInstructionRISCV.cpp +++ b/lldb/source/Plugins/Instruction/RISCV/EmulateInstructionRISCV.cpp @@ -32,7 +32,7 @@ LLDB_PLUGIN_DEFINE_ADV(EmulateInstructionRISCV, InstructionRISCV) namespace lldb_private { /// Returns all values wrapped in Optional, or std::nullopt if any of the values -/// is None. +/// is std::nullopt. template static llvm::Optional> zipOpt(llvm::Optional &&...ts) { if ((ts.has_value() && ...)) diff --git a/lldb/source/Plugins/Process/Linux/IntelPTProcessTrace.h b/lldb/source/Plugins/Process/Linux/IntelPTProcessTrace.h index 2fa6d85..bc2ef8c 100644 --- a/lldb/source/Plugins/Process/Linux/IntelPTProcessTrace.h +++ b/lldb/source/Plugins/Process/Linux/IntelPTProcessTrace.h @@ -37,9 +37,9 @@ public: virtual llvm::Error TraceStop(lldb::tid_t tid) = 0; /// \return - /// \b None if this instance doesn't support the requested data, an \a - /// llvm::Error if this isntance supports it but fails at fetching it, and - /// \b Error::success() otherwise. + /// \b std::nullopt if this instance doesn't support the requested data, an + /// \a llvm::Error if this isntance supports it but fails at fetching it, + /// and \b Error::success() otherwise. virtual llvm::Expected>> TryGetBinaryData(const TraceGetBinaryDataRequest &request) = 0; }; diff --git a/lldb/source/Plugins/Trace/intel-pt/LibiptDecoder.h b/lldb/source/Plugins/Trace/intel-pt/LibiptDecoder.h index 78fc2c7..ac79d18 100644 --- a/lldb/source/Plugins/Trace/intel-pt/LibiptDecoder.h +++ b/lldb/source/Plugins/Trace/intel-pt/LibiptDecoder.h @@ -29,9 +29,9 @@ struct PSBBlock { /// Size in bytes of this block uint64_t size; /// The first ip for this PSB block. - /// This is \a None if tracing was disabled when the PSB block was emitted. - /// This means that eventually there's be an enablement event that will come - /// with an ip. + /// This is \a std::nullopt if tracing was disabled when the PSB block was + /// emitted. This means that eventually there's be an enablement event that + /// will come with an ip. llvm::Optional starting_ip; }; diff --git a/lldb/source/Plugins/Trace/intel-pt/TraceCursorIntelPT.h b/lldb/source/Plugins/Trace/intel-pt/TraceCursorIntelPT.h index e1159a0..984d763 100644 --- a/lldb/source/Plugins/Trace/intel-pt/TraceCursorIntelPT.h +++ b/lldb/source/Plugins/Trace/intel-pt/TraceCursorIntelPT.h @@ -69,17 +69,17 @@ private: /// Timing information and cached values. /// \{ - /// TSC -> nanos conversion utility. \a None if not available at all. + /// TSC -> nanos conversion utility. \a std::nullopt if not available at all. llvm::Optional m_tsc_conversion; - /// Lowest nanoseconds timestamp seen in any thread trace, \a None if not - /// available at all. + /// Lowest nanoseconds timestamp seen in any thread trace, \a std::nullopt if + /// not available at all. llvm::Optional m_beginning_of_time_nanos; /// Range of trace items with the same TSC that includes the current trace - /// item, \a None if not calculated or not available. + /// item, \a std::nullopt if not calculated or not available. llvm::Optional mutable m_tsc_range; bool mutable m_tsc_range_calculated = false; /// Range of trace items with the same non-interpolated timestamps in - /// nanoseconds that includes the current trace item, \a None if not + /// nanoseconds that includes the current trace item, \a std::nullopt if not /// calculated or not available. llvm::Optional mutable m_nanoseconds_range; bool mutable m_nanoseconds_range_calculated = false; diff --git a/lldb/source/Plugins/Trace/intel-pt/TraceIntelPTBundleSaver.cpp b/lldb/source/Plugins/Trace/intel-pt/TraceIntelPTBundleSaver.cpp index 653cdde..731e4d15 100644 --- a/lldb/source/Plugins/Trace/intel-pt/TraceIntelPTBundleSaver.cpp +++ b/lldb/source/Plugins/Trace/intel-pt/TraceIntelPTBundleSaver.cpp @@ -130,9 +130,9 @@ BuildThreadsSection(Process &process, FileSpec directory) { } /// \return -/// an \a llvm::Error in case of failures, \a None if the trace is not written -/// to disk because the trace is empty and the \p compact flag is present, or -/// the FileSpec of the trace file on disk. +/// an \a llvm::Error in case of failures, \a std::nullopt if the trace is not +/// written to disk because the trace is empty and the \p compact flag is +/// present, or the FileSpec of the trace file on disk. static Expected> WriteContextSwitchTrace(TraceIntelPT &trace_ipt, lldb::cpu_id_t cpu_id, const FileSpec &cpus_dir, bool compact) { diff --git a/lldb/source/Plugins/Trace/intel-pt/TraceIntelPTMultiCpuDecoder.h b/lldb/source/Plugins/Trace/intel-pt/TraceIntelPTMultiCpuDecoder.h index 00657ab..f7b3e1a 100644 --- a/lldb/source/Plugins/Trace/intel-pt/TraceIntelPTMultiCpuDecoder.h +++ b/lldb/source/Plugins/Trace/intel-pt/TraceIntelPTMultiCpuDecoder.h @@ -96,8 +96,8 @@ private: llvm::DenseMap>> m_continuous_executions_per_thread; llvm::DenseMap m_decoded_threads; - /// This variable will be non-None if a severe error happened during the setup - /// of the decoder and we don't want decoding to be reattempted. + /// This variable will not be std::nullopt if a severe error happened during + /// the setup of the decoder and we don't want decoding to be reattempted. llvm::Optional m_setup_error; uint64_t m_unattributed_psb_blocks = 0; uint64_t m_total_psb_blocks = 0; diff --git a/lldb/source/Plugins/TraceExporter/common/TraceHTR.h b/lldb/source/Plugins/TraceExporter/common/TraceHTR.h index 3f5d6f2..75f3bd3 100644 --- a/lldb/source/Plugins/TraceExporter/common/TraceHTR.h +++ b/lldb/source/Plugins/TraceExporter/common/TraceHTR.h @@ -57,7 +57,7 @@ public: /// /// \return /// The name of the function that is called the most from this block or - /// None if no function is called from this block. + /// std::nullopt if no function is called from this block. llvm::Optional GetMostFrequentlyCalledFunction() const; /// Get the load address of the first instruction in the block. @@ -233,8 +233,8 @@ private: // most instructions don't contain useful metadata // This map contains the load address of all the call instructions. - // load address maps to the name of the function it calls (None if function - // name can't be determined) + // load address maps to the name of the function it calls (std::nullopt if + // function name can't be determined) std::unordered_map> m_call_isns; }; diff --git a/lldb/source/Target/TraceDumper.cpp b/lldb/source/Target/TraceDumper.cpp index 374c8ad..1f581011 100644 --- a/lldb/source/Target/TraceDumper.cpp +++ b/lldb/source/Target/TraceDumper.cpp @@ -19,7 +19,7 @@ using namespace lldb_private; using namespace llvm; /// \return -/// The given string or \b None if it's empty. +/// The given string or \b std::nullopt if it's empty. static Optional ToOptionalString(const char *s) { if (!s) return std::nullopt; -- 2.7.4