-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[AstMatcher]templateArgumentCountIs
support FunctionDecl
#130416
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
Changes from all commits
ca39210
97ea315
b28bd17
397c487
c04d320
d4d9536
3e2a7ef
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4108,8 +4108,14 @@ <h2 id="narrowing-matchers">Narrowing Matchers</h2> | |
Given | ||
template<typename T> struct C {}; | ||
C<int> c; | ||
template<typename T> void f() {} | ||
void func() { f<int>(); }; | ||
|
||
classTemplateSpecializationDecl(templateArgumentCountIs(1)) | ||
matches C<int>. | ||
|
||
functionDecl(templateArgumentCountIs(1)) | ||
matches f<int>(); | ||
</pre></td></tr> | ||
|
||
|
||
|
@@ -4833,6 +4839,23 @@ <h2 id="narrowing-matchers">Narrowing Matchers</h2> | |
</pre></td></tr> | ||
|
||
|
||
<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>></td><td class="name" onclick="toggle('templateArgumentCountIs2')"><a name="templateArgumentCountIs2Anchor">templateArgumentCountIs</a></td><td>unsigned N</td></tr> | ||
<tr><td colspan="4" class="doc" id="templateArgumentCountIs2"><pre>Matches if the number of template arguments equals N. | ||
|
||
Given | ||
template<typename T> struct C {}; | ||
C<int> c; | ||
template<typename T> void f() {} | ||
void func() { f<int>(); }; | ||
|
||
classTemplateSpecializationDecl(templateArgumentCountIs(1)) | ||
matches C<int>. | ||
|
||
functionDecl(templateArgumentCountIs(1)) | ||
matches f<int>(); | ||
</pre></td></tr> | ||
|
||
|
||
<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1FunctionProtoType.html">FunctionProtoType</a>></td><td class="name" onclick="toggle('hasDynamicExceptionSpec1')"><a name="hasDynamicExceptionSpec1Anchor">hasDynamicExceptionSpec</a></td><td></td></tr> | ||
<tr><td colspan="4" class="doc" id="hasDynamicExceptionSpec1"><pre>Matches functions that have a dynamic exception specification. | ||
|
||
|
@@ -5783,14 +5806,20 @@ <h2 id="narrowing-matchers">Narrowing Matchers</h2> | |
</pre></td></tr> | ||
|
||
|
||
<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>></td><td class="name" onclick="toggle('templateArgumentCountIs1')"><a name="templateArgumentCountIs1Anchor">templateArgumentCountIs</a></td><td>unsigned N</td></tr> | ||
<tr><td colspan="4" class="doc" id="templateArgumentCountIs1"><pre>Matches if the number of template arguments equals N. | ||
<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>></td><td class="name" onclick="toggle('templateArgumentCountIs3')"><a name="templateArgumentCountIs3Anchor">templateArgumentCountIs</a></td><td>unsigned N</td></tr> | ||
<tr><td colspan="4" class="doc" id="templateArgumentCountIs3"><pre>Matches if the number of template arguments equals N. | ||
|
||
Given | ||
template<typename T> struct C {}; | ||
C<int> c; | ||
template<typename T> void f() {} | ||
void func() { f<int>(); }; | ||
|
||
classTemplateSpecializationDecl(templateArgumentCountIs(1)) | ||
matches C<int>. | ||
|
||
functionDecl(templateArgumentCountIs(1)) | ||
matches f<int>(); | ||
</pre></td></tr> | ||
|
||
|
||
|
@@ -6219,6 +6248,23 @@ <h2 id="narrowing-matchers">Narrowing Matchers</h2> | |
Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl</a>> | ||
</pre></td></tr> | ||
|
||
|
||
<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1VarTemplateSpecializationDecl.html">VarTemplateSpecializationDecl</a>></td><td class="name" onclick="toggle('templateArgumentCountIs1')"><a name="templateArgumentCountIs1Anchor">templateArgumentCountIs</a></td><td>unsigned N</td></tr> | ||
<tr><td colspan="4" class="doc" id="templateArgumentCountIs1"><pre>Matches if the number of template arguments equals N. | ||
|
||
Given | ||
template<typename T> struct C {}; | ||
C<int> c; | ||
template<typename T> void f() {} | ||
void func() { f<int>(); }; | ||
|
||
classTemplateSpecializationDecl(templateArgumentCountIs(1)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same |
||
matches C<int>. | ||
|
||
functionDecl(templateArgumentCountIs(1)) | ||
matches f<int>(); | ||
</pre></td></tr> | ||
|
||
<!--END_NARROWING_MATCHERS --> | ||
</table> | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1084,12 +1084,19 @@ AST_POLYMORPHIC_MATCHER_P2( | |
/// \code | ||
/// template<typename T> struct C {}; | ||
/// C<int> c; | ||
/// template<typename T> void f() {} | ||
/// void func() { f<int>(); }; | ||
/// \endcode | ||
/// | ||
/// classTemplateSpecializationDecl(templateArgumentCountIs(1)) | ||
/// matches C<int>. | ||
/// | ||
/// functionDecl(templateArgumentCountIs(1)) | ||
/// matches f<int>(); | ||
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 commentThe 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 |
||
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.
Shouldn't this example be for
functionDecl
, instead ofclassTemplateSpecializationDecl
?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.