[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
This commit is contained in:
Kazu Hirata
2022-12-10 17:06:43 -08:00
parent d6684f2cb2
commit 8b5c302efb
13 changed files with 31 additions and 28 deletions

View File

@@ -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<std::string> GetSyncPointMetadata() const = 0;
/// \}

View File

@@ -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<int32_t> GetFilteredSignals(llvm::Optional<bool> should_suppress,
llvm::Optional<bool> should_stop,

View File

@@ -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 <typename C>
llvm::Optional<T> WaitFor(C Cond, const Timeout<std::micro> &timeout) {
std::unique_lock<std::mutex> 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<T>
WaitForValueNotEqualTo(T value,
const Timeout<std::micro> &timeout = std::nullopt) {

View File

@@ -49,7 +49,7 @@ struct TraceStartRequest {
llvm::Optional<std::vector<lldb::tid_t>> 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;
};

View File

@@ -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<llvm::StringRef>
guessIncludePath(llvm::StringRef path_to_file, llvm::StringRef pattern) {
if (pattern.empty())

View File

@@ -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 <typename... Ts>
static llvm::Optional<std::tuple<Ts...>> zipOpt(llvm::Optional<Ts> &&...ts) {
if ((ts.has_value() && ...))

View File

@@ -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<llvm::Optional<std::vector<uint8_t>>>
TryGetBinaryData(const TraceGetBinaryDataRequest &request) = 0;
};

View File

@@ -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<lldb::addr_t> starting_ip;
};

View File

@@ -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<LinuxPerfZeroTscConversion> 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<uint64_t> 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<DecodedThread::TSCRange> 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<DecodedThread::NanosecondsRange> mutable m_nanoseconds_range;
bool mutable m_nanoseconds_range_calculated = false;

View File

@@ -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<Optional<FileSpec>>
WriteContextSwitchTrace(TraceIntelPT &trace_ipt, lldb::cpu_id_t cpu_id,
const FileSpec &cpus_dir, bool compact) {

View File

@@ -96,8 +96,8 @@ private:
llvm::DenseMap<lldb::tid_t, std::vector<IntelPTThreadContinousExecution>>>
m_continuous_executions_per_thread;
llvm::DenseMap<lldb::tid_t, DecodedThreadSP> 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<std::string> m_setup_error;
uint64_t m_unattributed_psb_blocks = 0;
uint64_t m_total_psb_blocks = 0;

View File

@@ -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<llvm::StringRef> 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<lldb::addr_t, llvm::Optional<ConstString>> m_call_isns;
};

View File

@@ -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<const char *> ToOptionalString(const char *s) {
if (!s)
return std::nullopt;