[PATCH] D53457: clang-cl: Add "/clang:" pass-through arg support.

Hans Wennborg via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Oct 29 03:11:31 PDT 2018


hans added a comment.

In https://reviews.llvm.org/D53457#1277950, @neerajksingh wrote:

> In https://reviews.llvm.org/D53457#1277315, @hans wrote:
>
> >   One note about flag ordering: the /clang: flags are concatenated to the end of
> >   the argument list, so in cases where the last flag wins, the /clang: flags
> >   will be chosen regardless of their order relative to other flags on the driver
> >   command line.
> >
> >
> > This seems a little unfortunate. I wonder if it would be possible to not have this restriction, i.e. to process these in-line with the rest of the flags?
> >
> > One way to achieve this would be to change Driver::ParseArgStrings() to handle the "/clang:" arguments. After doing the regular option parsing, it would look for "/clang:" options and substitute them for the underlying option. This has the downside of adding some option-specific logic to ParseArgStrings, but on the other hand it's less intrusive than passing around the IsCLMode bool. Do you think something like this could work?
>
>
> One difficulty occurs with options that have separated values, like the `/clang:-MF /clang:<filename>` case.  In this case, we need to take two /clang: arguments and process them next to each other in order to form a single coherent argument/value pair. Another option is to allow the user to specify the option like `/clang:"-MF <filename>"` and then require that the user specify any flags that need a value in a single /clang: argument.  This would require some code to split the value string on spaces before passing it on to clang argument parsing.
>
> Do you have any preference or better suggestion for the option-with-value case?


The `-Xclang` option has the same issue, and I think `/clang:` should work similarly, i.e. `/clang:-MF /clang:<filename>`. It's not pretty, but at least it's consistent. Yes, that means processing consecutive `/Xclang:` options together, but hopefully that's doable.


https://reviews.llvm.org/D53457





More information about the cfe-commits mailing list