Is there a way I can pass constructor arguments to classes inheriting from clang::ASTFrontendAction in programs based on libtooling? All examples I have found online look something like this:
int main() {
ClangTool Tool(...);
return Tool.run(newFrontendActionFactory<SomeFrontendAction>().get());
}
But what if SomeFrontendAction needs to be aware of, i.e. options passed in by the tools user? How can I pass those on to the constructor of SomeFrontendAction?
I found this answer while looking for an answer to this question. You should create your own version of
newFrontEndActionFactory. The original code fornewFrontEndActionFactoryis:I replaced
TwithSomeFrontendAction, added a constructor to classSimpleFrontendActionFactoryand then pass the options toSomeFrontendAction. The resulting function looks something like this: