With this, clang-cl /source-charset:utf-16 test.cc now prints invalid value 'utf-16' in '/source-charset:utf-16' instead of invalid value 'utf-16' in '-finput-charset=utf-16' before, and several other clang-cl flags produce much less confusing output as well.
Fixes PR29106.
Since an arg and its alias can have different arg types (joined vs not) and different values (because of AliasArgs<>), I chose to give the Alias its own Arg object. For convenience, I just store the alias directly in the unaliased arg – there aren't many arg objects at runtime, so that seems ok.
Finally, I changed Arg::getAsString() to use the alias's representation if it's present – that function was already documented as being the suitable function for diagnostics, and most callers already used it for diagnostics.
Implementation-wise, Arg::accept() previously used to parse things as the unaliased option. The core of that switch is now extracted into a new function acceptInternal() which parses as the _aliased_ option, and the previously-intermingled unaliasing is now done as an explicit step afterwards.
(This also changes one place in lld that didn't use getAsString() for diagnostics, so that that one place now also prints the flag as the user wrote it, not as it looks after it went through unaliasing.)
I'm not sure this is really true:
Command lines can end up being quite long. Consider:
However, if someone comes along and cares about this, they can try shrinking this SmallVector instead, and using something similar to TinyPtrVector.