mirror of
https://github.com/intel/llvm.git
synced 2026-01-26 03:56:16 +08:00
[lldb] Change interface of StructuredData::Array::GetItemAtIndexAsString (#71613)
This patch changes the interface of StructuredData::Array::GetItemAtIndexAsString to return a `std::optional<llvm::StringRef>` instead of taking an out parameter. More generally, this commit serves as proposal that we change all of the sibling APIs (`GetItemAtIndexAs`) to do the same thing. The reason this isn't one giant patch is because it is rather unwieldy changing just one of these, so if this is approved, I will do all of the other ones as individual follow-ups.
This commit is contained in:
@@ -205,10 +205,9 @@ lldb::BreakpointSP Breakpoint::CreateFromStructuredData(
|
||||
if (success && names_array) {
|
||||
size_t num_names = names_array->GetSize();
|
||||
for (size_t i = 0; i < num_names; i++) {
|
||||
llvm::StringRef name;
|
||||
Status error;
|
||||
success = names_array->GetItemAtIndexAsString(i, name);
|
||||
target.AddNameToBreakpoint(result_sp, name.str().c_str(), error);
|
||||
if (std::optional<llvm::StringRef> maybe_name =
|
||||
names_array->GetItemAtIndexAsString(i))
|
||||
target.AddNameToBreakpoint(result_sp, *maybe_name, error);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -238,11 +237,10 @@ bool Breakpoint::SerializedBreakpointMatchesNames(
|
||||
size_t num_names = names_array->GetSize();
|
||||
|
||||
for (size_t i = 0; i < num_names; i++) {
|
||||
llvm::StringRef name;
|
||||
if (names_array->GetItemAtIndexAsString(i, name)) {
|
||||
if (llvm::is_contained(names, name))
|
||||
return true;
|
||||
}
|
||||
std::optional<llvm::StringRef> maybe_name =
|
||||
names_array->GetItemAtIndexAsString(i);
|
||||
if (maybe_name && llvm::is_contained(names, *maybe_name))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user