summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRui Ueyama <ruiu@google.com>2013-07-31 22:13:15 +0000
committerRui Ueyama <ruiu@google.com>2013-07-31 22:13:15 +0000
commit3adc09e9fcb3ec7f5415998ca8173dc8285783a5 (patch)
tree1547bea0e952d7bddd1170880ad34094276bbddb
parent34237a5fd3c7481ad4fd0648d0f07a448112362d (diff)
downloadbcm5719-llvm-3adc09e9fcb3ec7f5415998ca8173dc8285783a5.tar.gz
bcm5719-llvm-3adc09e9fcb3ec7f5415998ca8173dc8285783a5.zip
Revert "[PECOFF][Driver] Remove quotes from command line arguments."
This reverts commit r187390 because we should not handle argv's quotes ourselves. In Windows, unlike Unix, quotes are not processed by the shell. Instead the C startup routine parses it as described in http://msdn.microsoft.com/en-us/library/a1y7w461.aspx and pass the results to main(). So, at the time when the control reaches main(), quotes that should be removed has already been removed. We still need to handle quotes in the response file and in .drectve section ourselves. That will be addressed in different patches. llvm-svn: 187534
-rw-r--r--lld/lib/Driver/WinLinkDriver.cpp33
-rw-r--r--lld/unittests/DriverTests/WinLinkDriverTest.cpp12
2 files changed, 13 insertions, 32 deletions
diff --git a/lld/lib/Driver/WinLinkDriver.cpp b/lld/lib/Driver/WinLinkDriver.cpp
index 768a36d3e60..c4516b35d58 100644
--- a/lld/lib/Driver/WinLinkDriver.cpp
+++ b/lld/lib/Driver/WinLinkDriver.cpp
@@ -216,14 +216,6 @@ std::vector<StringRef> splitPathList(StringRef str) {
return std::move(ret);
}
-// Removes surrounding single or double quotes from the string. If it's not
-// quoted, return the argument as is.
-StringRef unquote(StringRef str) {
- bool isQuoted = (str.startswith("\"") && str.endswith("\"")) ||
- (str.startswith("'") && str.endswith("'"));
- return isQuoted ? str.substr(1, str.size() - 2) : str;
-}
-
// Handle /failifmatch option.
bool handleFailIfMismatchOption(StringRef option,
std::map<StringRef, StringRef> &mustMatch,
@@ -353,33 +345,33 @@ bool WinLinkDriver::parse(int argc, const char *argv[],
// handle /base
if (llvm::opt::Arg *arg = parsedArgs->getLastArg(OPT_base))
- if (!parseBaseOption(info, unquote(arg->getValue()), diagnostics))
+ if (!parseBaseOption(info, arg->getValue(), diagnostics))
return true;
// handle /stack
if (llvm::opt::Arg *arg = parsedArgs->getLastArg(OPT_stack))
- if (!parseStackOption(info, unquote(arg->getValue()), diagnostics))
+ if (!parseStackOption(info, arg->getValue(), diagnostics))
return true;
// handle /heap
if (llvm::opt::Arg *arg = parsedArgs->getLastArg(OPT_heap))
- if (!parseHeapOption(info, unquote(arg->getValue()), diagnostics))
+ if (!parseHeapOption(info, arg->getValue(), diagnostics))
return true;
// handle /subsystem
if (llvm::opt::Arg *arg = parsedArgs->getLastArg(OPT_subsystem))
- if (!parseSubsystemOption(info, unquote(arg->getValue()), diagnostics))
+ if (!parseSubsystemOption(info, arg->getValue(), diagnostics))
return true;
// handle /entry
if (llvm::opt::Arg *arg = parsedArgs->getLastArg(OPT_entry))
- info.setEntrySymbolName(unquote(arg->getValue()));
+ info.setEntrySymbolName(arg->getValue());
// handle /libpath
for (llvm::opt::arg_iterator it = parsedArgs->filtered_begin(OPT_libpath),
ie = parsedArgs->filtered_end();
it != ie; ++it) {
- info.appendInputSearchPath(unquote((*it)->getValue()));
+ info.appendInputSearchPath((*it)->getValue());
}
// handle /force
@@ -406,19 +398,19 @@ bool WinLinkDriver::parse(int argc, const char *argv[],
for (llvm::opt::arg_iterator it = parsedArgs->filtered_begin(OPT_incl),
ie = parsedArgs->filtered_end();
it != ie; ++it) {
- info.addInitialUndefinedSymbol(unquote((*it)->getValue()));
+ info.addInitialUndefinedSymbol((*it)->getValue());
}
// handle /out
if (llvm::opt::Arg *outpath = parsedArgs->getLastArg(OPT_out))
- info.setOutputPath(unquote(outpath->getValue()));
+ info.setOutputPath(outpath->getValue());
// handle /defaultlib
std::vector<StringRef> defaultLibs;
for (llvm::opt::arg_iterator it = parsedArgs->filtered_begin(OPT_defaultlib),
ie = parsedArgs->filtered_end();
it != ie; ++it) {
- defaultLibs.push_back(unquote((*it)->getValue()));
+ defaultLibs.push_back((*it)->getValue());
}
// Handle /failifmismatch. /failifmismatch is the hidden linker option behind
@@ -434,8 +426,7 @@ bool WinLinkDriver::parse(int argc, const char *argv[],
it = parsedArgs->filtered_begin(OPT_failifmismatch),
ie = parsedArgs->filtered_end();
it != ie; ++it) {
- if (!handleFailIfMismatchOption(unquote((*it)->getValue()),
- mustMatch, diagnostics))
+ if (!handleFailIfMismatchOption((*it)->getValue(), mustMatch, diagnostics))
return true;
}
@@ -444,13 +435,13 @@ bool WinLinkDriver::parse(int argc, const char *argv[],
for (llvm::opt::arg_iterator it = parsedArgs->filtered_begin(OPT_INPUT),
ie = parsedArgs->filtered_end();
it != ie; ++it) {
- inputPaths.push_back(unquote((*it)->getValue()));
+ inputPaths.push_back((*it)->getValue());
}
// Arguments after "--" are also input files
if (doubleDashPosition > 0)
for (int i = doubleDashPosition + 1; i < argc; ++i)
- inputPaths.push_back(unquote(argv[i]));
+ inputPaths.push_back(argv[i]);
// Add input files specified via the command line.
for (const StringRef path : inputPaths)
diff --git a/lld/unittests/DriverTests/WinLinkDriverTest.cpp b/lld/unittests/DriverTests/WinLinkDriverTest.cpp
index f4fd29df084..d32f22259b4 100644
--- a/lld/unittests/DriverTests/WinLinkDriverTest.cpp
+++ b/lld/unittests/DriverTests/WinLinkDriverTest.cpp
@@ -66,16 +66,6 @@ TEST_F(WinLinkParserTest, UnixStyleOption) {
EXPECT_EQ("a.obj", inputFile(0));
}
-TEST_F(WinLinkParserTest, Quote) {
- EXPECT_FALSE(parse("link.exe", "/subsystem:\"console\"", "-out:'a.exe'",
- "/defaultlib:'user32.lib'", "'a.obj'", nullptr));
- EXPECT_EQ(llvm::COFF::IMAGE_SUBSYSTEM_WINDOWS_CUI, _info.getSubsystem());
- EXPECT_EQ("a.exe", _info.outputPath());
- EXPECT_EQ(2, inputFileCount());
- EXPECT_EQ("a.obj", inputFile(0));
- EXPECT_EQ("user32.lib", inputFile(1));
-}
-
TEST_F(WinLinkParserTest, Mllvm) {
EXPECT_FALSE(parse("link.exe", "-mllvm", "-debug", "a.obj", nullptr));
const std::vector<const char *> &options = _info.llvmOptions();
@@ -215,7 +205,7 @@ TEST_F(WinLinkParserTest, NoInputFiles) {
TEST_F(WinLinkParserTest, FailIfMismatch_Match) {
EXPECT_FALSE(parse("link.exe", "/failifmismatch:foo=bar",
- "/failifmismatch:\"foo=bar\"", "/failifmismatch:abc=def",
+ "/failifmismatch:foo=bar", "/failifmismatch:abc=def",
"a.out", nullptr));
}
OpenPOWER on IntegriCloud