vendredi 21 juin 2019

Best way to reset clang::ast_matchers::MatchFinder?

I used some matchers to extract information from the AST

clang::ast_matchers::MatchFinder finder;
finder.addMatcher(customMatcher, &matchHandler);
finder.matchAST(ast->getASTContext());

Now I want to use the extracted information to extract more info from the AST. So the hard requirement is that the matchers of the first phase are called before any matchers of the second phase. If I add them to the finder all at once, some of the matchers of the second phase are called before the matchers of the first phase. This other Stack Overflow solution thus doesn't work: Is there any way to "restart matching" with libclang matchers after already having matched something?

I tried doing finder = clang::ast_matchers::MatchFinder();, but that doesn't work since it's a deleted method.

The kind of ugly way would be to declare a new finder for every phase:

clang::ast_matchers::MatchFinder finder2;
// phase 2 stuff
clang::ast_matchers::MatchFinder finder3;
// phase 3 stuff
// ...

Is there a better way?

Aucun commentaire:

Enregistrer un commentaire