Is there any way how to setup LangOptions for AST matcher? We have following matcher:
using namespace clang;
using namespace clang::ast_matchers;
static llvm::cl::OptionCategory OptionCategory("options");
class CMatcherCallback : public MatchFinder::MatchCallback
{
public:
virtual void run(const MatchFinder::MatchResult& result) override
{
if (const CXXMethodDecl* method = result.Nodes.getNodeAs<CXXMethodDecl>("id"))
{
method->dumpColor();
}
}
};
int main(int argc, const char** argv)
{
tooling::CommonOptionsParser optionsParser(argc, argv, OptionCategory);
tooling::ClangTool tool(optionsParser.getCompilations(),
optionsParser.getSourcePathList());
CMatcherCallback callback;
MatchFinder finder;
finder.addMatcher(cxxMethodDecl(
hasName("Method"),
hasParameter(0, parmVarDecl(hasType(asString("bool")))))
.bind("id"),
&callback);
int ret = tool.run(tooling::newFrontendActionFactory(&finder).get());
return ret;
}
It doesn't match this method:
class CTest
{
void Method(bool);
};
It does match when we change type from hasParameter(0, parmVarDecl(hasType(asString("bool")))))
to _Bool. So it seems matcher is in C instead of C++ mode?