<div dir="ltr">You should be able to use the SourceFileCallbacks for this purpose.<br></div><br><div class="gmail_quote">On Sun Jan 25 2015 at 9:16:17 PM Gábor Márton <<a href="mailto:martongabesz@gmail.com">martongabesz@gmail.com</a>> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
I am a newby here ... and I have a quesiton, hoping you can help :)<br>
<br>
I am writing a tool based on the ast matchers tutorial<br>
(<a href="http://clang.llvm.org/docs/LibASTMatchersTutorial.html" target="_blank">http://clang.llvm.org/docs/<u></u>LibASTMatchersTutorial.html</a>).<br>
<br>
I would like to have a callback (or similar) to print the filename of<br>
each and every translation unit which have been processed. I need this<br>
because I'd like to track the progress of my tool.<br>
<br>
For now I've been trying with this:<br>
struct TuFileHandler : public MatchFinder::MatchCallback {<br>
virtual void run(const MatchFinder::MatchResult &Result) {<br>
if (const Decl *D = Result.Nodes.getNodeAs<Decl>("<u></u>decl")) {<br>
if (const TranslationUnitDecl *TUD = dyn_cast<TranslationUnitDecl>(<u></u>D)) {<br>
auto loc = TUD->getLocation();<br>
llvm::outs() << loc.printToString(*Result.<u></u>SourceManager) << "\n";<br>
llvm::outs().flush();<br>
}<br>
}<br>
}<br>
};<br>
...<br>
TuFileHandler FileHandler;<br>
auto const TuMatcher = decl().bind("decl");<br>
Finder.addMatcher(TuMatcher, &FileHandler);<br>
But the TranslationUnitDecl has invalid source location. I might be<br>
trying with some cumbersome solutions to match different Decls which<br>
has valid source locations, but that would be overkill. I am pretty<br>
sure there might be an easier way...<br>
Is there a way to somehow get this info from the CangTool class?<br>
<br>
<br>
Many Thanks,<br>
Gabor<br>
______________________________<u></u>_________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@cs.uiuc.edu" target="_blank">cfe-dev@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" target="_blank">http://lists.cs.uiuc.edu/<u></u>mailman/listinfo/cfe-dev</a><br>
</blockquote></div>