[clang-cl] Ignore the /o option when /P is specified. This matches the cl.exe behavior (tested with 18.00.31101). In order to specify an output file for /P, use the /Fi option instead.
I ran into this when my change to add Windows version information to LLVM executables caused a failure on the clang selfhost builds. This is because the CMake tool cmcldeps.exe which it's using to figure out dependencies for the resource script file is invoking the host C++ compiler with '/P /out:<location>' but expecting <location> to be ignored. With MSVC's cl.exe (I tested VS2012 and VS2013) this is the case, but with clang-cl.exe we're trying to output the file to <location>. This patch changes clang-cl to match the cl behaviour in ignoring /o which allows cmcldeps.exe tool to function correctly with clang-cl. The test ensures that the '/Fi' option still works as expected to allow the location of the /P output to be specified if required.
Note that I mentioned that cmcldeps.exe is specifying the location with '/out:<location>', rather than '/o' '<location>'. This means that in this case it's actually being parsed as '/o' 'ut:<location>' but as it's being ignored anyway it doesn't cause us any problems. I'm not sure whether we'd also want to add '/out:' as an alias for '/o' too. As both '/o' and '/out:' now give a warning from cl.exe:
"Command line warning D9035 : option 'o' has been deprecated and will be removed in a future release"
I'm inclined to think that we shouldn't add '/out:' support as I'm not aware of any particular use-cases where it's required but I can do that too in a separate patch if the consensus is that we should.
Thanks,
-Greg
We probably don't need all four test cases for /P with /o anymore.
I think we should also have a note explaining the expected behaviour: that /o doesn't affect /P.