perfetto: switch base::Optional to std::optional
Now that base::Optional is simply a shim for std::optional and it's
stuck without being reverted, migrate everything over to use
std::optional directly.
Change-Id: Ic2595fc1cfae8f3b62350f8bf206675c709894a1
diff --git a/src/traceconv/pprof_builder.cc b/src/traceconv/pprof_builder.cc
index 07aa6f9..1ca8654 100644
--- a/src/traceconv/pprof_builder.cc
+++ b/src/traceconv/pprof_builder.cc
@@ -159,10 +159,10 @@
return ret;
}
-base::Optional<int64_t> GetStatsEntry(
+std::optional<int64_t> GetStatsEntry(
trace_processor::TraceProcessor* tp,
const std::string& name,
- base::Optional<uint64_t> idx = base::nullopt) {
+ std::optional<uint64_t> idx = std::nullopt) {
std::string query = "select value from stats where name == '" + name + "'";
if (idx.has_value())
query += " and idx == " + std::to_string(idx.value());
@@ -172,12 +172,12 @@
if (!it.Status().ok()) {
PERFETTO_DFATAL_OR_ELOG("Invalid iterator: %s",
it.Status().message().c_str());
- return base::nullopt;
+ return std::nullopt;
}
// some stats are not present unless non-zero
- return base::make_optional(0);
+ return std::make_optional(0);
}
- return base::make_optional(it.Get(0).AsLong());
+ return std::make_optional(it.Get(0).AsLong());
}
// Interns Locations, Lines, and Functions. Interning is done by the entity's
@@ -340,9 +340,9 @@
int64_t mapping_id = c_it.Get(2).AsLong();
auto func_sysname = c_it.Get(3).is_null() ? "" : c_it.Get(3).AsString();
auto func_name = c_it.Get(4).is_null() ? "" : c_it.Get(4).AsString();
- base::Optional<int64_t> symbol_set_id =
- c_it.Get(5).is_null() ? base::nullopt
- : base::make_optional(c_it.Get(5).AsLong());
+ std::optional<int64_t> symbol_set_id =
+ c_it.Get(5).is_null() ? std::nullopt
+ : std::make_optional(c_it.Get(5).AsLong());
Location loc(mapping_id, /*single_function_id=*/-1, {});
@@ -661,8 +661,8 @@
static bool VerifyPIDStats(trace_processor::TraceProcessor* tp, uint64_t pid) {
bool success = true;
- base::Optional<int64_t> stat =
- GetStatsEntry(tp, "heapprofd_buffer_corrupted", base::make_optional(pid));
+ std::optional<int64_t> stat =
+ GetStatsEntry(tp, "heapprofd_buffer_corrupted", std::make_optional(pid));
if (!stat.has_value()) {
PERFETTO_DFATAL_OR_ELOG("Failed to get heapprofd_buffer_corrupted stat");
} else if (stat.value() > 0) {
@@ -673,8 +673,7 @@
" CLIENT MEMORY CORRUPTION.",
pid);
}
- stat =
- GetStatsEntry(tp, "heapprofd_buffer_overran", base::make_optional(pid));
+ stat = GetStatsEntry(tp, "heapprofd_buffer_overran", std::make_optional(pid));
if (!stat.has_value()) {
PERFETTO_DFATAL_OR_ELOG("Failed to get heapprofd_buffer_overran stat");
} else if (stat.value() > 0) {
@@ -861,7 +860,7 @@
}
static void LogTracePerfEventIssues(trace_processor::TraceProcessor* tp) {
- base::Optional<int64_t> stat = GetStatsEntry(tp, "perf_samples_skipped");
+ std::optional<int64_t> stat = GetStatsEntry(tp, "perf_samples_skipped");
if (!stat.has_value()) {
PERFETTO_DFATAL_OR_ELOG("Failed to look up perf_samples_skipped stat");
} else if (stat.value() > 0) {