1 //===-- NameMatches.cpp -----------------------------------------*- C++ -*-===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is distributed under the University of Illinois Open Source 6 // License. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 #include "lldb/Utility/NameMatches.h" 10 #include "lldb/Utility/RegularExpression.h" 11 12 #include "llvm/ADT/StringRef.h" 13 14 using namespace lldb_private; 15 16 bool lldb_private::NameMatches(llvm::StringRef name, NameMatch match_type, 17 llvm::StringRef match) { 18 switch (match_type) { 19 case NameMatch::Ignore: 20 return true; 21 case NameMatch::Equals: 22 return name == match; 23 case NameMatch::Contains: 24 return name.contains(match); 25 case NameMatch::StartsWith: 26 return name.startswith(match); 27 case NameMatch::EndsWith: 28 return name.endswith(match); 29 case NameMatch::RegularExpression: { 30 RegularExpression regex(match); 31 return regex.Execute(name); 32 } 33 } 34 return false; 35 } 36