diff --git a/lld/MachO/Driver.cpp b/lld/MachO/Driver.cpp --- a/lld/MachO/Driver.cpp +++ b/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 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 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 &extensions) { + config->hasReexports = true; + StringRef searchName = arg->getValue(); + if (!markReexport(searchName, extensions)) + error(arg->getSpelling() + " " + searchName + + " does not match a supplied dylib"); + }; + std::vector 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.