================
@@ -538,15 +539,156 @@ void CPlusPlusLanguage::CxxMethodName::Parse() {
}
}
-llvm::StringRef
-CPlusPlusLanguage::CxxMethodName::GetBasenameNoTemplateParameters() {
- llvm::StringRef basename = GetBasename();
- size_t arg_start, arg_end;
- llvm::StringRef parens("<>", 2);
- if (ReverseFindMatchingChars(basename, parens, arg_start, arg_end))
- return basename.substr(0, arg_start);
+bool CPlusPlusLanguage::CxxMethodName::NameMatches(llvm::StringRef full_name,
+ llvm::StringRef pattern,
+ MatchOptions options) {
+ constexpr llvm::StringRef abi_prefix = "[abi:";
+ constexpr char abi_end = ']';
+ constexpr char open_angle = '<';
+ constexpr char close_angle = '>';
+ size_t f_idx = 0;
+ size_t p_idx = 0;
+
+ while (f_idx < full_name.size()) {
+ const char in_char = full_name[f_idx];
+ // input may have extra abi_tag / template so we still loop
+ const bool match_empty = p_idx >= pattern.size();
+ const char ma_char = match_empty ? '\0' : pattern[p_idx];
+
+ // skip abi_tags.
+ if (options.skip_tags && in_char == '[' &&
+ full_name.substr(f_idx).starts_with(abi_prefix)) {
+
+ const size_t tag_end = full_name.find(abi_end, f_idx);
+ if (tag_end != llvm::StringRef::npos) {
+ const size_t in_tag_len = tag_end - f_idx + 1;
+
+ if (!match_empty && pattern.substr(p_idx).starts_with(abi_prefix)) {
+ const size_t match_tag_end = pattern.find(abi_end, p_idx);
+ if (match_tag_end != llvm::StringRef::npos) {
+ const size_t ma_tag_len = match_tag_end - p_idx + 1;
+
+ // match may only have only one of the input's abi_tags.
+ // we only skip if the abi_tag matches.
+ if ((in_tag_len == ma_tag_len) &&
+ full_name.substr(f_idx, in_tag_len) ==
+ pattern.substr(p_idx, ma_tag_len)) {
+ p_idx += ma_tag_len;
+ }
+ }
+ }
+
+ f_idx += in_tag_len;
+ continue;
+ }
+ }
+
+ // skip template_tags.
+ if (options.skip_templates && in_char == open_angle &&
+ ma_char != open_angle) {
----------------
adrian-prantl wrote:
I wonder if this becomes more readable if you just replace open_angle with `'<'`
https://github.com/llvm/llvm-project/pull/170527
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits