#include "llvm/Support/CommandLine.h"
#include "DebugOptions.h"
#include "llvm-c/Support.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/STLFunctionalExtras.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/StringMap.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/Twine.h"
#include "llvm/Config/config.h"
#include "llvm/Support/ConvertUTF.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/ManagedStatic.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/Process.h"
#include "llvm/Support/StringSaver.h"
#include "llvm/Support/VirtualFileSystem.h"
#include "llvm/Support/raw_ostream.h"
#include <cstdlib>
#include <optional>
#include <string>
usingnamespacellvm;
usingnamespacecl;
#define DEBUG_TYPE …
namespace llvm {
namespace cl {
template class basic_parser<bool>;
template class basic_parser<boolOrDefault>;
template class basic_parser<int>;
template class basic_parser<long>;
template class basic_parser<long long>;
template class basic_parser<unsigned>;
template class basic_parser<unsigned long>;
template class basic_parser<unsigned long long>;
template class basic_parser<double>;
template class basic_parser<float>;
template class basic_parser<std::string>;
template class basic_parser<char>;
template class opt<unsigned>;
template class opt<int>;
template class opt<std::string>;
template class opt<char>;
template class opt<bool>;
}
}
void GenericOptionValue::anchor() { … }
void OptionValue<boolOrDefault>::anchor() { … }
void OptionValue<std::string>::anchor() { … }
void Option::anchor() { … }
void basic_parser_impl::anchor() { … }
void parser<bool>::anchor() { … }
void parser<boolOrDefault>::anchor() { … }
void parser<int>::anchor() { … }
void parser<long>::anchor() { … }
void parser<long long>::anchor() { … }
void parser<unsigned>::anchor() { … }
void parser<unsigned long>::anchor() { … }
void parser<unsigned long long>::anchor() { … }
void parser<double>::anchor() { … }
void parser<float>::anchor() { … }
void parser<std::string>::anchor() { … }
void parser<char>::anchor() { … }
const static size_t DefaultPad = …;
static StringRef ArgPrefix = …;
static StringRef ArgPrefixLong = …;
static StringRef ArgHelpPrefix = …;
static size_t argPlusPrefixesSize(StringRef ArgName, size_t Pad = DefaultPad) { … }
static SmallString<8> argPrefix(StringRef ArgName, size_t Pad = DefaultPad) { … }
static inline bool isGrouping(const Option *O) { … }
static inline bool isPrefixedOrGrouping(const Option *O) { … }
namespace {
class PrintArg { … };
raw_ostream &operator<<(raw_ostream &OS, const PrintArg& Arg) { … }
class CommandLineParser { … };
}
static ManagedStatic<CommandLineParser> GlobalParser;
template <typename T, T TrueVal, T FalseVal>
static bool parseBool(Option &O, StringRef ArgName, StringRef Arg, T &Value) { … }
void cl::AddLiteralOption(Option &O, StringRef Name) { … }
extrahelp::extrahelp(StringRef Help) : … { … }
void Option::addArgument() { … }
void Option::removeArgument() { … }
void Option::setArgStr(StringRef S) { … }
void Option::addCategory(OptionCategory &C) { … }
void Option::reset() { … }
void OptionCategory::registerCategory() { … }
LLVM_REQUIRE_CONSTANT_INITIALIZATION
static ManagedStatic<SubCommand> TopLevelSubCommand;
static ManagedStatic<SubCommand> AllSubCommands;
SubCommand &SubCommand::getTopLevel() { … }
SubCommand &SubCommand::getAll() { … }
void SubCommand::registerSubCommand() { … }
void SubCommand::unregisterSubCommand() { … }
void SubCommand::reset() { … }
operator bool()
Option *CommandLineParser::LookupOption(SubCommand &Sub, StringRef &Arg,
StringRef &Value) { … }
SubCommand *CommandLineParser::LookupSubCommand(StringRef Name,
std::string &NearestString) { … }
static Option *LookupNearestOption(StringRef Arg,
const StringMap<Option *> &OptionsMap,
std::string &NearestString) { … }
static bool CommaSeparateAndAddOccurrence(Option *Handler, unsigned pos,
StringRef ArgName, StringRef Value,
bool MultiArg = false) { … }
static inline bool ProvideOption(Option *Handler, StringRef ArgName,
StringRef Value, int argc,
const char *const *argv, int &i) { … }
bool llvm::cl::ProvidePositionalOption(Option *Handler, StringRef Arg, int i) { … }
static Option *getOptionPred(StringRef Name, size_t &Length,
bool (*Pred)(const Option *),
const StringMap<Option *> &OptionsMap) { … }
static Option *
HandlePrefixedOrGroupedOption(StringRef &Arg, StringRef &Value,
bool &ErrorParsing,
const StringMap<Option *> &OptionsMap) { … }
static bool RequiresValue(const Option *O) { … }
static bool EatsUnboundedNumberOfValues(const Option *O) { … }
static bool isWhitespace(char C) { … }
static bool isWhitespaceOrNull(char C) { … }
static bool isQuote(char C) { … }
void cl::TokenizeGNUCommandLine(StringRef Src, StringSaver &Saver,
SmallVectorImpl<const char *> &NewArgv,
bool MarkEOLs) { … }
static size_t parseBackslash(StringRef Src, size_t I, SmallString<128> &Token) { … }
static bool isWindowsSpecialChar(char C) { … }
static bool isWindowsSpecialCharInCommandName(char C) { … }
static inline void tokenizeWindowsCommandLineImpl(
StringRef Src, StringSaver &Saver, function_ref<void(StringRef)> AddToken,
bool AlwaysCopy, function_ref<void()> MarkEOL, bool InitialCommandName) { … }
void cl::TokenizeWindowsCommandLine(StringRef Src, StringSaver &Saver,
SmallVectorImpl<const char *> &NewArgv,
bool MarkEOLs) { … }
void cl::TokenizeWindowsCommandLineNoCopy(StringRef Src, StringSaver &Saver,
SmallVectorImpl<StringRef> &NewArgv) { … }
void cl::TokenizeWindowsCommandLineFull(StringRef Src, StringSaver &Saver,
SmallVectorImpl<const char *> &NewArgv,
bool MarkEOLs) { … }
void cl::tokenizeConfigFile(StringRef Source, StringSaver &Saver,
SmallVectorImpl<const char *> &NewArgv,
bool MarkEOLs) { … }
static bool hasUTF8ByteOrderMark(ArrayRef<char> S) { … }
static void ExpandBasePaths(StringRef BasePath, StringSaver &Saver,
const char *&Arg) { … }
Error ExpansionContext::expandResponseFile(
StringRef FName, SmallVectorImpl<const char *> &NewArgv) { … }
Error ExpansionContext::expandResponseFiles(
SmallVectorImpl<const char *> &Argv) { … }
bool cl::expandResponseFiles(int Argc, const char *const *Argv,
const char *EnvVar, StringSaver &Saver,
SmallVectorImpl<const char *> &NewArgv) { … }
bool cl::ExpandResponseFiles(StringSaver &Saver, TokenizerCallback Tokenizer,
SmallVectorImpl<const char *> &Argv) { … }
ExpansionContext::ExpansionContext(BumpPtrAllocator &A, TokenizerCallback T)
: … { … }
bool ExpansionContext::findConfigFile(StringRef FileName,
SmallVectorImpl<char> &FilePath) { … }
Error ExpansionContext::readConfigFile(StringRef CfgFile,
SmallVectorImpl<const char *> &Argv) { … }
static void initCommonOptions();
bool cl::ParseCommandLineOptions(int argc, const char *const *argv,
StringRef Overview, raw_ostream *Errs,
const char *EnvVar,
bool LongOptionsUseDoubleDash) { … }
void CommandLineParser::ResetAllOptionOccurrences() { … }
bool CommandLineParser::ParseCommandLineOptions(int argc,
const char *const *argv,
StringRef Overview,
raw_ostream *Errs,
bool LongOptionsUseDoubleDash) { … }
bool Option::error(const Twine &Message, StringRef ArgName, raw_ostream &Errs) { … }
bool Option::addOccurrence(unsigned pos, StringRef ArgName, StringRef Value,
bool MultiArg) { … }
static StringRef getValueStr(const Option &O, StringRef DefaultMsg) { … }
size_t alias::getOptionWidth() const { … }
void Option::printHelpStr(StringRef HelpStr, size_t Indent,
size_t FirstLineIndentedBy) { … }
void Option::printEnumValHelpStr(StringRef HelpStr, size_t BaseIndent,
size_t FirstLineIndentedBy) { … }
void alias::printOptionInfo(size_t GlobalWidth) const { … }
size_t basic_parser_impl::getOptionWidth(const Option &O) const { … }
void basic_parser_impl::printOptionInfo(const Option &O,
size_t GlobalWidth) const { … }
void basic_parser_impl::printOptionName(const Option &O,
size_t GlobalWidth) const { … }
bool parser<bool>::parse(Option &O, StringRef ArgName, StringRef Arg,
bool &Value) { … }
bool parser<boolOrDefault>::parse(Option &O, StringRef ArgName, StringRef Arg,
boolOrDefault &Value) { … }
bool parser<int>::parse(Option &O, StringRef ArgName, StringRef Arg,
int &Value) { … }
bool parser<long>::parse(Option &O, StringRef ArgName, StringRef Arg,
long &Value) { … }
bool parser<long long>::parse(Option &O, StringRef ArgName, StringRef Arg,
long long &Value) { … }
bool parser<unsigned>::parse(Option &O, StringRef ArgName, StringRef Arg,
unsigned &Value) { … }
bool parser<unsigned long>::parse(Option &O, StringRef ArgName, StringRef Arg,
unsigned long &Value) { … }
bool parser<unsigned long long>::parse(Option &O, StringRef ArgName,
StringRef Arg,
unsigned long long &Value) { … }
static bool parseDouble(Option &O, StringRef Arg, double &Value) { … }
bool parser<double>::parse(Option &O, StringRef ArgName, StringRef Arg,
double &Val) { … }
bool parser<float>::parse(Option &O, StringRef ArgName, StringRef Arg,
float &Val) { … }
unsigned generic_parser_base::findOption(StringRef Name) { … }
static StringRef EqValue = …;
static StringRef EmptyOption = …;
static StringRef OptionPrefix = …;
static size_t getOptionPrefixesSize() { … }
static bool shouldPrintOption(StringRef Name, StringRef Description,
const Option &O) { … }
size_t generic_parser_base::getOptionWidth(const Option &O) const { … }
void generic_parser_base::printOptionInfo(const Option &O,
size_t GlobalWidth) const { … }
static const size_t MaxOptWidth = …;
void generic_parser_base::printGenericOptionDiff(
const Option &O, const GenericOptionValue &Value,
const GenericOptionValue &Default, size_t GlobalWidth) const { … }
#define PRINT_OPT_DIFF(T) …
PRINT_OPT_DIFF(bool)
PRINT_OPT_DIFF(boolOrDefault)
PRINT_OPT_DIFF(int)
PRINT_OPT_DIFF(long)
PRINT_OPT_DIFF(long long)
PRINT_OPT_DIFF(unsigned)
PRINT_OPT_DIFF(unsigned long)
PRINT_OPT_DIFF(unsigned long long)
PRINT_OPT_DIFF(double)
PRINT_OPT_DIFF(float)
PRINT_OPT_DIFF(char)
void parser<std::string>::printOptionDiff(const Option &O, StringRef V,
const OptionValue<std::string> &D,
size_t GlobalWidth) const { … }
void basic_parser_impl::printOptionNoValue(const Option &O,
size_t GlobalWidth) const { … }
static int OptNameCompare(const std::pair<const char *, Option *> *LHS,
const std::pair<const char *, Option *> *RHS) { … }
static int SubNameCompare(const std::pair<const char *, SubCommand *> *LHS,
const std::pair<const char *, SubCommand *> *RHS) { … }
static void sortOpts(StringMap<Option *> &OptMap,
SmallVectorImpl<std::pair<const char *, Option *>> &Opts,
bool ShowHidden) { … }
static void
sortSubCommands(const SmallPtrSetImpl<SubCommand *> &SubMap,
SmallVectorImpl<std::pair<const char *, SubCommand *>> &Subs) { … }
namespace {
class HelpPrinter { … };
class CategorizedHelpPrinter : public HelpPrinter { … };
class HelpPrinterWrapper { … };
}
#if defined(__GNUC__)
# if defined(__OPTIMIZE__)
#define LLVM_IS_DEBUG_BUILD …
# else
#define LLVM_IS_DEBUG_BUILD …
# endif
#elif defined(_MSC_VER)
# if defined(_DEBUG)
#define LLVM_IS_DEBUG_BUILD …
# else
#define LLVM_IS_DEBUG_BUILD …
# endif
#else
#define LLVM_IS_DEBUG_BUILD …
#endif
namespace {
class VersionPrinter { … };
struct CommandLineCommonOptions { … };
}
static ManagedStatic<CommandLineCommonOptions> CommonOptions;
static void initCommonOptions() { … }
OptionCategory &cl::getGeneralCategory() { … }
void VersionPrinter::operator=(bool OptionWasSpecified) { … }
void HelpPrinterWrapper::operator=(bool Value) { … }
void cl::PrintOptionValues() { … }
void CommandLineParser::printOptionValues() { … }
void cl::PrintHelpMessage(bool Hidden, bool Categorized) { … }
ArrayRef<StringRef> cl::getCompilerBuildConfig() { … }
void cl::printBuildConfig(raw_ostream &OS) { … }
void cl::PrintVersionMessage() { … }
void cl::SetVersionPrinter(VersionPrinterTy func) { … }
void cl::AddExtraVersionPrinter(VersionPrinterTy func) { … }
StringMap<Option *> &cl::getRegisteredOptions(SubCommand &Sub) { … }
iterator_range<typename SmallPtrSet<SubCommand *, 4>::iterator>
cl::getRegisteredSubcommands() { … }
void cl::HideUnrelatedOptions(cl::OptionCategory &Category, SubCommand &Sub) { … }
void cl::HideUnrelatedOptions(ArrayRef<const cl::OptionCategory *> Categories,
SubCommand &Sub) { … }
void cl::ResetCommandLineParser() { … }
void cl::ResetAllOptionOccurrences() { … }
void LLVMParseCommandLineOptions(int argc, const char *const *argv,
const char *Overview) { … }