This patch enables matching for FunctionDecls that have bodies.
Details
Diff Detail
Event Timeline
The examples and test code you use seem to imply that the isDefinition() matcher may be all you need; is isDefinition() insufficient for some reason? If so, can you expand the test cases to cover that particular usage? Also, FunctionDecl::getBody() does more work than FunctionDecl::hasBody() -- it would be better to implement the AST matcher in terms of FunctionDecl::hasBody() instead.
Match only FunctionDecls which are definitions and ignore redeclarations without bodies.
include/clang/ASTMatchers/ASTMatchers.h | ||
---|---|---|
3118 | s/declaration/definition. | |
include/clang/ASTMatchers/ASTMatchersInternal.h | ||
1590 | Indentation here is incorrect, you should run clang-format over the patch. | |
lib/ASTMatchers/ASTMatchersInternal.cpp | ||
342 ↗ | (On Diff #45232) | The specialization should live in the header file, not the source file. |
344 ↗ | (On Diff #45232) | I would use Node.doesThisDeclarationHaveABody() instead; otherwise this will match definitions that are explicitly deleted, which isn't particularly useful. |
With one small nit, LGTM, thanks!
include/clang/ASTMatchers/ASTMatchersInternal.h | ||
---|---|---|
1596 | s/NULL/nullptr |
s/declaration/definition.