[clang] [ASTMatchers] Extend hasName matcher when matching templates (PR #100349)
Julian Schmidt via cfe-commits
cfe-commits at lists.llvm.org
Sat Aug 24 06:55:21 PDT 2024
================
@@ -638,6 +638,39 @@ bool HasNameMatcher::matchesNodeFullFast(const NamedDecl &Node) const {
return Patterns.foundMatch(/*AllowFullyQualified=*/true);
}
+static std::optional<StringRef> consumePatternBack(StringRef Pattern,
+ StringRef Target) {
+ while (!Pattern.empty()) {
+ auto Index = Pattern.rfind("<*>");
+ if (Index == StringRef::npos) {
+ if (Target.consume_back(Pattern))
+ return Target;
+ return {};
+ }
+ auto Suffix = Pattern.substr(Index + 2);
+ if (!Target.consume_back(Suffix))
----------------
5chmidti wrote:
Because I had to check this, could you please add a comment why only `+ 2` is used?
Something like:
> We consume pattern suffix that includes only the `>` of our `<*>`, and drop every character from the back until we encounter the corresponding `<` character to ensure balanced angle brackets.
https://github.com/llvm/llvm-project/pull/100349
More information about the cfe-commits
mailing list