Author: Kazu Hirata Date: 2022-12-05T23:32:18-08:00 New Revision: d920ab4a8bf26d3201e088888460bea542fcd5ea
URL: https://github.com/llvm/llvm-project/commit/d920ab4a8bf26d3201e088888460bea542fcd5ea DIFF: https://github.com/llvm/llvm-project/commit/d920ab4a8bf26d3201e088888460bea542fcd5ea.diff LOG: [lldb] Use std::nullopt instead of llvm::None (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 Added: Modified: lldb/source/Plugins/Trace/intel-pt/DecodedThread.cpp lldb/source/Plugins/Trace/intel-pt/LibiptDecoder.cpp lldb/source/Plugins/Trace/intel-pt/TraceCursorIntelPT.cpp lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.cpp lldb/source/Plugins/Trace/intel-pt/TraceIntelPTBundleSaver.cpp lldb/source/Plugins/Trace/intel-pt/TraceIntelPTJSONStructs.cpp Removed: ################################################################################ diff --git a/lldb/source/Plugins/Trace/intel-pt/DecodedThread.cpp b/lldb/source/Plugins/Trace/intel-pt/DecodedThread.cpp index 0a84906641a4..a290257cb199 100644 --- a/lldb/source/Plugins/Trace/intel-pt/DecodedThread.cpp +++ b/lldb/source/Plugins/Trace/intel-pt/DecodedThread.cpp @@ -158,7 +158,7 @@ Optional<DecodedThread::TSCRange> DecodedThread::GetTSCRangeByIndex(uint64_t item_index) const { auto next_it = m_tscs.upper_bound(item_index); if (next_it == m_tscs.begin()) - return None; + return std::nullopt; return prev(next_it)->second; } @@ -166,7 +166,7 @@ Optional<DecodedThread::NanosecondsRange> DecodedThread::GetNanosecondsRangeByIndex(uint64_t item_index) { auto next_it = m_nanoseconds.upper_bound(item_index); if (next_it == m_nanoseconds.begin()) - return None; + return std::nullopt; return prev(next_it)->second; } diff --git a/lldb/source/Plugins/Trace/intel-pt/LibiptDecoder.cpp b/lldb/source/Plugins/Trace/intel-pt/LibiptDecoder.cpp index c636847714ef..cfae7b708b74 100644 --- a/lldb/source/Plugins/Trace/intel-pt/LibiptDecoder.cpp +++ b/lldb/source/Plugins/Trace/intel-pt/LibiptDecoder.cpp @@ -228,15 +228,15 @@ class PSBBlockAnomalyDetector { return item_index; } if (item_index == 0) - return None; + return std::nullopt; item_index--; } - return None; + return std::nullopt; }; // Similar to most_recent_insn_index but skips the starting position. auto prev_insn_index = [&](uint64_t item_index) -> Optional<uint64_t> { if (item_index == 0) - return None; + return std::nullopt; return most_recent_insn_index(item_index - 1); }; @@ -244,7 +244,7 @@ class PSBBlockAnomalyDetector { Optional<uint64_t> last_insn_index_opt = *prev_insn_index(m_decoded_thread.GetItemsCount()); if (!last_insn_index_opt) - return None; + return std::nullopt; uint64_t last_insn_index = *last_insn_index_opt; // We then find the most recent previous occurrence of that last @@ -258,7 +258,7 @@ class PSBBlockAnomalyDetector { loop_size++; } if (!last_insn_copy_index) - return None; + return std::nullopt; // Now we check if the segment between these last positions of the last // instruction address is in fact a repeating loop. @@ -269,14 +269,14 @@ class PSBBlockAnomalyDetector { if (Optional<uint64_t> prev = prev_insn_index(insn_index_a)) insn_index_a = *prev; else - return None; + return std::nullopt; if (Optional<uint64_t> prev = prev_insn_index(insn_index_b)) insn_index_b = *prev; else - return None; + return std::nullopt; if (m_decoded_thread.GetInstructionLoadAddress(insn_index_a) != m_decoded_thread.GetInstructionLoadAddress(insn_index_b)) - return None; + return std::nullopt; loop_elements_visited++; } return loop_size; @@ -766,15 +766,15 @@ lldb_private::trace_intel_pt::FindLowestTSCInTrace(TraceIntelPT &trace_intel_pt, uint64_t ip = LLDB_INVALID_ADDRESS; int status = pt_qry_sync_forward(decoder, &ip); if (IsLibiptError(status)) - return None; + return std::nullopt; while (HasEvents(status)) { pt_event event; status = pt_qry_event(decoder, &event, sizeof(event)); if (IsLibiptError(status)) - return None; + return std::nullopt; if (event.has_tsc) return event.tsc; } - return None; + return std::nullopt; } diff --git a/lldb/source/Plugins/Trace/intel-pt/TraceCursorIntelPT.cpp b/lldb/source/Plugins/Trace/intel-pt/TraceCursorIntelPT.cpp index fe734c0375df..d50a738888ea 100644 --- a/lldb/source/Plugins/Trace/intel-pt/TraceCursorIntelPT.cpp +++ b/lldb/source/Plugins/Trace/intel-pt/TraceCursorIntelPT.cpp @@ -105,7 +105,7 @@ lldb::addr_t TraceCursorIntelPT::GetLoadAddress() const { Optional<uint64_t> TraceCursorIntelPT::GetHWClock() const { if (const Optional<DecodedThread::TSCRange> &range = GetTSCRange()) return range->tsc; - return None; + return std::nullopt; } Optional<double> TraceCursorIntelPT::GetWallClockTime() const { @@ -113,7 +113,7 @@ Optional<double> TraceCursorIntelPT::GetWallClockTime() const { GetNanosecondsRange()) return range->GetInterpolatedTime(m_pos, *m_beginning_of_time_nanos, *m_tsc_conversion); - return None; + return std::nullopt; } lldb::cpu_id_t TraceCursorIntelPT::GetCPU() const { diff --git a/lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.cpp b/lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.cpp index 1782675d68d3..99ddb5d312c8 100644 --- a/lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.cpp +++ b/lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.cpp @@ -197,7 +197,7 @@ Expected<Optional<uint64_t>> TraceIntelPT::FindBeginningOfTimeNanos() { storage.beginning_of_time_nanos_calculated = true; if (!storage.tsc_conversion) - return None; + return std::nullopt; Optional<uint64_t> lowest_tsc; @@ -465,7 +465,7 @@ void TraceIntelPT::DumpTraceInfoAsJson(Thread &thread, Stream &s, llvm::Expected<Optional<uint64_t>> TraceIntelPT::GetRawTraceSize(Thread &thread) { if (GetUpdatedStorage().multicpu_decoder) - return None; // TODO: calculate the amount of intel pt raw trace associated + return std::nullopt; // TODO: calculate the amount of intel pt raw trace associated // with the given thread. if (GetLiveProcess()) return GetLiveThreadBinaryDataSize(thread.GetID(), diff --git a/lldb/source/Plugins/Trace/intel-pt/TraceIntelPTBundleSaver.cpp b/lldb/source/Plugins/Trace/intel-pt/TraceIntelPTBundleSaver.cpp index d1c13298bfc4..17c8f070eecc 100644 --- a/lldb/source/Plugins/Trace/intel-pt/TraceIntelPTBundleSaver.cpp +++ b/lldb/source/Plugins/Trace/intel-pt/TraceIntelPTBundleSaver.cpp @@ -170,7 +170,7 @@ WriteContextSwitchTrace(TraceIntelPT &trace_ipt, lldb::cpu_id_t cpu_id, return std::move(err); if (should_skip) - return None; + return std::nullopt; return output_context_switch_trace; } @@ -193,7 +193,7 @@ static Expected<FileSpec> WriteIntelPTTrace(TraceIntelPT &trace_ipt, static llvm::Expected<llvm::Optional<std::vector<JSONCpu>>> BuildCpusSection(TraceIntelPT &trace_ipt, FileSpec directory, bool compact) { if (trace_ipt.GetTracedCpus().empty()) - return None; + return std::nullopt; std::vector<JSONCpu> json_cpus; FileSpec cpus_dir = directory; diff --git a/lldb/source/Plugins/Trace/intel-pt/TraceIntelPTJSONStructs.cpp b/lldb/source/Plugins/Trace/intel-pt/TraceIntelPTJSONStructs.cpp index 209b22cb59ee..4120dd11ebe9 100644 --- a/lldb/source/Plugins/Trace/intel-pt/TraceIntelPTJSONStructs.cpp +++ b/lldb/source/Plugins/Trace/intel-pt/TraceIntelPTJSONStructs.cpp @@ -21,7 +21,7 @@ namespace trace_intel_pt { Optional<std::vector<lldb::cpu_id_t>> JSONTraceBundleDescription::GetCpuIds() { if (!cpus) - return None; + return std::nullopt; std::vector<lldb::cpu_id_t> cpu_ids; for (const JSONCpu &cpu : *cpus) cpu_ids.push_back(cpu.id); _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits