[clang] [ASTMatchers] Extend hasName matcher when matching templates (PR #100349)

2024-08-24 Thread Julian Schmidt via cfe-commits
@@ -653,10 +686,12 @@ bool HasNameMatcher::matchesNodeFullSlow(const NamedDecl &Node) const { for (const StringRef Pattern : Names) { if (Pattern.starts_with("::")) { -if (FullName == Pattern) +if (auto Result = consumePatternBack(Pattern, FullName);

[clang] [ASTMatchers] Extend hasName matcher when matching templates (PR #100349)

2024-08-24 Thread Julian Schmidt via cfe-commits
https://github.com/5chmidti requested changes to this pull request. I think it does make sense to add this wildcard. The motivation to skip regex sounds like a good one, and it does make sense to special case templates specifically. The implementation looks correct to me. Just some small things

[clang] [ASTMatchers] Extend hasName matcher when matching templates (PR #100349)

2024-08-24 Thread Julian Schmidt via cfe-commits
@@ -638,6 +638,39 @@ bool HasNameMatcher::matchesNodeFullFast(const NamedDecl &Node) const { return Patterns.foundMatch(/*AllowFullyQualified=*/true); } +static std::optional consumePatternBack(StringRef Pattern, + StringRef

[clang] [ASTMatchers] Extend hasName matcher when matching templates (PR #100349)

2024-08-24 Thread Julian Schmidt via cfe-commits
@@ -638,6 +638,39 @@ bool HasNameMatcher::matchesNodeFullFast(const NamedDecl &Node) const { return Patterns.foundMatch(/*AllowFullyQualified=*/true); } +static std::optional consumePatternBack(StringRef Pattern, + StringRef

[clang] [ASTMatchers] Extend hasName matcher when matching templates (PR #100349)

2024-08-24 Thread Julian Schmidt via cfe-commits
@@ -638,6 +638,39 @@ bool HasNameMatcher::matchesNodeFullFast(const NamedDecl &Node) const { return Patterns.foundMatch(/*AllowFullyQualified=*/true); } +static std::optional consumePatternBack(StringRef Pattern, + StringRef

[clang] [ASTMatchers] Extend hasName matcher when matching templates (PR #100349)

2024-08-24 Thread Julian Schmidt via cfe-commits
https://github.com/5chmidti edited https://github.com/llvm/llvm-project/pull/100349 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [ASTMatchers] Extend hasName matcher when matching templates (PR #100349)

2024-07-29 Thread Aaron Ballman via cfe-commits
@@ -3076,6 +3076,21 @@ inline internal::BindableMatcher sizeOfExpr( /// \code /// namespace a { namespace b { class X; } } /// \endcode +/// +/// Qualified names in templated classes can be matched explicitly or implicity +/// by specifying the template type or using `<*>` to

[clang] [ASTMatchers] Extend hasName matcher when matching templates (PR #100349)

2024-07-29 Thread Aaron Ballman via cfe-commits
https://github.com/AaronBallman commented: The changes should also come with a release note in clang/docs/ReleaseNotes.rst. https://github.com/llvm/llvm-project/pull/100349 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/

[clang] [ASTMatchers] Extend hasName matcher when matching templates (PR #100349)

2024-07-29 Thread Aaron Ballman via cfe-commits
https://github.com/AaronBallman edited https://github.com/llvm/llvm-project/pull/100349 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [ASTMatchers] Extend hasName matcher when matching templates (PR #100349)

2024-07-26 Thread Nathan James via cfe-commits
https://github.com/njames93 updated https://github.com/llvm/llvm-project/pull/100349 >From a81c1b2ee0bd0d0622abf1d5ec06846a2e2e3a27 Mon Sep 17 00:00:00 2001 From: Nathan James Date: Wed, 24 Jul 2024 12:43:39 +0100 Subject: [PATCH] [ASMMatchers] Extend hasName matcher when matching templates Al

[clang] [ASTMatchers] Extend hasName matcher when matching templates (PR #100349)

2024-07-25 Thread Aaron Ballman via cfe-commits
AaronBallman wrote: > > > @AaronBallman That's a good point, I didn't account for how defaulted > > > template arguments aren't printed. Would using `<*>` ~or a more rustic > > > approach of `<_>`~ be a good alternative? > > > > > > I was thinking about that, but I keep coming around to wonde

[clang] [ASTMatchers] Extend hasName matcher when matching templates (PR #100349)

2024-07-25 Thread Nathan James via cfe-commits
njames93 wrote: @AaronBallman That's a good point, I didn't account for how defaulted template arguments aren't printed. Would using `<*>` or a more rustic approach of `<_>` be a good alternative? https://github.com/llvm/llvm-project/pull/100349 ___ c

[clang] [ASTMatchers] Extend hasName matcher when matching templates (PR #100349)

2024-07-25 Thread Aaron Ballman via cfe-commits
AaronBallman wrote: > Allow users to match all record instantiations by using <> as a wildcard. I think this will change the behavior of existing matchers, consider: ``` template struct S { Ty Val; void Call(); }; int main() { S<> s; s.Call(); // Currently matches only this S anothe

[clang] [ASTMatchers] Extend hasName matcher when matching templates (PR #100349)

2024-07-25 Thread Aaron Ballman via cfe-commits
https://github.com/AaronBallman edited https://github.com/llvm/llvm-project/pull/100349 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits