[PATCH] Fix PR17239 by changing the semantics of the RemainingArgsClass Option kind

Rafael Auler rafaelauler at gmail.com
Wed Aug 13 22:17:53 PDT 2014


Hi rafael,

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.

http://reviews.llvm.org/D4899

Files:
  include/llvm/Option/OptTable.h
  include/llvm/Option/Option.h
  include/llvm/Support/CommandLine.h
  lib/Option/OptTable.cpp
  lib/Option/Option.cpp
  lib/Support/CommandLine.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D4899.12486.patch
Type: text/x-patch
Size: 22416 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140814/22911393/attachment.bin>


More information about the llvm-commits mailing list