[lldb] Use std::nullopt 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-04 20:11:39 -08:00
parent 192d9dd731
commit 768cae4a5a
33 changed files with 52 additions and 52 deletions

View File

@@ -55,7 +55,7 @@ public:
/// A string containing JUST the breakpoint description.
/// \return
/// If \p input was not a valid breakpoint ID string, returns
/// \b llvm::None. Otherwise returns a BreakpointID with members filled
/// \b std::nullopt. Otherwise returns a BreakpointID with members filled
/// out accordingly.
static llvm::Optional<BreakpointID>
ParseCanonicalReference(llvm::StringRef input);

View File

@@ -100,7 +100,7 @@ public:
/// number of bytes that can be placed into \a dst.
///
/// \param[in] timeout
/// A timeout value or llvm::None for no timeout.
/// A timeout value or std::nullopt for no timeout.
///
/// \return
/// The number of bytes actually read.

View File

@@ -29,7 +29,7 @@ public:
/// Constructor.
///
/// Takes a \a file_spec with a \a line number and a \a column number. If
/// \a column is null or not provided, it is set to llvm::None.
/// \a column is null or not provided, it is set to std::nullopt.
///
/// \param[in] file_spec
/// The full or partial path to a file.

View File

@@ -131,7 +131,7 @@ public:
/// number of bytes that can be placed into \a dst.
///
/// \param[in] timeout
/// A timeout value or llvm::None for no timeout.
/// A timeout value or std::nullopt for no timeout.
///
/// \return
/// The number of bytes actually read.

View File

@@ -273,7 +273,7 @@ public:
/// The command arguments.
///
/// \return
/// llvm::None if there is no special repeat command - it will use the
/// std::nullopt if there is no special repeat command - it will use the
/// current command line.
/// Otherwise a std::string containing the command to be repeated.
/// If the string is empty, the command won't be allow repeating.

View File

@@ -485,7 +485,7 @@ public:
llvm::ArrayRef<std::unique_ptr<CallEdge>> GetCallEdges();
/// Get the outgoing tail-calling edges from this function. If none exist,
/// return None.
/// return std::nullopt.
llvm::ArrayRef<std::unique_ptr<CallEdge>> GetTailCallingEdges();
/// Get the outgoing call edge from this function which has the given return

View File

@@ -64,8 +64,8 @@ public:
///
/// If the range had no tags at all, the vector will be empty.
/// If some of the range was tagged it will have items and some
/// of them may be llvm::None.
/// (this saves the caller checking whether all items are llvm::None)
/// of them may be std::nullopt.
/// (this saves the caller checking whether all items are std::nullopt)
std::vector<llvm::Optional<lldb::addr_t>> GetTags(lldb::addr_t addr,
size_t len) const;
@@ -77,7 +77,7 @@ private:
/// to a granule boundary.
///
/// \return
/// The tag for the granule that address refers to, or llvm::None
/// The tag for the granule that address refers to, or std::nullopt
/// if it has no memory tag.
llvm::Optional<lldb::addr_t> GetTag(lldb::addr_t addr) const;

View File

@@ -81,8 +81,8 @@ public:
/// \param[in] only_if_exists
/// If \b true, besides matching \p path with the remapping rules, this
/// tries to check with the filesystem that the remapped file exists. If
/// no valid file is found, \b None is returned. This might be expensive,
/// specially on a network.
/// no valid file is found, \b std::nullopt is returned. This might be
/// expensive, specially on a network.
///
/// If \b false, then the existence of the returned remapping is not
/// checked.
@@ -104,8 +104,8 @@ public:
/// The reversed mapped new path.
///
/// \return
/// llvm::None if no remapping happens, otherwise, the matching source map
/// entry's ""to_new_pathto"" part (which is the prefix of \a file) is
/// std::nullopt if no remapping happens, otherwise, the matching source
/// map entry's ""to_new_pathto"" part (which is the prefix of \a file) is
/// returned.
llvm::Optional<llvm::StringRef> ReverseRemapPath(const FileSpec &file,
FileSpec &fixed) const;

View File

