[PATCH] D41581: [COFF] Do not parse args twice if no rsp files exists
Takuto Ikuta via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 26 21:07:24 PST 2017
takuto.ikuta updated this revision to Diff 128189.
takuto.ikuta added a comment.
Sure. Made parseDirectives removing unnecessary codes. Thanks.
https://reviews.llvm.org/D41581
Files:
lld/COFF/Driver.cpp
lld/COFF/Driver.h
lld/COFF/DriverUtils.cpp
Index: lld/COFF/DriverUtils.cpp
===================================================================
--- lld/COFF/DriverUtils.cpp
+++ lld/COFF/DriverUtils.cpp
@@ -750,6 +750,22 @@
return Args;
}
+// Parses a given list of options for .drective section.
+opt::InputArgList ArgParser::parseDirectives(ArrayRef<const char *> Argv) {
+ // Make InputArgList from string vectors.
+ unsigned MissingIndex;
+ unsigned MissingCount;
+ SmallVector<const char *, 256> Vec(Argv.data(), Argv.data() + Argv.size());
+
+ opt::InputArgList Args = Table.ParseArgs(Vec, 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/COFF/Driver.h
===================================================================
--- lld/COFF/Driver.h
+++ lld/COFF/Driver.h
@@ -54,10 +54,19 @@
// 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) {
+ return parseDirectives(tokenize(S));
+ }
+
private:
// Parses command line options.
llvm::opt::InputArgList parse(llvm::ArrayRef<const char *> Args);
+ // Parses command line options in .drectives section.
+ llvm::opt::InputArgList parseDirectives(llvm::ArrayRef<const char *> Args);
+
std::vector<const char *> tokenize(StringRef S);
COFFOptTable Table;
Index: lld/COFF/Driver.cpp
===================================================================
--- lld/COFF/Driver.cpp
+++ lld/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.128189.patch
Type: text/x-patch
Size: 2346 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171227/90bedf58/attachment.bin>
More information about the llvm-commits
mailing list