int lld::args::getInteger(opt::InputArgList &Args, unsigned Key, int Default) { int V = Default; if (auto *Arg = Args.getLastArg(Key)) { StringRef S = Arg->getValue(); if (!to_integer(S, V, 10)) error(Arg->getSpelling() + ": number expected, but got '" + S + "'"); } return V; }
static cl::TokenizerCallback getQuotingStyle(opt::InputArgList &Args) { if (auto *Arg = Args.getLastArg(OPT_rsp_quoting)) { StringRef S = Arg->getValue(); if (S != "windows" && S != "posix") error("invalid response file quoting: " + S); if (S == "windows") return cl::TokenizeWindowsCommandLine; return cl::TokenizeGNUCommandLine; } if (Triple(sys::getProcessTriple()).getOS() == Triple::Win32) return cl::TokenizeWindowsCommandLine; return cl::TokenizeGNUCommandLine; }
// Parse -color-diagnostics={auto,always,never} or -no-color-diagnostics. static bool getColorDiagnostics(opt::InputArgList &Args) { auto *Arg = Args.getLastArg(OPT_color_diagnostics, OPT_color_diagnostics_eq, OPT_no_color_diagnostics); if (!Arg) return ErrorOS->has_colors(); if (Arg->getOption().getID() == OPT_color_diagnostics) return true; if (Arg->getOption().getID() == OPT_no_color_diagnostics) return false; StringRef S = Arg->getValue(); if (S == "auto") return ErrorOS->has_colors(); if (S == "always") return true; if (S != "never") error("unknown option: -color-diagnostics=" + S); return false; }
// Parse -color-diagnostics={auto,always,never} or -no-color-diagnostics. static bool getColorDiagnostics(opt::InputArgList &Args) { bool Default = (ErrorOS == &errs() && Process::StandardErrHasColors()); auto *Arg = Args.getLastArg(OPT_color_diagnostics, OPT_color_diagnostics_eq, OPT_no_color_diagnostics); if (!Arg) return Default; if (Arg->getOption().getID() == OPT_color_diagnostics) return true; if (Arg->getOption().getID() == OPT_no_color_diagnostics) return false; StringRef S = Arg->getValue(); if (S == "auto") return Default; if (S == "always") return true; if (S != "never") error("unknown option: -color-diagnostics=" + S); return false; }