[cfe-dev] Re-using Driver's arg parsing

Edwin Vane revane at gmail.com
Fri Oct 25 09:31:40 PDT 2013

Manuel suggested I solicit your input. I'm looking to re-use
driver::Driver's arg parsing in FixedCompilationDatabase to remove FCD's
assumption that the args it gets from the command line don't contain the
compiler or name of the file to compile. For example, clang tools using FCD
are currently invoked like this:

tool <tool args> -- <compile args>

where compile args could look something like this:

-c -std=c++11 -g ...

However, it'd be very useful to handle args in this form:

clang++ -c myfile.cpp -std=c++11 -g ...

So the goal was to use Driver's arg parsing to determine if the compiler
and/or filename are present and correct the stored command-line. In
particular, Driver::BuildCompilation() looks promising but it seems to do
some work we don't need/want (like the call to HandleImmediateArgs()). If
this is indeed the right path, it looks like BuildCompilation() needs to be
refactored to re-use parts of it.

So my questions:
1) Does this sound like the correct path?
2) If so, which parts of BuildCompilation() are necessary and which are not
for detecting presence of compiler/filename?

Edwin V
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20131025/c5d421c8/attachment.html>

More information about the cfe-dev mailing list