31#include "llvm/Config/config.h"
50#define DEBUG_TYPE "commandline"
79void GenericOptionValue::anchor() {}
82void Option::anchor() {}
106 size_t Len = ArgName.
size();
114 for (
size_t I = 0;
I < Pad; ++
I) {
142 OS <<
argPrefix(Arg.ArgName, Arg.Pad) << Arg.ArgName;
146class CommandLineParser {
150 std::string ProgramName;
154 std::vector<StringRef> MoreHelp;
167 CommandLineParser() {
176 bool LongOptionsUseDoubleDash =
false);
181 if (!
SC->OptionsMap.insert(std::make_pair(
Name, &Opt)).second) {
182 errs() << ProgramName <<
": CommandLine Error: Option '" <<
Name
183 <<
"' registered more than once!\n";
190 for (
auto *Sub : RegisteredSubCommands) {
193 addLiteralOption(Opt, Sub,
Name);
199 if (Opt.
Subs.empty())
202 for (
auto *SC : Opt.
Subs)
203 addLiteralOption(Opt, SC,
Name);
208 bool HadErrors =
false;
209 if (
O->hasArgStr()) {
211 if (
O->isDefaultOption() &&
SC->OptionsMap.contains(
O->ArgStr))
215 if (!
SC->OptionsMap.insert(std::make_pair(
O->ArgStr, O)).second) {
216 errs() << ProgramName <<
": CommandLine Error: Option '" <<
O->ArgStr
217 <<
"' registered more than once!\n";
224 SC->PositionalOpts.push_back(O);
226 SC->SinkOpts.push_back(O);
228 if (
SC->ConsumeAfterOpt) {
229 O->error(
"Cannot specify more than one option with cl::ConsumeAfter!");
232 SC->ConsumeAfterOpt =
O;
245 for (
auto *Sub : RegisteredSubCommands) {
253 void addOption(
Option *O,
bool ProcessDefaultOption =
false) {
254 if (!ProcessDefaultOption &&
O->isDefaultOption()) {
259 if (
O->Subs.empty()) {
262 for (
auto *SC :
O->Subs)
269 O->getExtraOptionNames(OptionNames);
275 for (
auto Name : OptionNames) {
277 if (
I !=
End &&
I->getValue() == O)
300 void removeOption(
Option *O) {
304 if (
O->isInAllSubCommands()) {
305 for (
auto *SC : RegisteredSubCommands)
308 for (
auto *SC :
O->Subs)
314 bool hasOptions(
const SubCommand &Sub)
const {
319 bool hasOptions()
const {
320 for (
const auto *S : RegisteredSubCommands) {
327 SubCommand *getActiveSubCommand() {
return ActiveSubCommand; }
331 if (!Sub.
OptionsMap.insert(std::make_pair(NewName, O)).second) {
332 errs() << ProgramName <<
": CommandLine Error: Option '" <<
O->ArgStr
333 <<
"' registered more than once!\n";
343 if (
O->isInAllSubCommands()) {
344 for (
auto *SC : RegisteredSubCommands)
345 updateArgStr(O, NewName, SC);
347 for (
auto *SC :
O->Subs)
348 updateArgStr(O, NewName, SC);
353 void printOptionValues();
360 "Duplicate option categories");
368 return (!
sub->getName().empty()) &&
371 "Duplicate subcommands");
372 RegisteredSubCommands.insert(
sub);
379 if ((
O->isPositional() ||
O->isSink() ||
O->isConsumeAfter()) ||
383 addLiteralOption(*O,
sub,
E.first());
389 RegisteredSubCommands.erase(
sub);
394 return make_range(RegisteredSubCommands.begin(),
395 RegisteredSubCommands.end());
399 ActiveSubCommand =
nullptr;
404 RegisteredOptionCategories.
clear();
407 RegisteredSubCommands.clear();
414 DefaultOptions.
clear();
422 bool LongOptionsUseDoubleDash,
bool HaveDoubleDash) {
424 if (Opt && LongOptionsUseDoubleDash && !HaveDoubleDash && !
isGrouping(Opt))
445 FullyInitialized =
true;
451 if (FullyInitialized)
453 assert((S.
empty() || S[0] !=
'-') &&
"Option can't start with '-");
477void OptionCategory::registerCategory() {
511SubCommand::operator
bool()
const {
529 size_t EqualPos = Arg.
find(
'=');
549 Arg = Arg.
substr(0, EqualPos);
556 for (
auto *S : RegisteredSubCommands) {
559 if (S->getName().empty())
574 std::string &NearestString) {
580 std::pair<StringRef, StringRef> SplitArg = Arg.
split(
'=');
586 unsigned BestDistance = 0;
588 ie = OptionsMap.
end();
596 O->getExtraOptionNames(OptionNames);
602 for (
const auto &
Name : OptionNames) {
604 Flag,
true, BestDistance);
605 if (!Best || Distance < BestDistance) {
607 BestDistance = Distance;
608 if (
RHS.empty() || !PermitValue)
609 NearestString = std::string(
Name);
623 bool MultiArg =
false) {
635 Val = Val.
substr(Pos + 1);
651 const char *
const *argv,
int &i) {
662 return Handler->
error(
"requires a value!");
664 assert(argv &&
"null check");
669 if (NumAdditionalVals > 0)
670 return Handler->
error(
"multi-valued option specified"
671 " with ValueDisallowed modifier!");
682 if (NumAdditionalVals == 0)
686 bool MultiArg =
false;
695 while (NumAdditionalVals > 0) {
697 return Handler->
error(
"not enough values!");
698 assert(argv &&
"null check");
721 bool (*Pred)(
const Option *),
724 if (OMI != OptionsMap.
end() && !Pred(OMI->getValue()))
725 OMI = OptionsMap.
end();
730 while (OMI == OptionsMap.
end() &&
Name.size() > 1) {
733 if (OMI != OptionsMap.
end() && !Pred(OMI->getValue()))
734 OMI = OptionsMap.
end();
737 if (OMI != OptionsMap.
end() && Pred(OMI->second)) {
765 assert(OptionsMap.
count(Arg) && OptionsMap.
find(Arg)->second == PGOpt);
775 if (MaybeValue[0] ==
'=') {
785 ErrorParsing |= PGOpt->
error(
"may not occur within a group!");
814 return C ==
' ' ||
C ==
'\t' ||
C ==
'\r' ||
C ==
'\n';
821static bool isQuote(
char C) {
return C ==
'\"' ||
C ==
'\''; }
827 for (
size_t I = 0,
E = Src.size();
I !=
E; ++
I) {
832 if (MarkEOLs && Src[
I] ==
'\n')
843 if (
I + 1 <
E &&
C ==
'\\') {
852 while (
I !=
E && Src[
I] !=
C) {
854 if (Src[
I] ==
'\\' &&
I + 1 !=
E)
869 if (MarkEOLs &&
C ==
'\n')
902 size_t E = Src.size();
903 int BackslashCount = 0;
908 }
while (
I !=
E && Src[
I] ==
'\\');
910 bool FollowedByDoubleQuote = (
I !=
E && Src[
I] ==
'"');
911 if (FollowedByDoubleQuote) {
912 Token.
append(BackslashCount / 2,
'\\');
913 if (BackslashCount % 2 == 0)
918 Token.
append(BackslashCount,
'\\');
936 bool AlwaysCopy,
function_ref<
void()> MarkEOL,
bool InitialCommandName) {
945 bool CommandName = InitialCommandName;
948 enum {
INIT, UNQUOTED, QUOTED } State =
INIT;
950 for (
size_t I = 0,
E = Src.size();
I <
E; ++
I) {
953 assert(Token.
empty() &&
"token should be empty in initial state");
975 AddToken(AlwaysCopy ? Saver.
save(NormalChars) : NormalChars);
976 if (
I <
E && Src[
I] ==
'\n') {
978 CommandName = InitialCommandName;
982 }
else if (Src[
I] ==
'\"') {
983 Token += NormalChars;
985 }
else if (Src[
I] ==
'\\') {
986 assert(!CommandName &&
"or else we'd have treated it as a normal char");
987 Token += NormalChars;
1001 AddToken(Saver.
save(Token.
str()));
1003 if (Src[
I] ==
'\n') {
1004 CommandName = InitialCommandName;
1007 CommandName =
false;
1010 }
else if (Src[
I] ==
'\"') {
1012 }
else if (Src[
I] ==
'\\' && !CommandName) {
1020 if (Src[
I] ==
'\"') {
1021 if (
I < (
E - 1) && Src[
I + 1] ==
'"') {
1030 }
else if (Src[
I] ==
'\\' && !CommandName) {
1040 AddToken(Saver.
save(Token.
str()));
1047 auto OnEOL = [&]() {
1052 true, OnEOL,
false);
1058 auto OnEOL = []() {};
1067 auto OnEOL = [&]() {
1078 for (
const char *Cur = Source.begin(); Cur != Source.end();) {
1087 while (Cur != Source.end() && *Cur !=
'\n')
1092 const char *Start = Cur;
1093 for (
const char *
End = Source.end(); Cur !=
End; ++Cur) {
1095 if (Cur + 1 !=
End) {
1098 (*Cur ==
'\r' && (Cur + 1 !=
End) && Cur[1] ==
'\n')) {
1099 Line.append(Start, Cur - 1);
1105 }
else if (*Cur ==
'\n')
1109 Line.append(Start, Cur);
1117 return (S.
size() >= 3 && S[0] ==
'\xef' && S[1] ==
'\xbb' && S[2] ==
'\xbf');
1131 TokenPos = ArgString.
find(Token, StartPos)) {
1135 if (ResponseFile.
empty())
1139 ResponseFile.
append(BasePath);
1140 StartPos = TokenPos + Token.
size();
1143 if (!ResponseFile.
empty()) {
1146 if (!Remaining.
empty())
1153Error ExpansionContext::expandResponseFile(
1161 "': " +
EC.message());
1168 std::string UTF8Buf;
1172 "Could not convert UTF16 to UTF8");
1179 Str =
StringRef(BufRef.data() + 3, BufRef.size() - 3);
1182 Tokenizer(Str, Saver, NewArgv, MarkEOLs);
1187 if (!RelativeNames && !InConfigFile)
1191 for (
const char *&Arg : NewArgv) {
1203 bool ConfigInclusion =
false;
1204 if (ArgStr.consume_front(
"@")) {
1208 }
else if (ArgStr.consume_front(
"--config=")) {
1210 ConfigInclusion =
true;
1222 std::make_error_code(std::errc::no_such_file_or_directory),
1223 "cannot not find configuration file: " + FileName);
1224 ResponseFile.
append(FilePath);
1226 ResponseFile.
append(BasePath);
1238 struct ResponseFileRecord {
1253 for (
unsigned I = 0;
I != Argv.
size();) {
1254 while (
I == FileStack.
back().End) {
1260 const char *Arg = Argv[
I];
1262 if (Arg ==
nullptr) {
1267 if (Arg[0] !=
'@') {
1272 const char *FName = Arg + 1;
1277 if (CurrentDir.
empty()) {
1282 CWD.getError(),
Twine(
"cannot get absolute path for: ") + FName);
1285 CurrDir = CurrentDir;
1288 FName = CurrDir.
c_str();
1292 if (!Res || !Res->exists()) {
1293 std::error_code EC = Res.
getError();
1294 if (!InConfigFile) {
1305 "': " + EC.message());
1310 [FileStatus,
this](
const ResponseFileRecord &RFile) ->
ErrorOr<bool> {
1313 return RHS.getError();
1322 R.getError(),
Twine(
"recursive expansion of: '") +
F.File +
"'");
1325 Twine(
"cannot open file: ") +
F.File);
1332 if (
Error Err = expandResponseFile(FName, ExpandedArgv))
1335 for (ResponseFileRecord &
Record : FileStack) {
1341 FileStack.push_back({FName,
I + ExpandedArgv.
size()});
1366 Tokenize(*EnvValue, Saver, NewArgv,
false);
1369 NewArgv.
append(Argv + 1, Argv + Argc);
1389 : Saver(
A), Tokenizer(
T), FS(vfs::getRealFileSystem().
get()) {}
1403 CfgFilePath = FileName;
1406 if (!FileExists(CfgFilePath))
1413 for (
const StringRef &Dir : SearchDirs) {
1419 if (FileExists(CfgFilePath)) {
1434 return make_error<StringError>(
1435 EC,
Twine(
"cannot get absolute path for " + CfgFile));
1436 CfgFile = AbsPath.
str();
1438 InConfigFile =
true;
1439 RelativeNames =
true;
1440 if (
Error Err = expandResponseFile(CfgFile, Argv))
1449 bool LongOptionsUseDoubleDash) {
1458 if (std::optional<std::string> EnvValue =
1464 for (
int I = 1;
I < argc; ++
I)
1466 int NewArgc =
static_cast<int>(NewArgv.
size());
1469 return GlobalParser->ParseCommandLineOptions(NewArgc, &NewArgv[0], Overview,
1470 Errs, LongOptionsUseDoubleDash);
1474void CommandLineParser::ResetAllOptionOccurrences() {
1478 for (
auto *SC : RegisteredSubCommands) {
1479 for (
auto &O : SC->OptionsMap)
1481 for (
Option *O : SC->PositionalOpts)
1483 for (
Option *O : SC->SinkOpts)
1485 if (SC->ConsumeAfterOpt)
1486 SC->ConsumeAfterOpt->reset();
1490bool CommandLineParser::ParseCommandLineOptions(
int argc,
1491 const char *
const *argv,
1494 bool LongOptionsUseDoubleDash) {
1495 assert(hasOptions() &&
"No options specified!");
1497 ProgramOverview = Overview;
1498 bool IgnoreErrors = Errs;
1501 bool ErrorParsing =
false;
1512 if (
Error Err = ECtx.expandResponseFiles(newArgv)) {
1513 *Errs <<
toString(std::move(Err)) <<
'\n';
1517 argc =
static_cast<int>(newArgv.size());
1523 unsigned NumPositionalRequired = 0;
1526 bool HasUnlimitedPositionals =
false;
1530 if (argc >= 2 && argv[FirstArg][0] !=
'-') {
1533 ChosenSubCommand = LookupSubCommand(
StringRef(argv[FirstArg]));
1539 assert(ChosenSubCommand);
1542 auto &SinkOpts = ChosenSubCommand->
SinkOpts;
1543 auto &OptionsMap = ChosenSubCommand->
OptionsMap;
1545 for (
auto *O: DefaultOptions) {
1549 if (ConsumeAfterOpt) {
1550 assert(PositionalOpts.size() > 0 &&
1551 "Cannot specify cl::ConsumeAfter without a positional argument!");
1553 if (!PositionalOpts.empty()) {
1556 bool UnboundedFound =
false;
1557 for (
size_t i = 0, e = PositionalOpts.size(); i != e; ++i) {
1558 Option *Opt = PositionalOpts[i];
1560 ++NumPositionalRequired;
1561 else if (ConsumeAfterOpt) {
1564 if (PositionalOpts.size() > 1) {
1566 Opt->
error(
"error - this positional option will never be matched, "
1567 "because it does not Require a value, and a "
1568 "cl::ConsumeAfter option is active!");
1569 ErrorParsing =
true;
1571 }
else if (UnboundedFound && !Opt->
hasArgStr()) {
1577 Opt->
error(
"error - option can never match, because "
1578 "another positional argument will match an "
1579 "unbounded number of values, and this option"
1580 " does not require a value!");
1581 *Errs << ProgramName <<
": CommandLine Error: Option '" << Opt->
ArgStr
1582 <<
"' is all messed up!\n";
1583 *Errs << PositionalOpts.size();
1584 ErrorParsing =
true;
1588 HasUnlimitedPositionals = UnboundedFound || ConsumeAfterOpt;
1599 Option *ActivePositionalArg =
nullptr;
1602 bool DashDashFound =
false;
1603 for (
int i = FirstArg; i < argc; ++i) {
1604 Option *Handler =
nullptr;
1605 Option *NearestHandler =
nullptr;
1606 std::string NearestHandlerString;
1609 bool HaveDoubleDash =
false;
1615 if (argv[i][0] !=
'-' || argv[i][1] == 0 || DashDashFound) {
1617 if (ActivePositionalArg) {
1622 if (!PositionalOpts.empty()) {
1628 if (PositionalVals.
size() >= NumPositionalRequired && ConsumeAfterOpt) {
1629 for (++i; i < argc; ++i)
1637 }
else if (argv[i][0] ==
'-' && argv[i][1] ==
'-' && argv[i][2] == 0 &&
1639 DashDashFound =
true;
1641 }
else if (ActivePositionalArg &&
1648 if (!ArgName.
empty() && ArgName[0] ==
'-') {
1649 HaveDoubleDash =
true;
1650 ArgName = ArgName.
substr(1);
1653 Handler = LookupLongOption(*ChosenSubCommand, ArgName,
Value,
1654 LongOptionsUseDoubleDash, HaveDoubleDash);
1662 if (!ArgName.
empty() && ArgName[0] ==
'-') {
1663 HaveDoubleDash =
true;
1664 ArgName = ArgName.
substr(1);
1667 Handler = LookupLongOption(*ChosenSubCommand, ArgName,
Value,
1668 LongOptionsUseDoubleDash, HaveDoubleDash);
1671 if (!Handler && !(LongOptionsUseDoubleDash && HaveDoubleDash))
1677 if (!Handler && SinkOpts.empty())
1683 if (SinkOpts.empty()) {
1684 *Errs << ProgramName <<
": Unknown command line argument '" << argv[i]
1685 <<
"'. Try: '" << argv[0] <<
" --help'\n";
1687 if (NearestHandler) {
1689 *Errs << ProgramName <<
": Did you mean '"
1690 << PrintArg(NearestHandlerString, 0) <<
"'?\n";
1693 ErrorParsing =
true;
1695 for (
Option *SinkOpt : SinkOpts)
1696 SinkOpt->addOccurrence(i,
"",
StringRef(argv[i]));
1705 Handler->
error(
"This argument does not take a value.\n"
1706 "\tInstead, it consumes any positional arguments until "
1707 "the next recognized option.", *Errs);
1708 ErrorParsing =
true;
1710 ActivePositionalArg = Handler;
1717 if (NumPositionalRequired > PositionalVals.
size()) {
1718 *Errs << ProgramName
1719 <<
": Not enough positional command line arguments specified!\n"
1720 <<
"Must specify at least " << NumPositionalRequired
1721 <<
" positional argument" << (NumPositionalRequired > 1 ?
"s" :
"")
1722 <<
": See: " << argv[0] <<
" --help\n";
1724 ErrorParsing =
true;
1725 }
else if (!HasUnlimitedPositionals &&
1726 PositionalVals.
size() > PositionalOpts.size()) {
1727 *Errs << ProgramName <<
": Too many positional arguments specified!\n"
1728 <<
"Can specify at most " << PositionalOpts.size()
1729 <<
" positional arguments: See: " << argv[0] <<
" --help\n";
1730 ErrorParsing =
true;
1732 }
else if (!ConsumeAfterOpt) {
1734 unsigned ValNo = 0, NumVals =
static_cast<unsigned>(PositionalVals.
size());
1735 for (
size_t i = 0, e = PositionalOpts.size(); i !=
e; ++i) {
1738 PositionalVals[ValNo].second);
1740 --NumPositionalRequired;
1748 while (NumVals - ValNo > NumPositionalRequired && !
Done) {
1749 switch (PositionalOpts[i]->getNumOccurrencesFlag()) {
1756 PositionalVals[ValNo].first,
1757 PositionalVals[ValNo].second);
1762 "positional argument processing!");
1767 assert(ConsumeAfterOpt && NumPositionalRequired <= PositionalVals.
size());
1769 for (
size_t J = 0,
E = PositionalOpts.size(); J !=
E; ++J)
1772 PositionalVals[ValNo].first,
1773 PositionalVals[ValNo].second);
1782 if (PositionalOpts.size() == 1 && ValNo == 0 && !PositionalVals.
empty()) {
1784 PositionalVals[ValNo].first,
1785 PositionalVals[ValNo].second);
1791 for (; ValNo != PositionalVals.
size(); ++ValNo)
1794 PositionalVals[ValNo].second);
1798 for (
const auto &Opt : OptionsMap) {
1803 Opt.second->
error(
"must be specified at least once!");
1804 ErrorParsing =
true;
1816 for (
int i = 0; i < argc; ++i)
dbgs() << argv[i] <<
' ';
1837 if (!ArgName.
data())
1839 if (ArgName.
empty())
1842 Errs <<
GlobalParser->ProgramName <<
": for the " << PrintArg(ArgName, 0);
1844 Errs <<
" option: " << Message <<
"\n";
1853 return handleOccurrence(pos, ArgName,
Value);
1860 if (O.ValueStr.empty())
1870size_t alias::getOptionWidth()
const {
1875 size_t FirstLineIndentedBy) {
1876 assert(Indent >= FirstLineIndentedBy);
1877 std::pair<StringRef, StringRef> Split =
HelpStr.
split(
'\n');
1880 while (!Split.second.empty()) {
1881 Split = Split.second.split(
'\n');
1882 outs().
indent(Indent) << Split.first <<
"\n";
1887 size_t FirstLineIndentedBy) {
1889 assert(BaseIndent >= FirstLineIndentedBy);
1890 std::pair<StringRef, StringRef> Split =
HelpStr.
split(
'\n');
1891 outs().
indent(BaseIndent - FirstLineIndentedBy)
1893 while (!Split.second.empty()) {
1894 Split = Split.second.split(
'\n');
1895 outs().
indent(BaseIndent + ValHelpPrefix.
size()) << Split.first <<
"\n";
1900void alias::printOptionInfo(
size_t GlobalWidth)
const {
1916 if (!ValName.empty()) {
1917 size_t FormattingLen = 3;
1930 size_t GlobalWidth)
const {
1931 outs() << PrintArg(O.ArgStr);
1934 if (!ValName.empty()) {
1940 outs() << (O.ArgStr.size() == 1 ?
" <" :
"=<") <<
getValueStr(O, ValName)
1949 size_t GlobalWidth)
const {
1950 outs() << PrintArg(O.ArgStr);
1951 outs().
indent(GlobalWidth - O.ArgStr.size());
1958 if (Arg ==
"" || Arg ==
"true" || Arg ==
"TRUE" || Arg ==
"True" ||
1964 if (Arg ==
"false" || Arg ==
"FALSE" || Arg ==
"False" || Arg ==
"0") {
1968 return O.error(
"'" + Arg +
1969 "' is invalid value for boolean argument! Try 0 or 1");
1976 if (Arg ==
"" || Arg ==
"true" || Arg ==
"TRUE" || Arg ==
"True" ||
1981 if (Arg ==
"false" || Arg ==
"FALSE" || Arg ==
"False" || Arg ==
"0") {
1986 return O.error(
"'" + Arg +
1987 "' is invalid value for boolean argument! Try 0 or 1");
1995 return O.error(
"'" + Arg +
"' value invalid for integer argument!");
2004 return O.error(
"'" + Arg +
"' value invalid for long argument!");
2013 return O.error(
"'" + Arg +
"' value invalid for llong argument!");
2023 return O.error(
"'" + Arg +
"' value invalid for uint argument!");
2030 unsigned long &
Value) {
2033 return O.error(
"'" + Arg +
"' value invalid for ulong argument!");
2041 unsigned long long &
Value) {
2044 return O.error(
"'" + Arg +
"' value invalid for ullong argument!");
2051 if (to_float(Arg,
Value))
2053 return O.error(
"'" + Arg +
"' value invalid for floating point argument!");
2079 for (
unsigned i = 0; i != e; ++i) {
2096 !Description.
empty();
2101 if (O.hasArgStr()) {
2113 size_t BaseSize = 0;
2124 size_t GlobalWidth)
const {
2125 if (O.hasArgStr()) {
2131 outs() << PrintArg(O.ArgStr);
2150 if (OptionName.
empty()) {
2155 if (!Description.
empty())
2161 if (!O.HelpStr.empty())
2162 outs() <<
" " << O.HelpStr <<
'\n';
2179 outs() <<
" " << PrintArg(O.ArgStr);
2180 outs().
indent(GlobalWidth - O.ArgStr.size());
2183 for (
unsigned i = 0; i != NumOpts; ++i) {
2191 for (
unsigned j = 0; j != NumOpts; ++j) {
2200 outs() <<
"= *unknown option value*\n";
2205#define PRINT_OPT_DIFF(T) \
2206 void parser<T>::printOptionDiff(const Option &O, T V, OptionValue<T> D, \
2207 size_t GlobalWidth) const { \
2208 printOptionName(O, GlobalWidth); \
2211 raw_string_ostream SS(Str); \
2214 outs() << "= " << Str; \
2215 size_t NumSpaces = \
2216 MaxOptWidth > Str.size() ? MaxOptWidth - Str.size() : 0; \
2217 outs().indent(NumSpaces) << " (default: "; \
2219 outs() << D.getValue(); \
2221 outs() << "*no default*"; \
2239 size_t GlobalWidth)
const {
2240 printOptionName(O, GlobalWidth);
2241 outs() <<
"= " << V;
2245 outs() <<
D.getValue();
2247 outs() <<
"*no default*";
2253 size_t GlobalWidth)
const {
2255 outs() <<
"= *cannot print option value*\n";
2263 const std::pair<const char *, Option *> *RHS) {
2264 return strcmp(
LHS->first,
RHS->first);
2268 const std::pair<const char *, SubCommand *> *RHS) {
2269 return strcmp(
LHS->first,
RHS->first);
2285 if (
I->second->getOptionHiddenFlag() ==
Hidden && !ShowHidden)
2289 if (!OptionSet.
insert(
I->second).second)
2293 std::pair<const char *, Option *>(
I->getKey().data(),
I->second));
2303 for (
auto *S : SubMap) {
2304 if (S->getName().empty())
2306 Subs.push_back(std::make_pair(S->getName().data(), S));
2315 const bool ShowHidden;
2317 StrOptionPairVector;
2319 StrSubCommandPairVector;
2321 virtual void printOptions(StrOptionPairVector &Opts,
size_t MaxArgLen) {
2322 for (
size_t i = 0, e = Opts.size(); i != e; ++i)
2323 Opts[i].second->printOptionInfo(MaxArgLen);
2326 void printSubCommands(StrSubCommandPairVector &Subs,
size_t MaxSubLen) {
2327 for (
const auto &S : Subs) {
2328 outs() <<
" " << S.first;
2329 if (!S.second->getDescription().empty()) {
2331 outs() <<
" - " << S.second->getDescription();
2338 explicit HelpPrinter(
bool showHidden) : ShowHidden(showHidden) {}
2339 virtual ~HelpPrinter() =
default;
2342 void operator=(
bool Value) {
2357 StrOptionPairVector Opts;
2358 sortOpts(OptionsMap, Opts, ShowHidden);
2360 StrSubCommandPairVector Subs;
2368 if (Subs.size() > 2)
2369 outs() <<
" [subcommand]";
2370 outs() <<
" [options]";
2380 for (
auto *Opt : PositionalOpts) {
2387 if (ConsumeAfterOpt)
2388 outs() <<
" " << ConsumeAfterOpt->HelpStr;
2392 size_t MaxSubLen = 0;
2393 for (
size_t i = 0, e = Subs.size(); i != e; ++i)
2394 MaxSubLen = std::max(MaxSubLen, strlen(Subs[i].first));
2397 outs() <<
"SUBCOMMANDS:\n\n";
2398 printSubCommands(Subs, MaxSubLen);
2401 <<
" <subcommand> --help\" to get more help on a specific "
2408 size_t MaxArgLen = 0;
2409 for (
size_t i = 0, e = Opts.size(); i != e; ++i)
2410 MaxArgLen = std::max(MaxArgLen, Opts[i].second->getOptionWidth());
2412 outs() <<
"OPTIONS:\n";
2413 printOptions(Opts, MaxArgLen);
2422class CategorizedHelpPrinter :
public HelpPrinter {
2424 explicit CategorizedHelpPrinter(
bool showHidden) : HelpPrinter(showHidden) {}
2432 return (*A)->getName().compare((*B)->getName());
2436 using HelpPrinter::operator=;
2439 void printOptions(StrOptionPairVector &Opts,
size_t MaxArgLen)
override {
2440 std::vector<OptionCategory *> SortedCategories;
2446 SortedCategories.push_back(Category);
2449 assert(SortedCategories.size() > 0 &&
"No option categories registered!");
2451 OptionCategoryCompare);
2456 for (
size_t I = 0,
E = Opts.size();
I !=
E; ++
I) {
2460 "Option has an unregistered category");
2461 CategorizedOptions[Cat].push_back(Opt);
2468 const auto &CategoryOptions = CategorizedOptions[Category];
2469 bool IsEmptyCategory = CategoryOptions.
empty();
2470 if (!ShowHidden && IsEmptyCategory)
2485 if (IsEmptyCategory) {
2486 outs() <<
" This option category has no options.\n";
2490 for (
const Option *Opt : CategoryOptions)
2498class HelpPrinterWrapper {
2500 HelpPrinter &UncategorizedPrinter;
2501 CategorizedHelpPrinter &CategorizedPrinter;
2504 explicit HelpPrinterWrapper(HelpPrinter &UncategorizedPrinter,
2505 CategorizedHelpPrinter &CategorizedPrinter)
2506 : UncategorizedPrinter(UncategorizedPrinter),
2507 CategorizedPrinter(CategorizedPrinter) {}
2510 void operator=(
bool Value);
2515#if defined(__GNUC__)
2518# if defined(__OPTIMIZE__)
2519# define LLVM_IS_DEBUG_BUILD 0
2521# define LLVM_IS_DEBUG_BUILD 1
2523#elif defined(_MSC_VER)
2528# define LLVM_IS_DEBUG_BUILD 1
2530# define LLVM_IS_DEBUG_BUILD 0
2534# define LLVM_IS_DEBUG_BUILD 0
2538class VersionPrinter {
2540 void print(std::vector<VersionPrinterTy> ExtraPrinters = {}) {
2542#ifdef PACKAGE_VENDOR
2543 OS << PACKAGE_VENDOR <<
" ";
2545 OS <<
"LLVM (http://llvm.org/):\n ";
2547 OS << PACKAGE_NAME <<
" version " << PACKAGE_VERSION <<
"\n ";
2548#if LLVM_IS_DEBUG_BUILD
2549 OS <<
"DEBUG build";
2551 OS <<
"Optimized build";
2554 OS <<
" with assertions";
2560 if (!ExtraPrinters.empty()) {
2561 for (
const auto &
I : ExtraPrinters)
2565 void operator=(
bool OptionWasSpecified);
2568struct CommandLineCommonOptions {
2571 HelpPrinter UncategorizedNormalPrinter{
false};
2572 HelpPrinter UncategorizedHiddenPrinter{
true};
2573 CategorizedHelpPrinter CategorizedNormalPrinter{
false};
2574 CategorizedHelpPrinter CategorizedHiddenPrinter{
true};
2577 HelpPrinterWrapper WrappedNormalPrinter{UncategorizedNormalPrinter,
2578 CategorizedNormalPrinter};
2579 HelpPrinterWrapper WrappedHiddenPrinter{UncategorizedHiddenPrinter,
2580 CategorizedHiddenPrinter};
2590 "Display list of available options (--help-list-hidden for more)"),
2599 cl::desc(
"Display list of all available options"),
2611 cl::desc(
"Display available options (--help-hidden for more)"),
2622 cl::desc(
"Display all available options"),
2631 cl::desc(
"Print non-default options after command line parsing"),
2638 "print-all-options",
2639 cl::desc(
"Print all option values after command line parsing"),
2647 std::vector<VersionPrinterTy> ExtraVersionPrinters;
2650 VersionPrinter VersionPrinterInstance;
2653 "version",
cl::desc(
"Display the version of this program"),
2679 return GeneralCategory;
2682void VersionPrinter::operator=(
bool OptionWasSpecified) {
2683 if (!OptionWasSpecified)
2695void HelpPrinterWrapper::operator=(
bool Value) {
2702 if (
GlobalParser->RegisteredOptionCategories.size() > 1) {
2707 CategorizedPrinter =
true;
2709 UncategorizedPrinter =
true;
2715void CommandLineParser::printOptionValues() {
2723 size_t MaxArgLen = 0;
2724 for (
size_t i = 0, e = Opts.
size(); i != e; ++i)
2725 MaxArgLen = std::max(MaxArgLen, Opts[i].second->getOptionWidth());
2727 for (
size_t i = 0, e = Opts.
size(); i != e; ++i)
2728 Opts[i].second->printOptionValue(MaxArgLen,
CommonOptions->PrintAllOptions);
2733 if (!
Hidden && !Categorized)
2735 else if (!
Hidden && Categorized)
2737 else if (
Hidden && !Categorized)
2760 assert(Subs.contains(&Sub));
2772 bool Unrelated =
true;
2773 for (
auto &Cat :
I.second->Categories) {
2774 if (Cat == &Category || Cat == &
CommonOptions->GenericCategory)
2786 bool Unrelated =
true;
2787 for (
auto &Cat :
I.second->Categories) {
2803 const char *Overview) {
This file defines the StringMap class.
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
static bool CommaSeparateAndAddOccurrence(Option *Handler, unsigned pos, StringRef ArgName, StringRef Value, bool MultiArg=false)
CommaSeparateAndAddOccurrence - A wrapper around Handler->addOccurrence() that does special handling ...
static StringRef OptionPrefix
static bool RequiresValue(const Option *O)
static int SubNameCompare(const std::pair< const char *, SubCommand * > *LHS, const std::pair< const char *, SubCommand * > *RHS)
static size_t argPlusPrefixesSize(StringRef ArgName, size_t Pad=DefaultPad)
static bool isPrefixedOrGrouping(const Option *O)
static bool shouldPrintOption(StringRef Name, StringRef Description, const Option &O)
static Option * HandlePrefixedOrGroupedOption(StringRef &Arg, StringRef &Value, bool &ErrorParsing, const StringMap< Option * > &OptionsMap)
HandlePrefixedOrGroupedOption - The specified argument string (which started with at least one '-') d...
static bool parseDouble(Option &O, StringRef Arg, double &Value)
static const size_t DefaultPad
static StringRef EmptyOption
static bool hasUTF8ByteOrderMark(ArrayRef< char > S)
static ManagedStatic< CommandLineParser > GlobalParser
static void ExpandBasePaths(StringRef BasePath, StringSaver &Saver, const char *&Arg)
static SmallString< 8 > argPrefix(StringRef ArgName, size_t Pad=DefaultPad)
static StringRef ArgHelpPrefix
static bool isWindowsSpecialCharInCommandName(char C)
static Option * getOptionPred(StringRef Name, size_t &Length, bool(*Pred)(const Option *), const StringMap< Option * > &OptionsMap)
static StringRef getValueStr(const Option &O, StringRef DefaultMsg)
static size_t getOptionPrefixesSize()
static bool ProvideOption(Option *Handler, StringRef ArgName, StringRef Value, int argc, const char *const *argv, int &i)
ProvideOption - For Value, this differentiates between an empty value ("") and a null value (StringRe...
static bool isQuote(char C)
static ManagedStatic< CommandLineCommonOptions > CommonOptions
static void initCommonOptions()
static void tokenizeWindowsCommandLineImpl(StringRef Src, StringSaver &Saver, function_ref< void(StringRef)> AddToken, bool AlwaysCopy, function_ref< void()> MarkEOL, bool InitialCommandName)
static bool isWhitespace(char C)
static size_t parseBackslash(StringRef Src, size_t I, SmallString< 128 > &Token)
Backslashes are interpreted in a rather complicated way in the Windows-style command line,...
static StringRef ArgPrefixLong
static void sortSubCommands(const SmallPtrSetImpl< SubCommand * > &SubMap, SmallVectorImpl< std::pair< const char *, SubCommand * > > &Subs)
#define PRINT_OPT_DIFF(T)
static bool isWhitespaceOrNull(char C)
static const size_t MaxOptWidth
static Option * LookupNearestOption(StringRef Arg, const StringMap< Option * > &OptionsMap, std::string &NearestString)
LookupNearestOption - Lookup the closest match to the option specified by the specified option on the...
static bool EatsUnboundedNumberOfValues(const Option *O)
static int OptNameCompare(const std::pair< const char *, Option * > *LHS, const std::pair< const char *, Option * > *RHS)
static void sortOpts(StringMap< Option * > &OptMap, SmallVectorImpl< std::pair< const char *, Option * > > &Opts, bool ShowHidden)
static StringRef ArgPrefix
static bool isWindowsSpecialChar(char C)
static bool isGrouping(const Option *O)
#define LLVM_REQUIRE_CONSTANT_INITIALIZATION
LLVM_REQUIRE_CONSTANT_INITIALIZATION - Apply this to globals to ensure that they are constant initial...
static void Help(ArrayRef< SubtargetSubTypeKV > CPUTable, ArrayRef< SubtargetFeatureKV > FeatTable)
Display help for feature and mcpu choices.
Provides a library for accessing information about this process and other processes on the operating ...
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file defines the SmallPtrSet class.
This file defines the SmallString class.
Defines the virtual file system interface vfs::FileSystem.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
size_t size() const
size - Get the array size.
Allocate memory in an ever growing pool, as if by bump-pointer.
Represents either an error or a value T.
std::error_code getError() const
Lightweight error class with error context and mandatory checking.
static ErrorSuccess success()
Create a success value.
ManagedStatic - This transparently changes the behavior of global statics to be lazily constructed on...
This interface provides simple read-only access to a block of memory, and provides simple methods for...
size_t getBufferSize() const
const char * getBufferEnd() const
const char * getBufferStart() const
A templated base class for SmallPtrSet which provides the typesafe interface that is common across al...
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
void assign(StringRef RHS)
Assign from a StringRef.
void append(StringRef RHS)
Append from a StringRef.
StringRef str() const
Explicit conversion to StringRef.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
void assign(size_type NumElts, ValueParamT Elt)
iterator erase(const_iterator CI)
void append(ItTy in_start, ItTy in_end)
Add the specified range to the end of the SmallVector.
iterator insert(iterator I, T &&Elt)
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
A wrapper around a string literal that serves as a proxy for constructing global tables of StringRefs...
StringMap - This is an unconventional map that is specialized for handling keys that are "strings",...
iterator find(StringRef Key)
size_type count(StringRef Key) const
count - Return 1 if the element is in the map, 0 otherwise.
StringRef - Represent a constant reference to a string, i.e.
std::pair< StringRef, StringRef > split(char Separator) const
Split into two substrings around the first occurrence of a separator character.
bool getAsInteger(unsigned Radix, T &Result) const
Parse the current string as an integer of the specified radix.
constexpr StringRef substr(size_t Start, size_t N=npos) const
Return a reference to the substring from [Start, Start + N).
constexpr bool empty() const
empty - Check if the string is empty.
unsigned edit_distance(StringRef Other, bool AllowReplacements=true, unsigned MaxEditDistance=0) const
Determine the edit distance between this string and another string.
constexpr size_t size() const
size - Get the string size.
size_t find(char C, size_t From=0) const
Search for the first character C in the string.
static constexpr size_t npos
const char * data() const
data - Get a pointer to the start of the string (which may not be null terminated).
Saves strings in the provided stable storage and returns a StringRef with a stable character pointer.
BumpPtrAllocator & getAllocator() const
StringRef save(const char *S)
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
LLVM Value Representation.
Contains options that control response file expansion.
bool findConfigFile(StringRef FileName, SmallVectorImpl< char > &FilePath)
Looks for the specified configuration file.
ExpansionContext(BumpPtrAllocator &A, TokenizerCallback T)
Error expandResponseFiles(SmallVectorImpl< const char * > &Argv)
Expands constructs "@file" in the provided array of arguments recursively.
Error readConfigFile(StringRef CfgFile, SmallVectorImpl< const char * > &Argv)
Reads command line options from the given configuration file.
StringRef getDescription() const
StringRef getName() const
SmallPtrSet< SubCommand *, 1 > Subs
int getNumOccurrences() const
enum ValueExpected getValueExpectedFlag() const
void addCategory(OptionCategory &C)
virtual bool addOccurrence(unsigned pos, StringRef ArgName, StringRef Value, bool MultiArg=false)
void setMiscFlag(enum MiscFlags M)
enum FormattingFlags getFormattingFlag() const
virtual void printOptionInfo(size_t GlobalWidth) const =0
enum NumOccurrencesFlag getNumOccurrencesFlag() const
SmallVector< OptionCategory *, 1 > Categories
bool error(const Twine &Message, StringRef ArgName=StringRef(), raw_ostream &Errs=llvm::errs())
void setArgStr(StringRef S)
bool isDefaultOption() const
unsigned getMiscFlags() const
virtual void setDefault()=0
static void printEnumValHelpStr(StringRef HelpStr, size_t Indent, size_t FirstLineIndentedBy)
unsigned getNumAdditionalVals() const
void removeArgument()
Unregisters this option from the CommandLine system.
static void printHelpStr(StringRef HelpStr, size_t Indent, size_t FirstLineIndentedBy)
StringRef getName() const
SmallVector< Option *, 4 > SinkOpts
static SubCommand & getTopLevel()
void unregisterSubCommand()
static SubCommand & getAll()
void registerSubCommand()
SmallVector< Option *, 4 > PositionalOpts
StringMap< Option * > OptionsMap
StringRef getDescription() const
void printOptionInfo(const Option &O, size_t GlobalWidth) const
virtual StringRef getValueName() const
void printOptionNoValue(const Option &O, size_t GlobalWidth) const
size_t getOptionWidth(const Option &O) const
void printOptionName(const Option &O, size_t GlobalWidth) const
virtual size_t getOptionWidth(const Option &O) const
virtual StringRef getDescription(unsigned N) const =0
virtual const GenericOptionValue & getOptionValue(unsigned N) const =0
virtual unsigned getNumOptions() const =0
virtual StringRef getOption(unsigned N) const =0
void printOptionDiff(const Option &O, const AnyOptionValue &V, const AnyOptionValue &Default, size_t GlobalWidth) const
void printGenericOptionDiff(const Option &O, const GenericOptionValue &V, const GenericOptionValue &Default, size_t GlobalWidth) const
virtual void printOptionInfo(const Option &O, size_t GlobalWidth) const
unsigned findOption(StringRef Name)
bool parse(Option &O, StringRef ArgName, StringRef Arg, DataType &V)
An efficient, type-erasing, non-owning reference to a callable.
A range adaptor for a pair of iterators.
This class implements an extremely fast bulk output stream that can only output to a stream.
raw_ostream & indent(unsigned NumSpaces)
indent - Insert 'NumSpaces' spaces.
static std::optional< std::string > GetEnv(StringRef name)
virtual llvm::ErrorOr< std::string > getCurrentWorkingDirectory() const =0
Get the working directory of this file system.
llvm::ErrorOr< std::unique_ptr< llvm::MemoryBuffer > > getBufferForFile(const Twine &Name, int64_t FileSize=-1, bool RequiresNullTerminator=true, bool IsVolatile=false)
This is a convenience method that opens a file, gets its content and then closes the file.
virtual std::error_code makeAbsolute(SmallVectorImpl< char > &Path) const
Make Path an absolute path.
virtual llvm::ErrorOr< Status > status(const Twine &Path)=0
Get the status of the entry at Path, if one exists.
The result of a status operation.
bool equivalent(const Status &Other) const
void LLVMParseCommandLineOptions(int argc, const char *const *argv, const char *Overview)
This function parses the given arguments using the LLVM command line parser.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
@ C
The default llvm calling convention, compatible with C.
@ SC
CHAIN = SC CHAIN, Imm128 - System call.
constexpr size_t NameSize
std::function< void(raw_ostream &)> VersionPrinterTy
void(*)(StringRef Source, StringSaver &Saver, SmallVectorImpl< const char * > &NewArgv, bool MarkEOLs) TokenizerCallback
String tokenization function type.
void PrintVersionMessage()
Utility function for printing version number.
bool ExpandResponseFiles(StringSaver &Saver, TokenizerCallback Tokenizer, SmallVectorImpl< const char * > &Argv)
A convenience helper which supports the typical use case of expansion function call.
bool expandResponseFiles(int Argc, const char *const *Argv, const char *EnvVar, SmallVectorImpl< const char * > &NewArgv)
A convenience helper which concatenates the options specified by the environment variable EnvVar and ...
void TokenizeWindowsCommandLine(StringRef Source, StringSaver &Saver, SmallVectorImpl< const char * > &NewArgv, bool MarkEOLs=false)
Tokenizes a string of Windows command line arguments, which may contain quotes and escaped quotes.
OptionCategory & getGeneralCategory()
void ResetAllOptionOccurrences()
Reset all command line options to a state that looks as if they have never appeared on the command li...
void SetVersionPrinter(VersionPrinterTy func)
===------------------------------------------------------------------—===// Override the default (LLV...
void tokenizeConfigFile(StringRef Source, StringSaver &Saver, SmallVectorImpl< const char * > &NewArgv, bool MarkEOLs=false)
Tokenizes content of configuration file.
StringMap< Option * > & getRegisteredOptions(SubCommand &Sub=SubCommand::getTopLevel())
Use this to get a StringMap to all registered named options (e.g.
void ResetCommandLineParser()
Reset the command line parser back to its initial state.
bool ParseCommandLineOptions(int argc, const char *const *argv, StringRef Overview="", raw_ostream *Errs=nullptr, const char *EnvVar=nullptr, bool LongOptionsUseDoubleDash=false)
ManagedStatic< SubCommand > TopLevelSubCommand
iterator_range< typename SmallPtrSet< SubCommand *, 4 >::iterator > getRegisteredSubcommands()
Use this to get all registered SubCommands from the provided parser.
void AddLiteralOption(Option &O, StringRef Name)
Adds a new option for parsing and provides the option it refers to.
void TokenizeWindowsCommandLineNoCopy(StringRef Source, StringSaver &Saver, SmallVectorImpl< StringRef > &NewArgv)
Tokenizes a Windows command line while attempting to avoid copies.
bool ProvidePositionalOption(Option *Handler, StringRef Arg, int i)
Parses Arg into the option handler Handler.
initializer< Ty > init(const Ty &Val)
ManagedStatic< SubCommand > AllSubCommands
LocationClass< Ty > location(Ty &L)
void HideUnrelatedOptions(cl::OptionCategory &Category, SubCommand &Sub=SubCommand::getTopLevel())
Mark all options not part of this category as cl::ReallyHidden.
void AddExtraVersionPrinter(VersionPrinterTy func)
===------------------------------------------------------------------—===// Add an extra printer to u...
void PrintHelpMessage(bool Hidden=false, bool Categorized=false)
This function just prints the help message, exactly the same way as if the -help or -help-hidden opti...
void TokenizeWindowsCommandLineFull(StringRef Source, StringSaver &Saver, SmallVectorImpl< const char * > &NewArgv, bool MarkEOLs=false)
Tokenizes a Windows full command line, including command name at the start.
void TokenizeGNUCommandLine(StringRef Source, StringSaver &Saver, SmallVectorImpl< const char * > &NewArgv, bool MarkEOLs=false)
Tokenizes a command line that can contain escapes and quotes.
std::optional< const char * > toString(const std::optional< DWARFFormValue > &V)
Take an optional DWARFFormValue and try to extract a string value from it.
bool has_parent_path(const Twine &path, Style style=Style::native)
Has parent path?
bool is_relative(const Twine &path, Style style=Style::native)
Is path relative?
StringRef filename(StringRef path, Style style=Style::native)
Get filename.
StringRef parent_path(StringRef path, Style style=Style::native)
Get parent path.
bool is_absolute(const Twine &path, Style style=Style::native)
Is path absolute?
void append(SmallVectorImpl< char > &path, const Twine &a, const Twine &b="", const Twine &c="", const Twine &d="")
Append to path.
This is an optimization pass for GlobalISel generic memory operations.
auto drop_begin(T &&RangeOrContainer, size_t N=1)
Return a range covering RangeOrContainer with the first N elements excluded.
void initWithColorOptions()
auto size(R &&Range, std::enable_if_t< std::is_base_of< std::random_access_iterator_tag, typename std::iterator_traits< decltype(Range.begin())>::iterator_category >::value, void > *=nullptr)
Get the size of a range.
raw_fd_ostream & outs()
This returns a reference to a raw_fd_ostream for standard output.
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
bool hasUTF16ByteOrderMark(ArrayRef< char > SrcBytes)
Returns true if a blob of text starts with a UTF-16 big or little endian byte order mark.
void initDebugCounterOptions()
Error createStringError(std::error_code EC, char const *Fmt, const Ts &... Vals)
Create formatted StringError object.
@ no_such_file_or_directory
Printable print(const GCNRegPressure &RP, const GCNSubtarget *ST=nullptr)
decltype(auto) get(const PointerIntPair< PointerTy, IntBits, IntType, PtrTraits, Info > &Pair)
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
bool convertUTF16ToUTF8String(ArrayRef< char > SrcBytes, std::string &Out)
Converts a stream of raw bytes assumed to be UTF16 into a UTF8 std::string.
void initSignalsOptions()
void initTypeSizeOptions()
void initStatisticOptions()
raw_ostream & nulls()
This returns a reference to a raw_ostream which simply discards output.
raw_fd_ostream & errs()
This returns a reference to a raw_ostream for standard error.
void initRandomSeedOptions()
void initGraphWriterOptions()
raw_ostream & operator<<(raw_ostream &OS, const APFixedPoint &FX)
auto count_if(R &&Range, UnaryPredicate P)
Wrapper function around std::count_if to count the number of times an element satisfying a given pred...
bool is_contained(R &&Range, const E &Element)
Returns true if Element is found in Range.
void array_pod_sort(IteratorTy Start, IteratorTy End)
array_pod_sort - This sorts an array with the specified start and end extent.
@ Default
The result values are uniform if and only if all operands are uniform.