diff options
| author | Zachary Turner <zturner@google.com> | 2016-09-17 02:00:02 +0000 |
|---|---|---|
| committer | Zachary Turner <zturner@google.com> | 2016-09-17 02:00:02 +0000 |
| commit | 6fa7681bb613f4b92889b55a232507671e8f39be (patch) | |
| tree | 2b67bb2fac624c5cda50d4156b9e461dafdac2f1 /lldb/source/Breakpoint/BreakpointID.cpp | |
| parent | 271106cbb9d1ed70d6e57b72612b6653ba20fb10 (diff) | |
| download | bcm5719-llvm-6fa7681bb613f4b92889b55a232507671e8f39be.tar.gz bcm5719-llvm-6fa7681bb613f4b92889b55a232507671e8f39be.zip | |
Convert many functions to use StringRefs.
Where possible, remove the const char* version. To keep the
risk and impact here minimal, I've only done the simplest
functions.
In the process, I found a few opportunities for adding some
unit tests, so I added those as well.
Tested on Windows, Linux, and OSX.
llvm-svn: 281799
Diffstat (limited to 'lldb/source/Breakpoint/BreakpointID.cpp')
| -rw-r--r-- | lldb/source/Breakpoint/BreakpointID.cpp | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/lldb/source/Breakpoint/BreakpointID.cpp b/lldb/source/Breakpoint/BreakpointID.cpp index 9ab7adf48c4..c237b22ec1d 100644 --- a/lldb/source/Breakpoint/BreakpointID.cpp +++ b/lldb/source/Breakpoint/BreakpointID.cpp @@ -107,14 +107,21 @@ bool BreakpointID::ParseCanonicalReference(const char *input, return false; } -bool BreakpointID::StringIsBreakpointName(const char *name, Error &error) { +bool BreakpointID::StringIsBreakpointName(llvm::StringRef str, Error &error) { error.Clear(); + if (str.empty()) + return false; - if (name && (name[0] >= 'A' && name[0] <= 'z')) { - if (strcspn(name, ".- ") != strlen(name)) { - error.SetErrorStringWithFormat("invalid breakpoint name: \"%s\"", name); - } - return true; - } else + // First character must be a letter or _ + if (!isalpha(str[0]) || str[0] != '_') + return false; + + // Cannot contain ., -, or space. + if (str.find_first_of(".- ") != llvm::StringRef::npos) { + error.SetErrorStringWithFormat("invalid breakpoint name: \"%s\"", + str.str().c_str()); return false; + } + + return true; } |