@@ -259,8 +259,8 @@ public:
/// whenever an eTraceEventHWClockTick event is fired.
///
/// \return
/// The requested HW clock value, or \a llvm::None if this information is
/// not available for the current item.
/// The requested HW clock value, or \a std::nullopt if this information
/// is not available for the current item.
virtual llvm::Optional<uint64_t> GetHWClock() const = 0;
/// Get the approximate wall clock time in nanoseconds at which the current
@@ -268,7 +268,7 @@ public:
/// what time 0 means.
///
/// \return
/// The approximate wall clock time for the trace item, or \a llvm::None
/// The approximate wall clock time for the trace item, or \a std::nullopt
/// if not available.
virtual llvm::Optional<double> GetWallClockTime() const = 0;

View File

@@ -411,8 +411,8 @@ public:
/// The number of instructions to print.
///
/// \return
/// The instruction id of the last traversed instruction, or \b llvm::None
/// if no instructions were visited.
/// The instruction id of the last traversed instruction, or \b
/// std::nullopt if no instructions were visited.
llvm::Optional<lldb::user_id_t> DumpInstructions(size_t count);
/// Dump all function calls forwards chronologically and hierarchically

View File

@@ -190,10 +190,10 @@ public:
static bool Match(const FileSpec &pattern, const FileSpec &file);
/// Attempt to guess path style for a given path string. It returns a style,
/// if it was able to make a reasonable guess, or None if it wasn't. The guess
/// will be correct if the input path was a valid absolute path on the system
/// which produced it. On other paths the result of this function is
/// unreliable (e.g. "c:\foo.txt" is a valid relative posix path).
/// if it was able to make a reasonable guess, or std::nullopt if it wasn't.
/// The guess will be correct if the input path was a valid absolute path on
/// the system which produced it. On other paths the result of this function
/// is unreliable (e.g. "c:\foo.txt" is a valid relative posix path).
static llvm::Optional<Style> GuessPathStyle(llvm::StringRef absolute_path);
/// Case sensitivity of path.

View File

@@ -208,7 +208,7 @@ public:
static constexpr lldb::tid_t AllThreads = UINT64_MAX;
// Read thread-id from the packet. If the packet is valid, returns
// the pair (PID, TID), otherwise returns llvm::None. If the packet
// the pair (PID, TID), otherwise returns std::nullopt. If the packet
// does not list a PID, default_pid is used.
llvm::Optional<std::pair<lldb::pid_t, lldb::tid_t>>
GetPidTid(lldb::pid_t default_pid);

View File

