This patch contains the LLVM side of the fix of PR17239 (I will submit an additional patch for the clang side), a bug that happens because the /link (clang-cl.exe argument) is marked as "consume all remaining arguments". However, when inside a response file, /link should only consume all remaining arguments inside the response file where it is located, not the entire command line after expansion.
My patch will change the semantics of the RemainingArgsClass kind to always consume only until the end of the response file when the option originally came from a response file. There are only two options in this class: dash dash (--) and /link.
To do this, I had to change how response file expansion works in the CommandLine[.cpp|h] component. Now, the expansion returns not only the expanded argv vector, but also a vector with pairs of numbers that marks the first and last arguments that come from response files. With this information, I am able to fix this bug.
The problem is how to encapsulate this into a clean interface. To solve this, I created the ExpandedArgs class, which manages an argv vector after response files expansion. I was reluctant to implement a new class because Clang Driver already has ArgLists and InputInfos, that is, two other layers for input argument processing. However, ExpandedArgs was necessary as a first argv wrapper to manage (and keep correct) the response file indexes while driver.cpp (in clang) fiddles with the argument vector by adding/changing elements.