[PATCH] D54605: [lld][ELF] Use SmallDenseSet::count instead of lots of logical "or" operators and add test coverage for "-z" flags.
Kristina Brooks via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 15 15:46:01 PST 2018
kristina updated this revision to Diff 174296.
kristina added a comment.
Revised, newline at the end of the test file.
Repository:
rLLD LLVM Linker
https://reviews.llvm.org/D54605
Files:
ELF/Driver.cpp
test/ELF/invalid/zunknown-flag.test
Index: test/ELF/invalid/zunknown-flag.test
===================================================================
--- test/ELF/invalid/zunknown-flag.test
+++ test/ELF/invalid/zunknown-flag.test
@@ -0,0 +1,3 @@
+# RUN: not ld.lld -z obviouslyunknownflag 2>&1 | FileCheck --check-prefix=ERR %s
+# ERR: error: unknown -z value: obviouslyunknownflag
+
Index: ELF/Driver.cpp
===================================================================
--- ELF/Driver.cpp
+++ ELF/Driver.cpp
@@ -346,16 +346,20 @@
}
static bool isKnownZFlag(StringRef S) {
- return S == "combreloc" || S == "copyreloc" || S == "defs" ||
- S == "execstack" || S == "global" || S == "hazardplt" ||
- S == "initfirst" || S == "interpose" ||
- S == "keep-text-section-prefix" || S == "lazy" || S == "muldefs" ||
- S == "nocombreloc" || S == "nocopyreloc" || S == "nodelete" ||
- S == "nodlopen" || S == "noexecstack" ||
- S == "nokeep-text-section-prefix" || S == "norelro" || S == "notext" ||
- S == "now" || S == "origin" || S == "relro" || S == "retpolineplt" ||
- S == "rodynamic" || S == "text" || S == "wxneeded" ||
- S.startswith("max-page-size=") || S.startswith("stack-size=");
+ static llvm::SmallDenseSet<StringRef> KnownFlags {
+ "combreloc", "copyreloc", "defs",
+ "execstack", "global", "hazardplt",
+ "initfirst", "interpose", "keep-text-section-prefix",
+ "lazy", "muldefs", "nocombreloc",
+ "nocopyreloc", "nodelete", "nodlopen",
+ "noexecstack", "nokeep-text-section-prefix", "norelro",
+ "notext", "now", "origin",
+ "relro", "retpolineplt", "rodynamic",
+ "text", "wxneeded"
+ };
+
+ return KnownFlags.count(S) || S.startswith("max-page-size=") ||
+ S.startswith("stack-size=");
}
// Report an error for an unknown -z option.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D54605.174296.patch
Type: text/x-patch
Size: 1830 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181115/566f04b9/attachment.bin>
More information about the llvm-commits
mailing list