Hi,
I need your help again. Look, in my tool I was trying to use the syntax that’s shown here:
http://clang.llvm.org/docs/LibASTMatchersTutorial.html
Namely I’m referring to this part:
int main(int argc, const char **argv) {
CommonOptionsParser OptionsParser(argc, argv);
ClangTool Tool(OptionsParser.getCompilations(),
OptionsParser.getSourcePathList());
LoopPrinter Printer;
MatchFinder Finder;
Finder.addMatcher(LoopMatcher, &Printer);
return Tool.run(newFrontendActionFactory(&Finder));
}
However, now I want to create a object “Printer” with different features depending on the arguments provided in command line. So I was thinking on implement a factory method pattern to create a different LoopPrinter object:
class OptionsFactory {
public:
LoopPrinter getOption() {
if(…)
return LoopPrinter(attribute1, attribute2);
else
return LoopPrinter(attribute1);
}
};
I was searching for a better solution and there are some things that I can’t completely understand.
-
Why are there two classes MatchFinder:
http://clang.llvm.org/doxygen/classclang_1_1tooling_1_1MatchFinder.html
http://clang.llvm.org/doxygen/classclang_1_1ast__matchers_1_1MatchFinder.html -
What the method in ast_matchers:MatchFinder
clang::ASTConsumer *
|
newASTConsumer ()
|
- | - |
is used for? I see we can ‘associate’ an ASTConsumer to the Frontend as in:
http://clang.llvm.org/docs/RAVFrontendAction.html
but, is this possible using Matchers? Would it have any sense to create an ASTConsumer in my class OptionsFactory?
I have improved a lot since you last helped me, but clang is too big!
By the way, do you know how to use CommandLine? I posted a new thread
http://lists.cs.uiuc.edu/pipermail/cfe-dev/2013-May/029473.html
If you know how to solve that problem, please, let me know.
Thanks in advance,
Pedro.
El dia 27 abr 2013 18:39, Manuel Klimek klimek@google.com escribió: