1 //===-- NameMatches.cpp -----------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
9 #include "lldb/Core/RegularExpression.h"
10 #include "lldb/Utility/NameMatches.h"
12 #include "llvm/ADT/StringRef.h"
14 using namespace lldb_private;
17 lldb_private::NameMatches(const char *name, NameMatchType match_type, const char *match)
19 if (match_type == eNameMatchIgnore)
27 llvm::StringRef name_sref(name);
28 llvm::StringRef match_sref(match);
31 case eNameMatchIgnore: // This case cannot occur: tested before
33 case eNameMatchEquals:
34 return name_sref == match_sref;
35 case eNameMatchContains:
36 return name_sref.find(match_sref) != llvm::StringRef::npos;
37 case eNameMatchStartsWith:
38 return name_sref.startswith(match_sref);
39 case eNameMatchEndsWith:
40 return name_sref.endswith(match_sref);
41 case eNameMatchRegularExpression:
43 RegularExpression regex(match);
44 return regex.Execute(name);