llvm-project/clang/unittests/ASTMatchers
Adam Balogh dbd45b2db8 [ASTMatchers] Fix `hasBody` for the descendants of `FunctionDecl`
//AST Matcher// `hasBody` is a polymorphic matcher that behaves
differently for loop statements and function declarations. The main
difference is the for functions declarations it does not only call
`FunctionDecl::getBody()` but first checks whether the declaration in
question is that specific declaration which has the body by calling
`FunctionDecl::doesThisDeclarationHaveABody()`. This is achieved by
specialization of the template `GetBodyMatcher`. Unfortunately template
specializations do not catch the descendants of the class for which the
template is specialized. Therefore it does not work correcly for the
descendants of `FunctionDecl`, such as `CXXMethodDecl`,
`CXXConstructorDecl`, `CXXDestructorDecl` etc. This patch fixes this
issue by using a template metaprogram.

The patch also introduces a new matcher `hasAnyBody` which matches
declarations which have a body present in the AST but not necessarily
belonging to that particular declaration.

Differential Revision: https://reviews.llvm.org/D87527
2020-09-16 13:16:51 +02:00
..
Dynamic [ASTMatchers] Enhanced support for matchers taking Regex arguments 2020-07-02 14:52:25 +01:00
ASTMatchersInternalTest.cpp Use libClangTesting in the unittest for AST matchers 2020-06-04 17:40:39 +02:00
ASTMatchersNarrowingTest.cpp Enable the test for hasArraySize() AST matcher in all language modes 2020-07-20 10:23:00 +02:00
ASTMatchersNodeTest.cpp [clang] Add a matcher for template template parameters. 2020-08-11 16:01:36 +01:00
ASTMatchersTest.h Use TestClangConfig in AST Matchers tests and run them in more configurations 2020-07-16 18:36:53 +02:00
ASTMatchersTraversalTest.cpp [ASTMatchers] Fix `hasBody` for the descendants of `FunctionDecl` 2020-09-16 13:16:51 +02:00
CMakeLists.txt On Windows build, making the /bigobj flag global , instead of passing it per file. 2020-07-28 18:04:36 -05:00
GtestMatchersTest.cpp [AST matchers] Add basic matchers for googletest EXPECT/ASSERT calls. 2020-02-21 12:05:15 -05:00