[cfe-dev] Trouble to use MatchFinder::match

Anthony Lefort via cfe-dev cfe-dev at lists.llvm.org
Fri Apr 28 09:37:43 PDT 2017


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.getNodeAs<clang::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<http://www.castsoftware.com/> | Gain visibility into application quality to proactively manage risk and improve team performance.




-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20170428/60d05846/attachment.html>


More information about the cfe-dev mailing list