<div dir="ltr">On Wed, Aug 21, 2013 at 3:06 PM, Kim Gräsman <span dir="ltr"><<a href="mailto:kim.grasman@gmail.com" target="_blank">kim.grasman@gmail.com</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">John,<br>
<div class="im"><br>
On Wed, Aug 21, 2013 at 2:48 PM, Thompson, John<br>
<<a href="mailto:John_Thompson@playstation.sony.com">John_Thompson@playstation.sony.com</a>> wrote:<br>
><br>
> This would seem to have a prerequisite that ClangTooling have a OptTable<br>
> somewhere, but there doesn’t seem to be a connection.<br>
><br>
> Now let’s suppose I get past that hurdle, either by creating one myself and<br>
> somehow coercing it to parse the arguments given to ArgumentsAdjuster, how<br>
> do I use libOption to walk the arguments and figure out which command-line<br>
> argument is the source file?<br>
><br>
> Ideally, tooling should have a mechanism to tell me what the source file or<br>
> files are for each command line in the compilation database.  I had a much<br>
> simpler version, but it required I modify ArgumentsAdjuster to be given the<br>
> source file, which the caller had handy, but I couldn’t get that change<br>
> through.<br>
><br>
> Could someone associated with tooling lend a hand and tell me how to get the<br>
> input file from the command lines in the compilation database?<br>
<br>
</div>I can't help, but I'm struggling with the same thing right now.<br>
<br>
Our tool is originally designed to act as a replacement for clang in<br>
Make build systems, so it accepts the same command-line (plus some<br>
additional, escaped options)<br>
<br>
I've wanted to add compilation database support, but the way tooling<br>
is wired it seems I need to extract compilation db and source paths<br>
from the command-line and pass them to ClangTool::ClangTool. The<br>
compilation db is (sort of) handled by FixedCompilationDatabase, but<br>
it seems the source paths are assumed to be tool arguments, not Clang<br>
arguments.<br></blockquote><div><br></div><div>Use a clang plugin if you want to run as part of a build. The code that has your main logic is basically the same, and you can use ASTMatchers and other stuff from tooling in your clang plugin just fine.</div>
<div><br></div><div>See: <a href="http://clang.llvm.org/docs/Tooling.html">http://clang.llvm.org/docs/Tooling.html</a><br></div><div><br></div><div>Cheers,</div><div>/Manuel</div><div><br></div></div></div></div>