@@ -21,7 +21,7 @@ namespace lldb_private {
// from Timeout<std::milli> to Timeout<std::micro>.
//
// The intended meaning of the values is:
// - llvm::None - no timeout, the call should wait forever - 0 - poll, only
// - std::nullopt - no timeout, the call should wait forever - 0 - poll, only
// complete the call if it will not block - >0 - wait for a given number of
// units for the result
template <typename Ratio>

View File

@@ -44,7 +44,7 @@ struct TraceStartRequest {
/// Tracing technology name, e.g. intel-pt, arm-coresight.
std::string type;
/// If \a llvm::None, then this starts tracing the whole process. Otherwise,
/// If \a std::nullopt, then this starts tracing the whole process. Otherwise,
/// only tracing for the specified threads is enabled.
llvm::Optional<std::vector<lldb::tid_t>> tids;
@@ -72,7 +72,7 @@ struct TraceStopRequest {
/// Tracing technology name, e.g. intel-pt, arm-coresight.
std::string type;
/// If \a llvm::None, then this stops tracing the whole process. Otherwise,
/// If \a std::nullopt, then this stops tracing the whole process. Otherwise,
/// only tracing for the specified threads is stopped.
llvm::Optional<std::vector<lldb::tid_t>> tids;
};

View File

@@ -56,7 +56,7 @@ public:
bool IsRemovable() const override { return true; }
/// More documentation is available in lldb::CommandObject::GetRepeatCommand,
/// but in short, if llvm::None is returned, the previous command will be
/// but in short, if std::nullopt is returned, the previous command will be
/// repeated, and if an empty string is returned, no commands will be
/// executed.
llvm::Optional<std::string> GetRepeatCommand(Args &current_command_args,

View File

@@ -200,7 +200,7 @@ void BreakpointResolverFileLine::DeduceSourceMapping(
const llvm::StringRef path_separator = llvm::sys::path::get_separator(
m_location_spec.GetFileSpec().GetPathStyle());
// Check if "b" is a suffix of "a".
// And return llvm::None if not or the new path
// And return std::nullopt if not or the new path
// of "a" after consuming "b" from the back.
auto check_suffix =
[path_separator](llvm::StringRef a, llvm::StringRef b,

View File

@@ -773,7 +773,7 @@ private:
/// Returns size in bytes of the type associated with this variable
///
/// \returns On success, returns byte size of the type associated
/// with this variable. Returns NoneType otherwise.
/// with this variable. Returns std::nullopt otherwise.
virtual llvm::Optional<uint64_t>
GetByteSize(ExecutionContextScope *scope) const = 0;
@@ -784,7 +784,7 @@ private:
/// Returns alignment of the type associated with this variable in bits.
///
/// \returns On success, returns alignment in bits for the type associated
/// with this variable. Returns NoneType otherwise.
/// with this variable. Returns std::nullopt otherwise.
virtual llvm::Optional<size_t>
GetTypeBitAlign(ExecutionContextScope *scope) const = 0;

View File

@@ -252,7 +252,7 @@ MapOpcodeIntoControlFlowKind(InstructionOpcodeAndModrm opcode_and_modrm) {
/// Returns decoded instruction as struct InstructionOpcodeAndModrm, holding
/// primary_opcode, opcode_len and modrm byte. Refer to the struct definition
/// for more details.
/// Otherwise if the given instruction is invalid, returns None.
/// Otherwise if the given instruction is invalid, returns std::nullopt.
llvm::Optional<InstructionOpcodeAndModrm>
InstructionLengthDecode(const uint8_t *inst_bytes, int bytes_len,
bool is_exec_mode_64b) {

View File

@@ -874,7 +874,7 @@ private:
/// non-deterministic order, so this function should have no side effects.
/// To make this easier to enforce, this function and all its parameters
/// should always be const-qualified.
/// \return Returns llvm::None if no completion should be provided for the
/// \return Returns std::nullopt if no completion should be provided for the
/// given CodeCompletionResult.
llvm::Optional<CompletionWithPriority>
getCompletionForResult(const CodeCompletionResult &R) const {

View File

@@ -31,8 +31,8 @@ LLDB_PLUGIN_DEFINE_ADV(EmulateInstructionRISCV, InstructionRISCV)
namespace lldb_private {
/// Returns all values wrapped in Optional, or None if any of the values is
/// None.
/// Returns all values wrapped in Optional, or std::nullopt if any of the values
/// is None.
template <typename... Ts>
static llvm::Optional<std::tuple<Ts...>> zipOpt(llvm::Optional<Ts> &&...ts) {
if ((ts.has_value() && ...))

View File

@@ -64,7 +64,7 @@ Error IntelPTCollector::TraceStop(const TraceStopRequest &request) {
/// \return
/// some file descriptor in /sys/fs/ associated with the cgroup of the given
/// pid, or \a llvm::None if the pid is not part of a cgroup.
/// pid, or \a std::nullopt if the pid is not part of a cgroup.
static Optional<int> GetCGroupFileDescriptor(lldb::pid_t pid) {
static Optional<int> fd;
if (fd)

View File

@@ -34,7 +34,7 @@ public:
///
/// \param[in] cgroup_fd
/// A file descriptor in /sys/fs associated with the cgroup of the process to
/// trace. If not \a llvm::None, then the trace sesion will use cgroup
/// trace. If not \a std::nullopt, then the trace sesion will use cgroup
/// filtering.
///
/// \return

View File

@@ -43,7 +43,7 @@ public:
///
/// \param[in] cgroup_fd
/// A file descriptor in /sys/fs associated with the cgroup of the process
/// to trace. If not \a llvm::None, then the trace sesion will use cgroup
/// to trace. If not \a std::nullopt, then the trace sesion will use cgroup
/// filtering.
///
/// \return

View File

@@ -71,7 +71,7 @@ public:
/// from that gets updated as data gets decoded.
///
/// \return
/// Returns a valid DIERef if decoding succeeded, llvm::None if there was
/// Returns a valid DIERef if decoding succeeded, std::nullopt if there was
/// unsufficient or invalid values that were decoded.
static llvm::Optional<DIERef> Decode(const lldb_private::DataExtractor &data,
lldb::offset_t *offset_ptr);

View File

@@ -3866,7 +3866,7 @@ CollectCallSiteParameters(ModuleSP module, DWARFDIE call_site_die) {
const size_t num_attributes = child.GetAttributes(attributes);
// Parse the location at index \p attr_index within this call site parameter
// DIE, or return None on failure.
// DIE, or return std::nullopt on failure.
auto parse_simple_location =
[&](int attr_index) -> llvm::Optional<DWARFExpressionList> {
DWARFFormValue form_value;

View File

@@ -2273,7 +2273,7 @@ SymbolFileNativePDB::FindSymbolScope(PdbCompilandSymId id) {
// If this exact symbol opens a scope, we can just directly access its
// parent.
id.offset = getScopeParentOffset(sym);
// Global symbols have parent offset of 0. Return llvm::None to indicate
// Global symbols have parent offset of 0. Return std::nullopt to indicate
// this.
if (id.offset == 0)
return std::nullopt;

View File

@@ -121,7 +121,7 @@ namespace ParsingUtils {
/// MB and MiB for 2^20 bytes; and B for bytes. A single integral number is
/// considered bytes.
/// \return
/// The converted number of bytes or \a llvm::None if the expression is
/// The converted number of bytes or \a std::nullopt if the expression is
/// invalid.
llvm::Optional<uint64_t>
ParseUserFriendlySizeExpression(llvm::StringRef size_expression);

View File

@@ -188,7 +188,7 @@ public:
/// The trace item index to compare with.
///
/// \return
/// The requested TSC range, or \a llvm::None if not available.
/// The requested TSC range, or \a std::nullopt if not available.
llvm::Optional<DecodedThread::TSCRange>
GetTSCRangeByIndex(uint64_t item_index) const;
@@ -199,7 +199,7 @@ public:
/// The trace item index to compare with.
///
/// \return
/// The requested nanoseconds range, or \a llvm::None if not available.
/// The requested nanoseconds range, or \a std::nullopt if not available.
llvm::Optional<DecodedThread::NanosecondsRange>
GetNanosecondsRangeByIndex(uint64_t item_index);

View File

@@ -111,7 +111,7 @@ SplitTraceIntoPSBBlock(TraceIntelPT &trace_intel_pt,
/// Find the lowest TSC in the given trace.
///
/// \return
/// The lowest TSC value in this trace if available, \a llvm::None if the
/// The lowest TSC value in this trace if available, \a std::nullopt if the
/// trace is empty or the trace contains no timing information, or an \a
/// llvm::Error if it was not possible to set up the decoder.
llvm::Expected<llvm::Optional<uint64_t>>

View File

@@ -36,9 +36,9 @@ public:
llvm::Expected<DecodedThreadSP> Decode();
/// \return
/// The lowest TSC value in this trace if available, \a llvm::None if the
/// trace is empty or the trace contains no timing information, or an \a
/// llvm::Error if it was not possible to set up the decoder.
/// The lowest TSC value in this trace if available, \a std::nullopt if
/// the trace is empty or the trace contains no timing information, or an
/// \a llvm::Error if it was not possible to set up the decoder.
llvm::Expected<llvm::Optional<uint64_t>> FindLowestTSC();
ThreadDecoder(const ThreadDecoder &other) = delete;

View File

@@ -249,7 +249,7 @@ private:
/// \return
/// The lowest timestamp in nanoseconds in all traces if available, \a
/// llvm::None if all the traces were empty or no trace contained no
/// std::nullopt if all the traces were empty or no trace contained no
/// timing information, or an \a llvm::Error if it was not possible to set
/// up the decoder for some trace.
llvm::Expected<llvm::Optional<uint64_t>> FindBeginningOfTimeNanos();

View File

@@ -67,9 +67,9 @@ public:
size_t GetTotalPSBBlocksCount() const;
/// \return
/// The lowest TSC value in this trace if available, \a llvm::None if the
/// trace is empty or the trace contains no timing information, or an \a
/// llvm::Error if it was not possible to set up the decoder.
/// The lowest TSC value in this trace if available, \a std::nullopt if
/// the trace is empty or the trace contains no timing information, or an
/// \a llvm::Error if it was not possible to set up the decoder.
llvm::Expected<llvm::Optional<uint64_t>> FindLowestTSC();
private:

View File

@@ -47,7 +47,7 @@ MemoryTagMap::GetTags(lldb::addr_t addr, size_t len) const {
got_valid_tags = true;
}
// To save the caller checking if every item is llvm::None,
// To save the caller checking if every item is std::nullopt,
// we return an empty vector if we got no tags at all.
if (got_valid_tags)
return tags;