[cfe-dev] How to run FrontendAction over multiply TU
Whisperity via cfe-dev
cfe-dev at lists.llvm.org
Sun Jul 26 05:11:18 PDT 2020
Hey!
Check out this class:
https://clang.llvm.org/doxygen/AllTUsExecution_8h_source.html, and its
usages. Might be the one you're looking for. It takes care of going over
every TU. And it's also doing it multithreaded!
samins KAlex via cfe-dev <cfe-dev at lists.llvm.org> ezt írta (időpont: 2020.
júl. 26., V, 10:23):
> Hello!
> How can we run ClangTool based AST action over multiply source files.
>
> For example command line tool:
> ./loop-convert
> --extra-arg-before=-I'/media/sf_share/llvm_9/llvm9-build/lib/clang/9.0.0/include'
> \
> -p '/home/fvmu/scnd_disk/my_projects/for_code_data_divider/busybox-1.32.0'
> \
> '/home/fvmu/scnd_disk/my_projects/for_code_data_divider/busybox-1.32.0/libbb/rtc.c'
> '/home/fvmu/scnd_disk/my_projects/for_code_data_divider/busybox-1.32.0/libbb/ubi.c'
> '/home/fvmu/scnd_disk/my_projects/for_code_data_divider/busybox-1.32.0/libbb/dump.c'
> '/home/fvmu/scnd_disk/my_projects/for_code_data_divider/busybox-1.32.0/libbb/loop.c'
> '/home/fvmu/scnd_disk/my_projects/for_code_data_divider/busybox-1.32.0/libbb/mtab.c'
> '/home/fvmu/scnd_disk/my_projects/for_code_data_divider/busybox-1.32.0/libbb/read.c'
>
>
> and code (taken from
> https://clang.llvm.org/docs/LibASTMatchersTutorial.html)
>
> CommonOptionsParser OptionsParser(argc, argv, MyToolCategory);
> ClangTool Tool(OptionsParser.getCompilations(),
> OptionsParser.getSourcePathList());
> LoopPrinter Printer;
> MatchFinder Finder;
> Finder.addMatcher(LoopMatcher, &Printer);
> return Tool.run(newFrontendActionFactory(&Finder).get());
>
>
>
> I can iterate over the compilation database entries inside my program or
> write python wrapper. But I beleive there is an easier way.
> newFrontendActionFactory(&Finder).get() works only for last source file in
> list (libbb/read.c). So how can I match AST nodes over multiply TU in one
> clang tool?
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20200726/4cd77399/attachment.html>
More information about the cfe-dev
mailing list