diff options
author | Zachary Turner <zturner@google.com> | 2016-10-06 21:22:44 +0000 |
---|---|---|
committer | Zachary Turner <zturner@google.com> | 2016-10-06 21:22:44 +0000 |
commit | 4fa098a5c0223dab6ae10da6f01541e943cc0bbf (patch) | |
tree | f22c6bf0e5f05bc7b0c405fbbb81a7f444a3364f /lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp | |
parent | 60fb35b20a0fc335e5f626c44006eed3a49d3bd7 (diff) | |
download | bcm5719-llvm-4fa098a5c0223dab6ae10da6f01541e943cc0bbf.tar.gz bcm5719-llvm-4fa098a5c0223dab6ae10da6f01541e943cc0bbf.zip |
Convert UniqueCStringMap to use StringRef.
llvm-svn: 283494
Diffstat (limited to 'lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp')
-rw-r--r-- | lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp | 61 |
1 files changed, 33 insertions, 28 deletions
diff --git a/lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp b/lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp index 8955baaebf3..1d6522f01a3 100644 --- a/lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp +++ b/lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp @@ -83,41 +83,46 @@ void ObjCLanguage::MethodName::Clear() { m_category_is_valid = false; } -bool ObjCLanguage::MethodName::SetName(const char *name, bool strict) { +bool ObjCLanguage::MethodName::SetName(llvm::StringRef name, bool strict) { Clear(); - if (name && name[0]) { - // If "strict" is true. then the method must be specified with a - // '+' or '-' at the beginning. If "strict" is false, then the '+' - // or '-' can be omitted - bool valid_prefix = false; - - if (name[0] == '+' || name[0] == '-') { - valid_prefix = name[1] == '['; - if (name[0] == '+') - m_type = eTypeClassMethod; - else - m_type = eTypeInstanceMethod; - } else if (!strict) { - // "strict" is false, the name just needs to start with '[' - valid_prefix = name[0] == '['; - } + if (name.empty()) + return IsValid(strict); + + // If "strict" is true. then the method must be specified with a + // '+' or '-' at the beginning. If "strict" is false, then the '+' + // or '-' can be omitted + bool valid_prefix = false; + + if (name[0] == '+' || name[0] == '-') { + valid_prefix = name[1] == '['; + if (name[0] == '+') + m_type = eTypeClassMethod; + else + m_type = eTypeInstanceMethod; + } else if (!strict) { + // "strict" is false, the name just needs to start with '[' + valid_prefix = name[0] == '['; + } - if (valid_prefix) { - int name_len = strlen(name); - // Objective C methods must have at least: - // "-[" or "+[" prefix - // One character for a class name - // One character for the space between the class name - // One character for the method name - // "]" suffix - if (name_len >= (5 + (strict ? 1 : 0)) && name[name_len - 1] == ']') { - m_full.SetCStringWithLength(name, name_len); - } + if (valid_prefix) { + int name_len = name.size(); + // Objective C methods must have at least: + // "-[" or "+[" prefix + // One character for a class name + // One character for the space between the class name + // One character for the method name + // "]" suffix + if (name_len >= (5 + (strict ? 1 : 0)) && name.back() == ']') { + m_full.SetString(name); } } return IsValid(strict); } +bool ObjCLanguage::MethodName::SetName(const char *name, bool strict) { + return SetName(llvm::StringRef(name), strict); +} + const ConstString &ObjCLanguage::MethodName::GetClassName() { if (!m_class) { if (IsValid(false)) { |