diff --git a/lld/MachO/Driver.cpp b/lld/MachO/Driver.cpp --- a/lld/MachO/Driver.cpp +++ b/lld/MachO/Driver.cpp @@ -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,22 @@ // 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.