<div dir="ltr"><div>Hey!</div><div><br></div><div>Check out this class: <a href="https://clang.llvm.org/doxygen/AllTUsExecution_8h_source.html">https://clang.llvm.org/doxygen/AllTUsExecution_8h_source.html</a>, 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!</div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">samins KAlex via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a>> ezt írta (időpont: 2020. júl. 26., V, 10:23):<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div>Hello!</div><div>How can we run ClangTool based AST action over multiply source files.</div><div> </div><div>For example command line tool:</div><div><div>./loop-convert --extra-arg-before=-I'/media/sf_share/llvm_9/llvm9-build/lib/clang/9.0.0/include' \</div><div>-p '/home/fvmu/scnd_disk/my_projects/for_code_data_divider/busybox-1.32.0' \</div><div>'/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'</div><div> </div><div> </div><div>and code (taken from <a href="https://clang.llvm.org/docs/LibASTMatchersTutorial.html" target="_blank">https://clang.llvm.org/docs/LibASTMatchersTutorial.html</a>)</div><div> <div>CommonOptionsParser OptionsParser(argc, argv, MyToolCategory);</div><div>ClangTool Tool(OptionsParser.getCompilations(), OptionsParser.getSourcePathList());</div><div>LoopPrinter Printer;</div><div>MatchFinder Finder;</div><div>Finder.addMatcher(LoopMatcher, &Printer);</div><div>return Tool.run(newFrontendActionFactory(&Finder).get());</div><div> </div><div> </div><div> </div><div>I can iterate over the compilation database entries inside my program or write python wrapper. But I beleive there is an easier way.</div></div><div>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?</div><div><div> </div></div></div>_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a><br>
</blockquote></div>