[lld] ffc6582 - [lld-macho][nfc] Minor refactoring + clang-tidy fixes
Vy Nguyen via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 7 10:58:34 PDT 2021
Author: Vy Nguyen
Date: 2021-04-07T13:55:52-04:00
New Revision: ffc65824f0ee20e1f8e884811062b92bd6707b11
URL: https://github.com/llvm/llvm-project/commit/ffc65824f0ee20e1f8e884811062b92bd6707b11
DIFF: https://github.com/llvm/llvm-project/commit/ffc65824f0ee20e1f8e884811062b92bd6707b11.diff
LOG: [lld-macho][nfc] Minor refactoring + clang-tidy fixes
- use "empty()" instead of "size()"
- refactor the re-export code so it doesn't create a new vector every time.
Differential Revision: https://reviews.llvm.org/D100019
Added:
Modified:
lld/MachO/Driver.cpp
Removed:
################################################################################
diff --git a/lld/MachO/Driver.cpp b/lld/MachO/Driver.cpp
index 851a1b649348a..2f671649a7494 100644
--- a/lld/MachO/Driver.cpp
+++ b/lld/MachO/Driver.cpp
@@ -1022,13 +1022,13 @@ bool macho::link(ArrayRef<const char *> argsArr, bool canExitEarly,
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,22 @@ bool macho::link(ArrayRef<const char *> argsArr, bool canExitEarly,
// 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.
More information about the llvm-commits
mailing list