CompilerInvocation::createFromArgs Problem

   In order to include C++ headers without platform-specific code, I copied
the code from "createInvocationFromCommandLine" , renamed it to
"CreateCXXInvocation" and added the following line:

TheDriver.CCCIsCXX = true;

   after the driver object is created. Now the CompilerInvocation object
created by "createFromArgs" contains all the args for C++ paths. The problem
is that all these arguments are placed AFTER the target file (test.cpp).
Therefore, they don't work. If the target file is put at the end, the
command would work fine. Why does "createFromArgs" put CXX paths after the
target file? How can this be remedied?