[PATCH] D100019: [lld-macho][nfc] Minor refactoring + clang-tidy fixes
Vy Nguyen via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 6 22:53:22 PDT 2021
oontvoo created this revision.
Herald added a reviewer: int3.
Herald added a project: lld-macho.
Herald added a reviewer: lld-macho.
oontvoo requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
- use "empty()" instead of "size()"
- refactor the re-export code so it doesn't create a new vector every time.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D100019
Files:
lld/MachO/Driver.cpp
Index: lld/MachO/Driver.cpp
===================================================================
--- lld/MachO/Driver.cpp
+++ lld/MachO/Driver.cpp
@@ -356,8 +356,9 @@
error("framework not found for -framework " + name);
}
-// Parses LC_LINKER_OPTION contents, which can add additional command line flags.
-void macho::parseLCLinkerOption(InputFile* f, unsigned argc, StringRef data) {
+// Parses LC_LINKER_OPTION contents, which can add additional command line
+// flags.
+void macho::parseLCLinkerOption(InputFile *f, unsigned argc, StringRef data) {
SmallVector<const char *, 4> argv;
size_t offset = 0;
for (unsigned i = 0; i < argc && offset < data.size(); ++i) {
@@ -848,7 +849,6 @@
stderrOS.enable_colors(stderrOS.has_colors());
// TODO: Set up error handler properly, e.g. the errorLimitExceededMsg
-
MachOOptTable parser;
InputArgList args = parser.parse(argsArr.slice(1));
@@ -1022,13 +1022,13 @@
if (args.hasArg(OPT_v)) {
message(getLLDVersion());
message(StringRef("Library search paths:") +
- (config->librarySearchPaths.size()
- ? "\n\t" + join(config->librarySearchPaths, "\n\t")
- : ""));
+ (config->librarySearchPaths.empty()
+ ? ""
+ : "\n\t" + join(config->librarySearchPaths, "\n\t")));
message(StringRef("Framework search paths:") +
- (config->frameworkSearchPaths.size()
- ? "\n\t" + join(config->frameworkSearchPaths, "\n\t")
- : ""));
+ (config->frameworkSearchPaths.empty()
+ ? ""
+ : "\n\t" + join(config->frameworkSearchPaths, "\n\t")));
}
config->progName = argsArr[0];
@@ -1052,17 +1052,23 @@
// Now that all dylibs have been loaded, search for those that should be
// re-exported.
- for (const Arg *arg : args.filtered(OPT_sub_library, OPT_sub_umbrella)) {
- config->hasReexports = true;
- StringRef searchName = arg->getValue();
- std::vector<StringRef> extensions;
- if (arg->getOption().getID() == OPT_sub_library)
- extensions = {".dylib", ".tbd"};
- else
- extensions = {".tbd"};
- if (!markReexport(searchName, extensions))
- error(arg->getSpelling() + " " + searchName +
- " does not match a supplied dylib");
+ {
+ auto reexportHandler = [](const Arg *arg,
+ const std::vector<StringRef> &extensions) {
+ config->hasReexports = true;
+ StringRef searchName = arg->getValue();
+ if (!markReexport(searchName, extensions))
+ error(arg->getSpelling() + " " + searchName +
+ " does not match a supplied dylib");
+ };
+ std::vector<StringRef> extensions = {".tbd"};
+ for (const Arg *arg : args.filtered(OPT_sub_umbrella)) {
+ reexportHandler(arg, extensions);
+ }
+ extensions.push_back(".dylib");
+ for (const Arg *arg : args.filtered(OPT_sub_library)) {
+ reexportHandler(arg, extensions);
+ }
}
// Parse LTO options.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D100019.335728.patch
Type: text/x-patch
Size: 3105 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210407/0c6d0c16/attachment.bin>
More information about the llvm-commits
mailing list