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/Utility/NameMatches.h"
10 #include "lldb/Core/RegularExpression.h"
12 #include "llvm/ADT/StringRef.h"
14 using namespace lldb_private;
16 bool lldb_private::NameMatches(llvm::StringRef name, NameMatchType match_type,
17 llvm::StringRef match) {
18 if (match_type == eNameMatchIgnore)
24 if (name.empty() || match.empty())
28 case eNameMatchIgnore: // This case cannot occur: tested before
30 case eNameMatchEquals:
32 case eNameMatchContains:
33 return name.contains(match);
34 case eNameMatchStartsWith:
35 return name.startswith(match);
36 case eNameMatchEndsWith:
37 return name.endswith(match);
38 case eNameMatchRegularExpression: {
39 RegularExpression regex(match);
40 return regex.Execute(name);