Hi,
I’m a software developer and in my company we use clang to parse c++ code.
I’m in trouble to go to a call back when I’m using an AST matcher.
Here is the problem:
I already use the function “ clang::ast_matchers::MatchFinder::matchAST(ASTContext&)” and it works perfectly. But, in a particular case, I would like to match only within a subtree so I try to use “ clang::ast_matchers::MatchFinder::match(constT &node, ASTContext&)” but I never reach my callback.
Here a sample of a source code
clang::ast_matchers::MatchFinder matcherFinder;
matcherFinder.addMatcher(binaryOperatorMatcher, new MatchCallback(
[&cleanListField](cla::MatchFinder::MatchResult const & matchRes)
{
auto binaryOperator = matchRes.Nodes.getNodeAsclang::Stmt(binaryOperatorNode);
binaryOperator->dumpColor();
}));
matcherFinder.match((*constructor), constructor->getASTContext());
//matcherFinder.matchAST(constructor->getASTContext());
As we can see in the example, the subtree root is a clang::CXXConstructorDecl.
Thanks you in advance.
Best regards.
Anthony LEFORT
Software engineer
3 rue Marcel Allégot
92190 Meudon - France
CAST, Leader in Automated Application Intelligence
Achieve Insight. Deliver Excellence.
www.castsoftware.com | Gain visibility into application quality to proactively manage risk and improve team performance.