[lldb] Use std::nullopt instead of None in comments (NFC)
authorKazu Hirata <kazu@google.com>
Mon, 5 Dec 2022 04:11:39 +0000 (20:11 -0800)
committerKazu Hirata <kazu@google.com>
Mon, 5 Dec 2022 04:11:39 +0000 (20:11 -0800)
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

33 files changed:
lldb/include/lldb/Breakpoint/BreakpointID.h
lldb/include/lldb/Core/Communication.h
lldb/include/lldb/Core/SourceLocationSpec.h
lldb/include/lldb/Core/ThreadedCommunication.h
lldb/include/lldb/Interpreter/CommandObject.h
lldb/include/lldb/Symbol/Function.h
lldb/include/lldb/Target/MemoryTagMap.h
lldb/include/lldb/Target/PathMappingList.h
lldb/include/lldb/Target/TraceCursor.h
lldb/include/lldb/Target/TraceDumper.h
lldb/include/lldb/Utility/FileSpec.h
lldb/include/lldb/Utility/StringExtractorGDBRemote.h
lldb/include/lldb/Utility/Timeout.h
lldb/include/lldb/Utility/TraceGDBRemotePackets.h
lldb/source/API/SBCommandInterpreter.cpp
lldb/source/Breakpoint/BreakpointResolverFileLine.cpp
lldb/source/Expression/Materializer.cpp
lldb/source/Plugins/Disassembler/LLVMC/DisassemblerLLVMC.cpp
lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
lldb/source/Plugins/Instruction/RISCV/EmulateInstructionRISCV.cpp
lldb/source/Plugins/Process/Linux/IntelPTCollector.cpp
lldb/source/Plugins/Process/Linux/IntelPTMultiCoreTrace.h
lldb/source/Plugins/Process/Linux/IntelPTSingleBufferTrace.h
lldb/source/Plugins/SymbolFile/DWARF/DIERef.h
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
lldb/source/Plugins/Trace/intel-pt/CommandObjectTraceStartIntelPT.h
lldb/source/Plugins/Trace/intel-pt/DecodedThread.h
lldb/source/Plugins/Trace/intel-pt/LibiptDecoder.h
lldb/source/Plugins/Trace/intel-pt/ThreadDecoder.h
lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.h
lldb/source/Plugins/Trace/intel-pt/TraceIntelPTMultiCpuDecoder.h
lldb/source/Target/MemoryTagMap.cpp

index 64432f2..d3d75f8 100644 (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);
index a015152..f5f6368 100644 (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.
index 3b58b28..5463b40 100644 (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.
index b7412c7..2e3afde 100644 (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.
index 03f5aef..8ac251c 100644 (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.
index 3eb4f5d..2da13f8 100644 (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
index acf3825..a2b4a31 100644 (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;
 
index 2f7ee53..1f1555a 100644 (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;
index 3126c9f..ee5014f 100644 (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;
 
index bc79705..e5fdaaf 100644 (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
index d4f30bb..3f02412 100644 (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.
index 86a3a39..1c03ed1 100644 (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);
index a873c47..1a9e595 100644 (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>
index c6d3f52..bfa6821 100644 (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;
 };
index 8457b78..91a52ef 100644 (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,
index 5933595..3b6509b 100644 (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,
index 926d4af..d28b524 100644 (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;
 
index b497386..eae950d 100644 (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) {
index 2386946..511c6ff 100644 (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 {
index 862c8f5..d44864e 100644 (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() && ...))
index 2051b5b..66ef90f 100644 (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)
index 38503b1..b5b4203 100644 (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
index 677038b..a61e35b 100644 (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
index e980f68..7e5d7a6 100644 (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);
index 880b521..bc23a53 100644 (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;
index 5e68675..d84a1a6 100644 (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;
index 083184e..ffa1dce 100644 (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);
index bbe0fb9..d850217 100644 (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);
 
index 8676a0b..78fc2c7 100644 (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>>
index ad7c124..74b40c0 100644 (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;
index f671183..611d996 100644 (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();
index 87c370e..00657ab 100644 (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:
index 4fe5c8b..8eff42d 100644 (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;