Re-using Driver's arg parsing

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 –

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?