[PATCH] D41581: [COFF] Do not parse args twice if no rsp files exists

Rui Ueyama via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 26 22:09:21 PST 2017


This revision was automatically updated to reflect the committed changes.
Closed by commit rL321470: [COFF] Do not parse args twice if no rsp files exists (authored by ruiu, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D41581?vs=128193&id=128195#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D41581

Files:
  lld/trunk/COFF/Driver.cpp
  lld/trunk/COFF/Driver.h
  lld/trunk/COFF/DriverUtils.cpp


Index: lld/trunk/COFF/DriverUtils.cpp
===================================================================
--- lld/trunk/COFF/DriverUtils.cpp
+++ lld/trunk/COFF/DriverUtils.cpp
@@ -750,6 +750,22 @@
   return Args;
 }
 
+// Tokenizes and parses a given string as command line in .drective section.
+opt::InputArgList ArgParser::parseDirectives(StringRef S) {
+  // Make InputArgList from string vectors.
+  unsigned MissingIndex;
+  unsigned MissingCount;
+
+  opt::InputArgList Args =
+      Table.ParseArgs(tokenize(S), MissingIndex, MissingCount);
+
+  if (MissingCount)
+    fatal(Twine(Args.getArgString(MissingIndex)) + ": missing argument");
+  for (auto *Arg : Args.filtered(OPT_UNKNOWN))
+    warn("ignoring unknown argument: " + Arg->getSpelling());
+  return Args;
+}
+
 // link.exe has an interesting feature. If LINK or _LINK_ environment
 // variables exist, their contents are handled as command line strings.
 // So you can pass extra arguments using them.
Index: lld/trunk/COFF/Driver.h
===================================================================
--- lld/trunk/COFF/Driver.h
+++ lld/trunk/COFF/Driver.h
@@ -54,6 +54,10 @@
   // Tokenizes a given string and then parses as command line options.
   llvm::opt::InputArgList parse(StringRef S) { return parse(tokenize(S)); }
 
+  // Tokenizes a given string and then parses as command line options in
+  // .drectve section.
+  llvm::opt::InputArgList parseDirectives(StringRef S);
+
 private:
   // Parses command line options.
   llvm::opt::InputArgList parse(llvm::ArrayRef<const char *> Args);
Index: lld/trunk/COFF/Driver.cpp
===================================================================
--- lld/trunk/COFF/Driver.cpp
+++ lld/trunk/COFF/Driver.cpp
@@ -227,7 +227,7 @@
 void LinkerDriver::parseDirectives(StringRef S) {
   ArgParser Parser;
   // .drectve is always tokenized using Windows shell rules.
-  opt::InputArgList Args = Parser.parse(S);
+  opt::InputArgList Args = Parser.parseDirectives(S);
 
   for (auto *Arg : Args) {
     switch (Arg->getOption().getUnaliasedOption().getID()) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D41581.128195.patch
Type: text/x-patch
Size: 2074 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171227/0cbd2a23/attachment.bin>


More information about the llvm-commits mailing list