summaryrefslogtreecommitdiffstats
path: root/lldb/source/Utility/NameMatches.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lldb/source/Utility/NameMatches.cpp')
-rw-r--r--lldb/source/Utility/NameMatches.cpp41
1 files changed, 20 insertions, 21 deletions
diff --git a/lldb/source/Utility/NameMatches.cpp b/lldb/source/Utility/NameMatches.cpp
index a15ab4bd065..7b733d24eba 100644
--- a/lldb/source/Utility/NameMatches.cpp
+++ b/lldb/source/Utility/NameMatches.cpp
@@ -13,33 +13,32 @@
using namespace lldb_private;
-bool lldb_private::NameMatches(const char *name, NameMatchType match_type,
- const char *match) {
+bool lldb_private::NameMatches(llvm::StringRef name, NameMatchType match_type,
+ llvm::StringRef match) {
if (match_type == eNameMatchIgnore)
return true;
if (name == match)
return true;
- if (name && match) {
- llvm::StringRef name_sref(name);
- llvm::StringRef match_sref(match);
- switch (match_type) {
- case eNameMatchIgnore: // This case cannot occur: tested before
- return true;
- case eNameMatchEquals:
- return name_sref == match_sref;
- case eNameMatchContains:
- return name_sref.find(match_sref) != llvm::StringRef::npos;
- case eNameMatchStartsWith:
- return name_sref.startswith(match_sref);
- case eNameMatchEndsWith:
- return name_sref.endswith(match_sref);
- case eNameMatchRegularExpression: {
- RegularExpression regex(match_sref);
- return regex.Execute(name_sref);
- } break;
- }
+ if (name.empty() || match.empty())
+ return false;
+
+ switch (match_type) {
+ case eNameMatchIgnore: // This case cannot occur: tested before
+ return true;
+ case eNameMatchEquals:
+ return name == match;
+ case eNameMatchContains:
+ return name.contains(match);
+ case eNameMatchStartsWith:
+ return name.startswith(match);
+ case eNameMatchEndsWith:
+ return name.endswith(match);
+ case eNameMatchRegularExpression: {
+ RegularExpression regex(match);
+ return regex.Execute(name);
+ } break;
}
return false;
}
OpenPOWER on IntegriCloud