-
Notifications
You must be signed in to change notification settings - Fork 13k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[AstMatcher]templateArgumentCountIs
support FunctionDecl
#130416
[AstMatcher]templateArgumentCountIs
support FunctionDecl
#130416
Conversation
The old `constructFrom` has hidden requirement which TypeMatcher must be used before ArgumentMatcher because there are bind inside. Inlining this function to make it more intuitive.
`hasTemplateArgument` and `templateArgumentCountIs` are always used together. It is more convenient to make then support `FunctionDecl`.
This stack of pull requests is managed by Graphite. Learn more about stacking. |
@llvm/pr-subscribers-clang Author: Congcong Cai (HerrCai0907) Changes
Full diff: https://github.com/llvm/llvm-project/pull/130416.diff 1 Files Affected:
diff --git a/clang/include/clang/ASTMatchers/ASTMatchers.h b/clang/include/clang/ASTMatchers/ASTMatchers.h
index 0f7e3a8a01762..03d522072f6c1 100644
--- a/clang/include/clang/ASTMatchers/ASTMatchers.h
+++ b/clang/include/clang/ASTMatchers/ASTMatchers.h
@@ -1090,6 +1090,7 @@ AST_POLYMORPHIC_MATCHER_P2(
AST_POLYMORPHIC_MATCHER_P(
templateArgumentCountIs,
AST_POLYMORPHIC_SUPPORTED_TYPES(ClassTemplateSpecializationDecl,
+ VarTemplateSpecializationDecl, FunctionDecl,
TemplateSpecializationType),
unsigned, N) {
return internal::getTemplateSpecializationArgs(Node).size() == N;
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You may need to update documentation for this matcher in clang/docs/LibASTMatchersReference.html
dump-ast-matchers has some bug. I will fix it after #130726 merging |
`hasTemplateArgument` and `templateArgumentCountIs` are always used together. It is more convenient to make then support `FunctionDecl`.
97ea315
to
b28bd17
Compare
…tcher_templateargumentcountis_support_functiondecl_
…ateargumentcountis_support_functiondecl_' into users/ccc03-08-_astmatcher_templateargumentcountis_support_functiondecl_
<tr><td colspan="4" class="doc" id="templateArgumentCountIs2"><pre>Matches if the number of template arguments equals N. | ||
|
||
Given | ||
template<typename T> struct C {}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this example be for functionDecl
, instead of classTemplateSpecializationDecl
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is auto-generated from the python script based on the comments on the matcher.
Given | ||
template<typename T> struct C {}; | ||
C<int> c; | ||
classTemplateSpecializationDecl(templateArgumentCountIs(1)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same
Adding @AaronBallman as owner for |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally LG, but I did have a testing and commenting request.
Please also add a note to clang/docs/ReleaseNotes.rst
so users know about the new match.
<tr><td colspan="4" class="doc" id="templateArgumentCountIs2"><pre>Matches if the number of template arguments equals N. | ||
|
||
Given | ||
template<typename T> struct C {}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is auto-generated from the python script based on the comments on the matcher.
@@ -1090,6 +1090,7 @@ AST_POLYMORPHIC_MATCHER_P2( | |||
AST_POLYMORPHIC_MATCHER_P( | |||
templateArgumentCountIs, | |||
AST_POLYMORPHIC_SUPPORTED_TYPES(ClassTemplateSpecializationDecl, | |||
VarTemplateSpecializationDecl, FunctionDecl, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It'd probably be good to update the example code above. Also, can you add test coverage to clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Merge activity
|
…0416) `hasTemplateArgument` and `templateArgumentCountIs` are always used together. It is more convenient to make then support `FunctionDecl`.
hasTemplateArgument
andtemplateArgumentCountIs
are always used together. It is more convenient to make then supportFunctionDecl
.