summaryrefslogtreecommitdiffstats
path: root/lldb/source/Breakpoint
diff options
context:
space:
mode:
authorZachary Turner <zturner@google.com>2017-05-12 05:49:54 +0000
committerZachary Turner <zturner@google.com>2017-05-12 05:49:54 +0000
commit2833321f09efd9387257d17a3ef5128841142e6f (patch)
tree734c009de6f4895529effceec687d377434ba2d9 /lldb/source/Breakpoint
parent41c99364602a6965c30be674d75451ad87658d8c (diff)
downloadbcm5719-llvm-2833321f09efd9387257d17a3ef5128841142e6f.tar.gz
bcm5719-llvm-2833321f09efd9387257d17a3ef5128841142e6f.zip
Update StructuredData::String to return StringRefs.
It was returning const std::string& which was leading to unnecessary copies all over the place, and preventing people from doing things like Dict->GetValueForKeyAsString("foo", ref); llvm-svn: 302875
Diffstat (limited to 'lldb/source/Breakpoint')
-rw-r--r--lldb/source/Breakpoint/Breakpoint.cpp12
-rw-r--r--lldb/source/Breakpoint/BreakpointOptions.cpp4
-rw-r--r--lldb/source/Breakpoint/BreakpointResolver.cpp12
-rw-r--r--lldb/source/Breakpoint/BreakpointResolverAddress.cpp2
-rw-r--r--lldb/source/Breakpoint/BreakpointResolverFileLine.cpp2
-rw-r--r--lldb/source/Breakpoint/BreakpointResolverFileRegex.cpp4
-rw-r--r--lldb/source/Breakpoint/BreakpointResolverName.cpp10
7 files changed, 23 insertions, 23 deletions
diff --git a/lldb/source/Breakpoint/Breakpoint.cpp b/lldb/source/Breakpoint/Breakpoint.cpp
index c839c1eb344..4c58f823134 100644
--- a/lldb/source/Breakpoint/Breakpoint.cpp
+++ b/lldb/source/Breakpoint/Breakpoint.cpp
@@ -207,10 +207,10 @@ lldb::BreakpointSP Breakpoint::CreateFromStructuredData(
if (success && names_array) {
size_t num_names = names_array->GetSize();
for (size_t i = 0; i < num_names; i++) {
- std::string name;
+ llvm::StringRef name;
Status error;
success = names_array->GetItemAtIndexAsString(i, name);
- result_sp->AddName(name.c_str(), error);
+ result_sp->AddName(name, error);
}
}
@@ -242,7 +242,7 @@ bool Breakpoint::SerializedBreakpointMatchesNames(
std::vector<std::string>::iterator end = names.end();
for (size_t i = 0; i < num_names; i++) {
- std::string name;
+ llvm::StringRef name;
if (names_array->GetItemAtIndexAsString(i, name)) {
if (std::find(begin, end, name) != end) {
return true;
@@ -833,10 +833,10 @@ size_t Breakpoint::GetNumResolvedLocations() const {
size_t Breakpoint::GetNumLocations() const { return m_locations.GetSize(); }
-bool Breakpoint::AddName(const char *new_name, Status &error) {
- if (!new_name)
+bool Breakpoint::AddName(llvm::StringRef new_name, Status &error) {
+ if (new_name.empty())
return false;
- if (!BreakpointID::StringIsBreakpointName(llvm::StringRef(new_name), error)) {
+ if (!BreakpointID::StringIsBreakpointName(new_name, error)) {
error.SetErrorStringWithFormat("input name \"%s\" not a breakpoint name.",
new_name);
return false;
diff --git a/lldb/source/Breakpoint/BreakpointOptions.cpp b/lldb/source/Breakpoint/BreakpointOptions.cpp
index 9b9c9c2aec7..bef63cc0f22 100644
--- a/lldb/source/Breakpoint/BreakpointOptions.cpp
+++ b/lldb/source/Breakpoint/BreakpointOptions.cpp
@@ -73,7 +73,7 @@ BreakpointOptions::CommandData::CreateFromStructuredData(
if (success)
found_something = true;
- std::string interpreter_str;
+ llvm::StringRef interpreter_str;
ScriptLanguage interp_language;
success = options_dict.GetValueForKeyAsString(
GetKey(OptionNames::Interpreter), interpreter_str);
@@ -99,7 +99,7 @@ BreakpointOptions::CommandData::CreateFromStructuredData(
found_something = true;
size_t num_elems = user_source->GetSize();
for (size_t i = 0; i < num_elems; i++) {
- std::string elem_string;
+ llvm::StringRef elem_string;
success = user_source->GetItemAtIndexAsString(i, elem_string);
if (success)
data_up->user_source.AppendString(elem_string);
diff --git a/lldb/source/Breakpoint/BreakpointResolver.cpp b/lldb/source/Breakpoint/BreakpointResolver.cpp
index a6a3689e866..31aefb08f97 100644
--- a/lldb/source/Breakpoint/BreakpointResolver.cpp
+++ b/lldb/source/Breakpoint/BreakpointResolver.cpp
@@ -56,9 +56,9 @@ const char *BreakpointResolver::ResolverTyToName(enum ResolverTy type) {
}
BreakpointResolver::ResolverTy
-BreakpointResolver::NameToResolverTy(const char *name) {
+BreakpointResolver::NameToResolverTy(llvm::StringRef name) {
for (size_t i = 0; i < LastKnownResolverType; i++) {
- if (strcmp(name, g_ty_to_name[i]) == 0)
+ if (name == g_ty_to_name[i])
return (ResolverTy)i;
}
return UnknownResolver;
@@ -79,7 +79,7 @@ BreakpointResolverSP BreakpointResolver::CreateFromStructuredData(
return result_sp;
}
- std::string subclass_name;
+ llvm::StringRef subclass_name;
bool success = resolver_dict.GetValueForKeyAsString(
GetSerializationSubclassKey(), subclass_name);
@@ -90,10 +90,10 @@ BreakpointResolverSP BreakpointResolver::CreateFromStructuredData(
return result_sp;
}
- ResolverTy resolver_type = NameToResolverTy(subclass_name.c_str());
+ ResolverTy resolver_type = NameToResolverTy(subclass_name);
if (resolver_type == UnknownResolver) {
- error.SetErrorStringWithFormat("Unknown resolver type: %s.",
- subclass_name.c_str());
+ error.SetErrorStringWithFormatv("Unknown resolver type: {0}.",
+ subclass_name);
return result_sp;
}
diff --git a/lldb/source/Breakpoint/BreakpointResolverAddress.cpp b/lldb/source/Breakpoint/BreakpointResolverAddress.cpp
index 32e503cfb4d..32f2045ed59 100644
--- a/lldb/source/Breakpoint/BreakpointResolverAddress.cpp
+++ b/lldb/source/Breakpoint/BreakpointResolverAddress.cpp
@@ -45,7 +45,7 @@ BreakpointResolverAddress::~BreakpointResolverAddress() {}
BreakpointResolver *BreakpointResolverAddress::CreateFromStructuredData(
Breakpoint *bkpt, const StructuredData::Dictionary &options_dict,
Status &error) {
- std::string module_name;
+ llvm::StringRef module_name;
lldb::addr_t addr_offset;
FileSpec module_filespec;
bool success;
diff --git a/lldb/source/Breakpoint/BreakpointResolverFileLine.cpp b/lldb/source/Breakpoint/BreakpointResolverFileLine.cpp
index f618c1a3b56..780d25db9cc 100644
--- a/lldb/source/Breakpoint/BreakpointResolverFileLine.cpp
+++ b/lldb/source/Breakpoint/BreakpointResolverFileLine.cpp
@@ -39,7 +39,7 @@ BreakpointResolverFileLine::~BreakpointResolverFileLine() {}
BreakpointResolver *BreakpointResolverFileLine::CreateFromStructuredData(
Breakpoint *bkpt, const StructuredData::Dictionary &options_dict,
Status &error) {
- std::string filename;
+ llvm::StringRef filename;
uint32_t line_no;
bool check_inlines;
bool skip_prologue;
diff --git a/lldb/source/Breakpoint/BreakpointResolverFileRegex.cpp b/lldb/source/Breakpoint/BreakpointResolverFileRegex.cpp
index 8fe908d7d25..54c05a04246 100644
--- a/lldb/source/Breakpoint/BreakpointResolverFileRegex.cpp
+++ b/lldb/source/Breakpoint/BreakpointResolverFileRegex.cpp
@@ -40,7 +40,7 @@ BreakpointResolver *BreakpointResolverFileRegex::CreateFromStructuredData(
Status &error) {
bool success;
- std::string regex_string;
+ llvm::StringRef regex_string;
success = options_dict.GetValueForKeyAsString(
GetKey(OptionNames::RegexString), regex_string);
if (!success) {
@@ -65,7 +65,7 @@ BreakpointResolver *BreakpointResolverFileRegex::CreateFromStructuredData(
if (success && names_array) {
size_t num_names = names_array->GetSize();
for (size_t i = 0; i < num_names; i++) {
- std::string name;
+ llvm::StringRef name;
success = names_array->GetItemAtIndexAsString(i, name);
if (!success) {
error.SetErrorStringWithFormat(
diff --git a/lldb/source/Breakpoint/BreakpointResolverName.cpp b/lldb/source/Breakpoint/BreakpointResolverName.cpp
index 8da05b0f85f..468de35db0e 100644
--- a/lldb/source/Breakpoint/BreakpointResolverName.cpp
+++ b/lldb/source/Breakpoint/BreakpointResolverName.cpp
@@ -94,14 +94,14 @@ BreakpointResolver *BreakpointResolverName::CreateFromStructuredData(
Breakpoint *bkpt, const StructuredData::Dictionary &options_dict,
Status &error) {
LanguageType language = eLanguageTypeUnknown;
- std::string language_name;
+ llvm::StringRef language_name;
bool success = options_dict.GetValueForKeyAsString(
GetKey(OptionNames::LanguageName), language_name);
if (success) {
language = Language::GetLanguageTypeFromString(language_name);
if (language == eLanguageTypeUnknown) {
- error.SetErrorStringWithFormat("BRN::CFSD: Unknown language: %s.",
- language_name.c_str());
+ error.SetErrorStringWithFormatv("BRN::CFSD: Unknown language: {0}.",
+ language_name);
return nullptr;
}
}
@@ -122,7 +122,7 @@ BreakpointResolver *BreakpointResolverName::CreateFromStructuredData(
return nullptr;
}
- std::string regex_text;
+ llvm::StringRef regex_text;
success = options_dict.GetValueForKeyAsString(
GetKey(OptionNames::RegexString), regex_text);
if (success) {
@@ -162,7 +162,7 @@ BreakpointResolver *BreakpointResolverName::CreateFromStructuredData(
std::vector<uint32_t> name_masks;
for (size_t i = 0; i < num_elem; i++) {
uint32_t name_mask;
- std::string name;
+ llvm::StringRef name;
success = names_array->GetItemAtIndexAsString(i, name);
if (!success) {
OpenPOWER on IntegriCloud