================
@@ -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) {
+ size_t depth = 1;
+ size_t tmp_idx = f_idx + 1;
+ bool found_end = false;
+ for (; tmp_idx < full_name.size(); ++tmp_idx) {
+ const char cur = full_name[tmp_idx];
+ if (cur == open_angle)
+ depth++;
+ else if (cur == close_angle) {
+ depth--;
+
+ if (depth == 0) {
+ found_end = true;
+ break;
+ }
+ }
+ }
+
+ if (found_end) {
+ f_idx = tmp_idx + 1;
+ continue;
+ }
+ }
+
+ // input contains characters that are not in match.
+ if (match_empty || in_char != ma_char)
+ return false;
+
+ f_idx++;
+ p_idx++;
+ }
+
+ // Ensure we fully consumed the match string.
+ return p_idx == pattern.size();
+}
+
+static llvm::StringRef NextContext(llvm::StringRef context, size_t &end_pos) {
----------------
adrian-prantl wrote:
Can you add a doxygen comment explaining what this function does?
https://github.com/llvm/llvm-project/pull/170527
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits