Skip to content

Commit

Permalink
[lld-macho][NFC] drop opt:: when already using llvm::opt
Browse files Browse the repository at this point in the history
Top-level `using llvm::opt` has been present in `lld/MachO/Driver*.cpp` for some time, so remove lingering `opt::` prefixes.

Differential Revision: https://reviews.llvm.org/D98314
  • Loading branch information
gkmhub committed Mar 10, 2021
1 parent fdc0c21 commit 714ec86
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 31 deletions.
47 changes: 23 additions & 24 deletions lld/MachO/Driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ using namespace lld::macho;

Configuration *lld::macho::config;

static HeaderFileType getOutputType(const opt::InputArgList &args) {
static HeaderFileType getOutputType(const InputArgList &args) {
// TODO: -r, -dylinker, -preload...
opt::Arg *outputArg = args.getLastArg(OPT_bundle, OPT_dylib, OPT_execute);
Arg *outputArg = args.getLastArg(OPT_bundle, OPT_dylib, OPT_execute);
if (outputArg == nullptr)
return MH_EXECUTE;

Expand Down Expand Up @@ -137,7 +137,7 @@ static bool warnIfNotDirectory(StringRef option, StringRef path) {
}

static std::vector<StringRef>
getSearchPaths(unsigned optionCode, opt::InputArgList &args,
getSearchPaths(unsigned optionCode, InputArgList &args,
const std::vector<StringRef> &roots,
const SmallVector<StringRef, 2> &systemPaths) {
std::vector<StringRef> paths;
Expand Down Expand Up @@ -175,7 +175,7 @@ getSearchPaths(unsigned optionCode, opt::InputArgList &args,
return paths;
}

static std::vector<StringRef> getSystemLibraryRoots(opt::InputArgList &args) {
static std::vector<StringRef> getSystemLibraryRoots(InputArgList &args) {
std::vector<StringRef> roots;
for (const Arg *arg : args.filtered(OPT_syslibroot))
roots.push_back(arg->getValue());
Expand All @@ -190,13 +190,12 @@ static std::vector<StringRef> getSystemLibraryRoots(opt::InputArgList &args) {
}

static std::vector<StringRef>
getLibrarySearchPaths(opt::InputArgList &args,
const std::vector<StringRef> &roots) {
getLibrarySearchPaths(InputArgList &args, const std::vector<StringRef> &roots) {
return getSearchPaths(OPT_L, args, roots, {"/usr/lib", "/usr/local/lib"});
}

static std::vector<StringRef>
getFrameworkSearchPaths(opt::InputArgList &args,
getFrameworkSearchPaths(InputArgList &args,
const std::vector<StringRef> &roots) {
return getSearchPaths(OPT_F, args, roots,
{"/Library/Frameworks", "/System/Library/Frameworks"});
Expand Down Expand Up @@ -365,7 +364,7 @@ void macho::parseLCLinkerOption(InputFile* f, unsigned argc, StringRef data) {

MachOOptTable table;
unsigned missingIndex, missingCount;
opt::InputArgList args = table.ParseArgs(argv, missingIndex, missingCount);
InputArgList args = table.ParseArgs(argv, missingIndex, missingCount);
if (missingCount)
fatal(Twine(args.getArgString(missingIndex)) + ": missing argument");
for (const Arg *arg : args.filtered(OPT_UNKNOWN))
Expand Down Expand Up @@ -544,8 +543,8 @@ static std::string lowerDash(StringRef s) {
}

// Has the side-effect of setting Config::platformInfo.
static PlatformKind parsePlatformVersion(const opt::ArgList &args) {
const opt::Arg *arg = args.getLastArg(OPT_platform_version);
static PlatformKind parsePlatformVersion(const ArgList &args) {
const Arg *arg = args.getLastArg(OPT_platform_version);
if (!arg) {
error("must specify -platform_version");
return PlatformKind::unknown;
Expand Down Expand Up @@ -583,7 +582,7 @@ static PlatformKind parsePlatformVersion(const opt::ArgList &args) {
}

// Has the side-effect of setting Config::target.
static TargetInfo *createTargetInfo(opt::InputArgList &args) {
static TargetInfo *createTargetInfo(InputArgList &args) {
StringRef archName = args.getLastArgValue(OPT_arch);
if (archName.empty())
fatal("must specify -arch");
Expand All @@ -603,7 +602,7 @@ static TargetInfo *createTargetInfo(opt::InputArgList &args) {
}

static UndefinedSymbolTreatment
getUndefinedSymbolTreatment(const opt::ArgList &args) {
getUndefinedSymbolTreatment(const ArgList &args) {
StringRef treatmentStr = args.getLastArgValue(OPT_undefined);
auto treatment =
StringSwitch<UndefinedSymbolTreatment>(treatmentStr)
Expand All @@ -628,7 +627,7 @@ getUndefinedSymbolTreatment(const opt::ArgList &args) {
return treatment;
}

static void warnIfDeprecatedOption(const opt::Option &opt) {
static void warnIfDeprecatedOption(const Option &opt) {
if (!opt.getGroup().isValid())
return;
if (opt.getGroup().getID() == OPT_grp_deprecated) {
Expand All @@ -637,7 +636,7 @@ static void warnIfDeprecatedOption(const opt::Option &opt) {
}
}

static void warnIfUnimplementedOption(const opt::Option &opt) {
static void warnIfUnimplementedOption(const Option &opt) {
if (!opt.getGroup().isValid() || !opt.hasFlag(DriverFlag::HelpHidden))
return;
switch (opt.getGroup().getID()) {
Expand All @@ -662,13 +661,13 @@ static void warnIfUnimplementedOption(const opt::Option &opt) {
}
}

static const char *getReproduceOption(opt::InputArgList &args) {
static const char *getReproduceOption(InputArgList &args) {
if (const Arg *arg = args.getLastArg(OPT_reproduce))
return arg->getValue();
return getenv("LLD_REPRODUCE");
}

static bool isPie(opt::InputArgList &args) {
static bool isPie(InputArgList &args) {
if (config->outputType != MH_EXECUTE || args.hasArg(OPT_no_pie))
return false;
if (config->target.Arch == AK_arm64 || config->target.Arch == AK_arm64e)
Expand Down Expand Up @@ -700,8 +699,8 @@ static void parseClangOption(StringRef opt, const Twine &msg) {
error(msg + ": " + StringRef(err).trim());
}

static uint32_t parseDylibVersion(const opt::ArgList& args, unsigned id) {
const opt::Arg *arg = args.getLastArg(id);
static uint32_t parseDylibVersion(const ArgList &args, unsigned id) {
const Arg *arg = args.getLastArg(id);
if (!arg)
return 0;

Expand Down Expand Up @@ -748,7 +747,7 @@ bool SymbolPatterns::match(StringRef symbolName) const {
return matchLiteral(symbolName) || matchGlob(symbolName);
}

static void handleSymbolPatterns(opt::InputArgList &args,
static void handleSymbolPatterns(InputArgList &args,
SymbolPatterns &symbolPatterns,
unsigned singleOptionCode,
unsigned listFileOptionCode) {
Expand Down Expand Up @@ -783,7 +782,7 @@ bool macho::link(ArrayRef<const char *> argsArr, bool canExitEarly,


MachOOptTable parser;
opt::InputArgList args = parser.parse(argsArr.slice(1));
InputArgList args = parser.parse(argsArr.slice(1));

if (args.hasArg(OPT_help_hidden)) {
parser.printHelp(argsArr[0], /*showHidden=*/true);
Expand Down Expand Up @@ -836,7 +835,7 @@ bool macho::link(ArrayRef<const char *> argsArr, bool canExitEarly,
config->printEachFile = args.hasArg(OPT_t);
config->printWhyLoad = args.hasArg(OPT_why_load);
config->outputType = getOutputType(args);
if (const opt::Arg *arg = args.getLastArg(OPT_bundle_loader)) {
if (const Arg *arg = args.getLastArg(OPT_bundle_loader)) {
if (config->outputType != MH_BUNDLE)
error("-bundle_loader can only be used with MachO bundle output");
addFile(arg->getValue(), false, true);
Expand All @@ -851,10 +850,10 @@ bool macho::link(ArrayRef<const char *> argsArr, bool canExitEarly,
config->demangle = args.hasArg(OPT_demangle);
config->implicitDylibs = !args.hasArg(OPT_no_implicit_dylibs);

if (const opt::Arg *arg = args.getLastArg(OPT_static, OPT_dynamic))
if (const Arg *arg = args.getLastArg(OPT_static, OPT_dynamic))
config->staticLink = (arg->getOption().getID() == OPT_static);

if (const opt::Arg *arg =
if (const Arg *arg =
args.getLastArg(OPT_flat_namespace, OPT_twolevel_namespace))
config->namespaceKind = arg->getOption().getID() == OPT_twolevel_namespace
? NamespaceKind::twolevel
Expand All @@ -867,7 +866,7 @@ bool macho::link(ArrayRef<const char *> argsArr, bool canExitEarly,
getLibrarySearchPaths(args, config->systemLibraryRoots);
config->frameworkSearchPaths =
getFrameworkSearchPaths(args, config->systemLibraryRoots);
if (const opt::Arg *arg =
if (const Arg *arg =
args.getLastArg(OPT_search_paths_first, OPT_search_dylibs_first))
config->searchDylibsFirst =
arg->getOption().getID() == OPT_search_dylibs_first;
Expand Down
14 changes: 7 additions & 7 deletions lld/MachO/DriverUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ using namespace lld::macho;
#undef PREFIX

// Create table mapping all options defined in Options.td
static const opt::OptTable::Info optInfo[] = {
static const OptTable::Info optInfo[] = {
#define OPTION(X1, X2, ID, KIND, GROUP, ALIAS, X7, X8, X9, X10, X11, X12) \
{X1, X2, X10, X11, OPT_##ID, opt::Option::KIND##Class, \
{X1, X2, X10, X11, OPT_##ID, Option::KIND##Class, \
X9, X8, OPT_##GROUP, OPT_##ALIAS, X7, X12},
#include "Options.inc"
#undef OPTION
Expand All @@ -51,7 +51,7 @@ MachOOptTable::MachOOptTable() : OptTable(optInfo) {}

// Set color diagnostics according to --color-diagnostics={auto,always,never}
// or --no-color-diagnostics flags.
static void handleColorDiagnostics(opt::InputArgList &args) {
static void handleColorDiagnostics(InputArgList &args) {
const Arg *arg =
args.getLastArg(OPT_color_diagnostics, OPT_color_diagnostics_eq,
OPT_no_color_diagnostics);
Expand All @@ -72,7 +72,7 @@ static void handleColorDiagnostics(opt::InputArgList &args) {
}
}

opt::InputArgList MachOOptTable::parse(ArrayRef<const char *> argv) {
InputArgList MachOOptTable::parse(ArrayRef<const char *> argv) {
// Make InputArgList from string vectors.
unsigned missingIndex;
unsigned missingCount;
Expand All @@ -81,7 +81,7 @@ opt::InputArgList MachOOptTable::parse(ArrayRef<const char *> argv) {
// Expand response files (arguments in the form of @<filename>)
// and then parse the argument again.
cl::ExpandResponseFiles(saver, cl::TokenizeGNUCommandLine, vec);
opt::InputArgList args = ParseArgs(vec, missingIndex, missingCount);
InputArgList args = ParseArgs(vec, missingIndex, missingCount);

// Handle -fatal_warnings early since it converts missing argument warnings
// to errors.
Expand All @@ -92,7 +92,7 @@ opt::InputArgList MachOOptTable::parse(ArrayRef<const char *> argv) {

handleColorDiagnostics(args);

for (opt::Arg *arg : args.filtered(OPT_UNKNOWN)) {
for (const Arg *arg : args.filtered(OPT_UNKNOWN)) {
std::string nearest;
if (findNearest(arg->getAsString(args), nearest) > 1)
error("unknown argument '" + arg->getAsString(args) + "'");
Expand All @@ -117,7 +117,7 @@ static std::string rewritePath(StringRef s) {

// Reconstructs command line arguments so that so that you can re-run
// the same command with the same inputs. This is for --reproduce.
std::string macho::createResponseFile(const opt::InputArgList &args) {
std::string macho::createResponseFile(const InputArgList &args) {
SmallString<0> data;
raw_svector_ostream os(data);

Expand Down

0 comments on commit 714ec86

Please sign in to comment.