Fix Windows command line bug when last token in response file is ""
authorAdrian McCarthy <amccarth@google.com>
Wed, 27 May 2020 20:53:47 +0000 (13:53 -0700)
committerAdrian McCarthy <amccarth@google.com>
Wed, 27 May 2020 21:49:30 +0000 (14:49 -0700)
commit2d068e534f1671459e1b135852c1b3c10502e929
tree17b5c0215ff0a9d37a4021559b6e862e6ef1c9e4
parent0a072b8a0da7399eeeb670330b7baeddf1bb407a
Fix Windows command line bug when last token in response file is ""

Patch by Neil Dhar <dhar@alumni.duke.edu>

Current state machine for parsing tokens from response files in Windows
does not correctly handle the case where the last token is "". The current
implementation handles the last token by only adding it if it is not empty,
however this does not cover the case where the last token is meant to be
the empty string. We can cover this case by checking whether the state
machine was last in the UNQUOTED state, which indicates that the last
character of the input was a non-whitespace character.

Differential Revision: https://reviews.llvm.org/D78346
llvm/lib/Support/CommandLine.cpp
llvm/unittests/Support/CommandLineTest.cpp