1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-22 02:33:06 +01:00

Revert "Use ManagedStatic and lazy initialization of cl::opt in libSupport to make it free of global initializer"

This reverts commit 42f588f39c5ce6f521e3709b8871d1fdd076292f.
Broke some buildbots
This commit is contained in:
Mehdi Amini 2021-07-16 03:46:22 +00:00
parent a9a8a9a361
commit 0fd38b8415
32 changed files with 282 additions and 519 deletions

View File

@ -661,7 +661,7 @@ declared, the command line option ``-help-list`` becomes visible which will
print the command line options as uncategorized list.
Note that Options that are not explicitly categorized will be placed in the
``cl::getGeneralCategory()`` category.
``cl::GeneralCategory`` category.
.. _Reference Guide:

View File

@ -71,9 +71,9 @@ class ARMAttributeParser : public ELFAttributeParser {
public:
ARMAttributeParser(ScopedPrinter *sw)
: ELFAttributeParser(sw, ARMBuildAttrs::getARMAttributeTags(), "aeabi") {}
: ELFAttributeParser(sw, ARMBuildAttrs::ARMAttributeTags, "aeabi") {}
ARMAttributeParser()
: ELFAttributeParser(ARMBuildAttrs::getARMAttributeTags(), "aeabi") {}
: ELFAttributeParser(ARMBuildAttrs::ARMAttributeTags, "aeabi") {}
};
}

View File

@ -23,7 +23,7 @@
namespace llvm {
namespace ARMBuildAttrs {
const TagNameMap &getARMAttributeTags();
extern const TagNameMap ARMAttributeTags;
enum SpecialAttr {
// This is for the .cpu asm attr. It translates into one or more

View File

@ -202,7 +202,7 @@ public:
};
// The general Option Category (used as default category).
OptionCategory &getGeneralCategory();
extern OptionCategory GeneralCategory;
//===----------------------------------------------------------------------===//
// SubCommand class
@ -342,7 +342,7 @@ protected:
: NumOccurrences(0), Occurrences(OccurrencesFlag), Value(0),
HiddenFlag(Hidden), Formatting(NormalFormatting), Misc(0),
FullyInitialized(false), Position(0), AdditionalVals(0) {
Categories.push_back(&getGeneralCategory());
Categories.push_back(&GeneralCategory);
}
inline void setNumAdditionalVals(unsigned n) { AdditionalVals = n; }

View File

@ -27,9 +27,9 @@ class RISCVAttributeParser : public ELFAttributeParser {
public:
RISCVAttributeParser(ScopedPrinter *sw)
: ELFAttributeParser(sw, RISCVAttrs::getRISCVAttributeTags(), "riscv") {}
: ELFAttributeParser(sw, RISCVAttrs::RISCVAttributeTags, "riscv") {}
RISCVAttributeParser()
: ELFAttributeParser(RISCVAttrs::getRISCVAttributeTags(), "riscv") {}
: ELFAttributeParser(RISCVAttrs::RISCVAttributeTags, "riscv") {}
};
} // namespace llvm

View File

@ -22,7 +22,7 @@
namespace llvm {
namespace RISCVAttrs {
const TagNameMap &getRISCVAttributeTags();
extern const TagNameMap RISCVAttributeTags;
enum AttrType : unsigned {
// Attribute types in ELF/.riscv.attributes.

View File

@ -32,9 +32,8 @@ template <typename T> struct EnumEntry {
// "Advanced Micro Devices X86-64" on GNU style
StringRef AltName;
T Value;
constexpr EnumEntry(StringRef N, StringRef A, T V)
: Name(N), AltName(A), Value(V) {}
constexpr EnumEntry(StringRef N, T V) : Name(N), AltName(N), Value(V) {}
EnumEntry(StringRef N, StringRef A, T V) : Name(N), AltName(A), Value(V) {}
EnumEntry(StringRef N, T V) : Name(N), AltName(N), Value(V) {}
};
struct HexNumber {

View File

@ -20,7 +20,7 @@ namespace cl {
class OptionCategory;
}
extern cl::OptionCategory &getColorCategory();
extern cl::OptionCategory ColorCategory;
// Symbolic names for various syntax elements.
enum class HighlightColor {

View File

@ -63,7 +63,6 @@ static const TagNameItem tagData[] = {
{ARMBuildAttrs::ABI_align_preserved, "Tag_ABI_align8_preserved"},
};
constexpr TagNameMap ARMAttributeTags{tagData};
const TagNameMap &llvm::ARMBuildAttrs::getARMAttributeTags() {
return ARMAttributeTags;
}
const TagNameMap llvm::ARMBuildAttrs::ARMAttributeTags(tagData,
sizeof(tagData) /
sizeof(TagNameItem));

View File

@ -16,9 +16,6 @@
//===----------------------------------------------------------------------===//
#include "llvm/Support/CommandLine.h"
#include "DebugOptions.h"
#include "llvm-c/Support.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/Optional.h"
@ -465,7 +462,7 @@ void Option::addCategory(OptionCategory &C) {
// Maintain backward compatibility by replacing the default GeneralCategory
// if it's still set. Otherwise, just add the new one. The GeneralCategory
// must be explicitly added if you want multiple categories that include it.
if (&C != &getGeneralCategory() && Categories[0] == &getGeneralCategory())
if (&C != &GeneralCategory && Categories[0] == &GeneralCategory)
Categories[0] = &C;
else if (!is_contained(Categories, &C))
Categories.push_back(&C);
@ -478,6 +475,9 @@ void Option::reset() {
removeArgument();
}
// Initialise the general option category.
OptionCategory llvm::cl::GeneralCategory("General options");
void OptionCategory::registerCategory() {
GlobalParser->registerCategory(this);
}
@ -1293,12 +1293,10 @@ bool cl::readConfigFile(StringRef CfgFile, StringSaver &Saver,
/*MarkEOLs=*/false, /*RelativeNames=*/true);
}
static void initCommonOptions();
bool cl::ParseCommandLineOptions(int argc, const char *const *argv,
StringRef Overview, raw_ostream *Errs,
const char *EnvVar,
bool LongOptionsUseDoubleDash) {
initCommonOptions();
SmallVector<const char *, 20> NewArgv;
BumpPtrAllocator A;
StringSaver Saver(A);
@ -1939,9 +1937,7 @@ unsigned generic_parser_base::findOption(StringRef Name) {
static StringRef EqValue = "=<value>";
static StringRef EmptyOption = "<empty>";
static StringRef OptionPrefix = " =";
static size_t getOptionPrefixesSize() {
return OptionPrefix.size() + ArgHelpPrefix.size();
}
static size_t OptionPrefixesSize = OptionPrefix.size() + ArgHelpPrefix.size();
static bool shouldPrintOption(StringRef Name, StringRef Description,
const Option &O) {
@ -1959,7 +1955,7 @@ size_t generic_parser_base::getOptionWidth(const Option &O) const {
if (!shouldPrintOption(Name, getDescription(i), O))
continue;
size_t NameSize = Name.empty() ? EmptyOption.size() : Name.size();
Size = std::max(Size, NameSize + getOptionPrefixesSize());
Size = std::max(Size, NameSize + OptionPrefixesSize);
}
return Size;
} else {
@ -1998,7 +1994,7 @@ void generic_parser_base::printOptionInfo(const Option &O,
StringRef Description = getDescription(i);
if (!shouldPrintOption(OptionName, Description, O))
continue;
size_t FirstLineIndent = OptionName.size() + getOptionPrefixesSize();
size_t FirstLineIndent = OptionName.size() + OptionPrefixesSize;
outs() << OptionPrefix << OptionName;
if (OptionName.empty()) {
outs() << EmptyOption;
@ -2378,6 +2374,105 @@ public:
} // End anonymous namespace
// Declare the four HelpPrinter instances that are used to print out help, or
// help-hidden as an uncategorized list or in categories.
static HelpPrinter UncategorizedNormalPrinter(false);
static HelpPrinter UncategorizedHiddenPrinter(true);
static CategorizedHelpPrinter CategorizedNormalPrinter(false);
static CategorizedHelpPrinter CategorizedHiddenPrinter(true);
// Declare HelpPrinter wrappers that will decide whether or not to invoke
// a categorizing help printer
static HelpPrinterWrapper WrappedNormalPrinter(UncategorizedNormalPrinter,
CategorizedNormalPrinter);
static HelpPrinterWrapper WrappedHiddenPrinter(UncategorizedHiddenPrinter,
CategorizedHiddenPrinter);
// Define a category for generic options that all tools should have.
static cl::OptionCategory GenericCategory("Generic Options");
// Define uncategorized help printers.
// --help-list is hidden by default because if Option categories are being used
// then --help behaves the same as --help-list.
static cl::opt<HelpPrinter, true, parser<bool>> HLOp(
"help-list",
cl::desc("Display list of available options (--help-list-hidden for more)"),
cl::location(UncategorizedNormalPrinter), cl::Hidden, cl::ValueDisallowed,
cl::cat(GenericCategory), cl::sub(*AllSubCommands));
static cl::opt<HelpPrinter, true, parser<bool>>
HLHOp("help-list-hidden", cl::desc("Display list of all available options"),
cl::location(UncategorizedHiddenPrinter), cl::Hidden,
cl::ValueDisallowed, cl::cat(GenericCategory),
cl::sub(*AllSubCommands));
// Define uncategorized/categorized help printers. These printers change their
// behaviour at runtime depending on whether one or more Option categories have
// been declared.
static cl::opt<HelpPrinterWrapper, true, parser<bool>>
HOp("help", cl::desc("Display available options (--help-hidden for more)"),
cl::location(WrappedNormalPrinter), cl::ValueDisallowed,
cl::cat(GenericCategory), cl::sub(*AllSubCommands));
static cl::alias HOpA("h", cl::desc("Alias for --help"), cl::aliasopt(HOp),
cl::DefaultOption);
static cl::opt<HelpPrinterWrapper, true, parser<bool>>
HHOp("help-hidden", cl::desc("Display all available options"),
cl::location(WrappedHiddenPrinter), cl::Hidden, cl::ValueDisallowed,
cl::cat(GenericCategory), cl::sub(*AllSubCommands));
static cl::opt<bool> PrintOptions(
"print-options",
cl::desc("Print non-default options after command line parsing"),
cl::Hidden, cl::init(false), cl::cat(GenericCategory),
cl::sub(*AllSubCommands));
static cl::opt<bool> PrintAllOptions(
"print-all-options",
cl::desc("Print all option values after command line parsing"), cl::Hidden,
cl::init(false), cl::cat(GenericCategory), cl::sub(*AllSubCommands));
void HelpPrinterWrapper::operator=(bool Value) {
if (!Value)
return;
// Decide which printer to invoke. If more than one option category is
// registered then it is useful to show the categorized help instead of
// uncategorized help.
if (GlobalParser->RegisteredOptionCategories.size() > 1) {
// unhide --help-list option so user can have uncategorized output if they
// want it.
HLOp.setHiddenFlag(NotHidden);
CategorizedPrinter = true; // Invoke categorized printer
} else
UncategorizedPrinter = true; // Invoke uncategorized printer
}
// Print the value of each option.
void cl::PrintOptionValues() { GlobalParser->printOptionValues(); }
void CommandLineParser::printOptionValues() {
if (!PrintOptions && !PrintAllOptions)
return;
SmallVector<std::pair<const char *, Option *>, 128> Opts;
sortOpts(ActiveSubCommand->OptionsMap, Opts, /*ShowHidden*/ true);
// Compute the maximum argument length...
size_t MaxArgLen = 0;
for (size_t i = 0, e = Opts.size(); i != e; ++i)
MaxArgLen = std::max(MaxArgLen, Opts[i].second->getOptionWidth());
for (size_t i = 0, e = Opts.size(); i != e; ++i)
Opts[i].second->printOptionValue(MaxArgLen, PrintAllOptions);
}
static VersionPrinterTy OverrideVersionPrinter = nullptr;
static std::vector<VersionPrinterTy> *ExtraVersionPrinters = nullptr;
#if defined(__GNUC__)
// GCC and GCC-compatible compilers define __OPTIMIZE__ when optimizations are
// enabled.
@ -2433,203 +2528,59 @@ public:
#endif
OS << '\n';
}
void operator=(bool OptionWasSpecified);
};
void operator=(bool OptionWasSpecified) {
if (!OptionWasSpecified)
return;
struct CommandLineCommonOptions {
// Declare the four HelpPrinter instances that are used to print out help, or
// help-hidden as an uncategorized list or in categories.
HelpPrinter UncategorizedNormalPrinter{false};
HelpPrinter UncategorizedHiddenPrinter{true};
CategorizedHelpPrinter CategorizedNormalPrinter{false};
CategorizedHelpPrinter CategorizedHiddenPrinter{true};
// Declare HelpPrinter wrappers that will decide whether or not to invoke
// a categorizing help printer
HelpPrinterWrapper WrappedNormalPrinter{UncategorizedNormalPrinter,
CategorizedNormalPrinter};
HelpPrinterWrapper WrappedHiddenPrinter{UncategorizedHiddenPrinter,
CategorizedHiddenPrinter};
// Define a category for generic options that all tools should have.
cl::OptionCategory GenericCategory{"Generic Options"};
if (OverrideVersionPrinter != nullptr) {
OverrideVersionPrinter(outs());
exit(0);
}
print();
// Define uncategorized help printers.
// --help-list is hidden by default because if Option categories are being
// used then --help behaves the same as --help-list.
cl::opt<HelpPrinter, true, parser<bool>> HLOp{
"help-list",
cl::desc(
"Display list of available options (--help-list-hidden for more)"),
cl::location(UncategorizedNormalPrinter),
cl::Hidden,
cl::ValueDisallowed,
cl::cat(GenericCategory),
cl::sub(*AllSubCommands)};
// Iterate over any registered extra printers and call them to add further
// information.
if (ExtraVersionPrinters != nullptr) {
outs() << '\n';
for (const auto &I : *ExtraVersionPrinters)
I(outs());
}
cl::opt<HelpPrinter, true, parser<bool>> HLHOp{
"help-list-hidden",
cl::desc("Display list of all available options"),
cl::location(UncategorizedHiddenPrinter),
cl::Hidden,
cl::ValueDisallowed,
cl::cat(GenericCategory),
cl::sub(*AllSubCommands)};
// Define uncategorized/categorized help printers. These printers change their
// behaviour at runtime depending on whether one or more Option categories
// have been declared.
cl::opt<HelpPrinterWrapper, true, parser<bool>> HOp{
"help",
cl::desc("Display available options (--help-hidden for more)"),
cl::location(WrappedNormalPrinter),
cl::ValueDisallowed,
cl::cat(GenericCategory),
cl::sub(*AllSubCommands)};
cl::alias HOpA{"h", cl::desc("Alias for --help"), cl::aliasopt(HOp),
cl::DefaultOption};
cl::opt<HelpPrinterWrapper, true, parser<bool>> HHOp{
"help-hidden",
cl::desc("Display all available options"),
cl::location(WrappedHiddenPrinter),
cl::Hidden,
cl::ValueDisallowed,
cl::cat(GenericCategory),
cl::sub(*AllSubCommands)};
cl::opt<bool> PrintOptions{
"print-options",
cl::desc("Print non-default options after command line parsing"),
cl::Hidden,
cl::init(false),
cl::cat(GenericCategory),
cl::sub(*AllSubCommands)};
cl::opt<bool> PrintAllOptions{
"print-all-options",
cl::desc("Print all option values after command line parsing"),
cl::Hidden,
cl::init(false),
cl::cat(GenericCategory),
cl::sub(*AllSubCommands)};
VersionPrinterTy OverrideVersionPrinter = nullptr;
std::vector<VersionPrinterTy> ExtraVersionPrinters;
// Define the --version option that prints out the LLVM version for the tool
VersionPrinter VersionPrinterInstance;
cl::opt<VersionPrinter, true, parser<bool>> VersOp{
"version", cl::desc("Display the version of this program"),
cl::location(VersionPrinterInstance), cl::ValueDisallowed,
cl::cat(GenericCategory)};
exit(0);
}
};
} // End anonymous namespace
// Lazy-initialized global instance of options controlling the command-line
// parser and general handling.
static ManagedStatic<CommandLineCommonOptions> CommonOptions;
// Define the --version option that prints out the LLVM version for the tool
static VersionPrinter VersionPrinterInstance;
static void initCommonOptions() {
*CommonOptions;
initDebugCounterOptions();
initGraphWriterOptions();
initSignalsOptions();
initStatisticOptions();
initTimerOptions();
initTypeSizeOptions();
initWithColorOptions();
initDebugOptions();
initRandomSeedOptions();
}
OptionCategory &cl::getGeneralCategory() {
// Initialise the general option category.
static OptionCategory GeneralCategory{"General options"};
return GeneralCategory;
}
void VersionPrinter::operator=(bool OptionWasSpecified) {
if (!OptionWasSpecified)
return;
if (CommonOptions->OverrideVersionPrinter != nullptr) {
CommonOptions->OverrideVersionPrinter(outs());
exit(0);
}
print();
// Iterate over any registered extra printers and call them to add further
// information.
if (!CommonOptions->ExtraVersionPrinters.empty()) {
outs() << '\n';
for (const auto &I : CommonOptions->ExtraVersionPrinters)
I(outs());
}
exit(0);
}
void HelpPrinterWrapper::operator=(bool Value) {
if (!Value)
return;
// Decide which printer to invoke. If more than one option category is
// registered then it is useful to show the categorized help instead of
// uncategorized help.
if (GlobalParser->RegisteredOptionCategories.size() > 1) {
// unhide --help-list option so user can have uncategorized output if they
// want it.
CommonOptions->HLOp.setHiddenFlag(NotHidden);
CategorizedPrinter = true; // Invoke categorized printer
} else
UncategorizedPrinter = true; // Invoke uncategorized printer
}
// Print the value of each option.
void cl::PrintOptionValues() { GlobalParser->printOptionValues(); }
void CommandLineParser::printOptionValues() {
if (!CommonOptions->PrintOptions && !CommonOptions->PrintAllOptions)
return;
SmallVector<std::pair<const char *, Option *>, 128> Opts;
sortOpts(ActiveSubCommand->OptionsMap, Opts, /*ShowHidden*/ true);
// Compute the maximum argument length...
size_t MaxArgLen = 0;
for (size_t i = 0, e = Opts.size(); i != e; ++i)
MaxArgLen = std::max(MaxArgLen, Opts[i].second->getOptionWidth());
for (size_t i = 0, e = Opts.size(); i != e; ++i)
Opts[i].second->printOptionValue(MaxArgLen, CommonOptions->PrintAllOptions);
}
static cl::opt<VersionPrinter, true, parser<bool>>
VersOp("version", cl::desc("Display the version of this program"),
cl::location(VersionPrinterInstance), cl::ValueDisallowed,
cl::cat(GenericCategory));
// Utility function for printing the help message.
void cl::PrintHelpMessage(bool Hidden, bool Categorized) {
if (!Hidden && !Categorized)
CommonOptions->UncategorizedNormalPrinter.printHelp();
UncategorizedNormalPrinter.printHelp();
else if (!Hidden && Categorized)
CommonOptions->CategorizedNormalPrinter.printHelp();
CategorizedNormalPrinter.printHelp();
else if (Hidden && !Categorized)
CommonOptions->UncategorizedHiddenPrinter.printHelp();
UncategorizedHiddenPrinter.printHelp();
else
CommonOptions->CategorizedHiddenPrinter.printHelp();
CategorizedHiddenPrinter.printHelp();
}
/// Utility function for printing version number.
void cl::PrintVersionMessage() {
CommonOptions->VersionPrinterInstance.print();
}
void cl::PrintVersionMessage() { VersionPrinterInstance.print(); }
void cl::SetVersionPrinter(VersionPrinterTy func) {
CommonOptions->OverrideVersionPrinter = func;
}
void cl::SetVersionPrinter(VersionPrinterTy func) { OverrideVersionPrinter = func; }
void cl::AddExtraVersionPrinter(VersionPrinterTy func) {
CommonOptions->ExtraVersionPrinters.push_back(func);
if (!ExtraVersionPrinters)
ExtraVersionPrinters = new std::vector<VersionPrinterTy>;
ExtraVersionPrinters->push_back(func);
}
StringMap<Option *> &cl::getRegisteredOptions(SubCommand &Sub) {
@ -2645,10 +2596,10 @@ cl::getRegisteredSubcommands() {
}
void cl::HideUnrelatedOptions(cl::OptionCategory &Category, SubCommand &Sub) {
initCommonOptions();
for (auto &I : Sub.OptionsMap) {
for (auto &Cat : I.second->Categories) {
if (Cat != &Category && Cat != &CommonOptions->GenericCategory)
if (Cat != &Category &&
Cat != &GenericCategory)
I.second->setHiddenFlag(cl::ReallyHidden);
}
}
@ -2656,11 +2607,9 @@ void cl::HideUnrelatedOptions(cl::OptionCategory &Category, SubCommand &Sub) {
void cl::HideUnrelatedOptions(ArrayRef<const cl::OptionCategory *> Categories,
SubCommand &Sub) {
initCommonOptions();
for (auto &I : Sub.OptionsMap) {
for (auto &Cat : I.second->Categories) {
if (!is_contained(Categories, Cat) &&
Cat != &CommonOptions->GenericCategory)
if (!is_contained(Categories, Cat) && Cat != &GenericCategory)
I.second->setHiddenFlag(cl::ReallyHidden);
}
}

View File

@ -30,8 +30,6 @@
#include "llvm/Support/circular_raw_ostream.h"
#include "llvm/Support/raw_ostream.h"
#include "DebugOptions.h"
#undef isCurrentDebugType
#undef setCurrentDebugType
#undef setCurrentDebugTypes
@ -81,32 +79,21 @@ void setCurrentDebugTypes(const char **Types, unsigned Count) {
// All Debug.h functionality is a no-op in NDEBUG mode.
#ifndef NDEBUG
namespace {
struct CreateDebug {
static void *call() {
return new cl::opt<bool, true>("debug", cl::desc("Enable debug output"),
cl::Hidden, cl::location(DebugFlag));
}
};
// -debug - Command line option to enable the DEBUG statements in the passes.
// This flag may only be enabled in debug builds.
static cl::opt<bool, true>
Debug("debug", cl::desc("Enable debug output"), cl::Hidden,
cl::location(DebugFlag));
// -debug-buffer-size - Buffer the last N characters of debug output
//until program termination.
struct CreateDebugBufferSize {
static void *call() {
return new cl::opt<unsigned>(
"debug-buffer-size",
cl::desc("Buffer the last N characters of debug output "
"until program termination. "
"[default 0 -- immediate print-out]"),
cl::Hidden, cl::init(0));
}
};
} // namespace
// -debug - Command line option to enable the DEBUG statements in the passes.
// This flag may only be enabled in debug builds.
static ManagedStatic<cl::opt<bool, true>, CreateDebug> Debug;
static ManagedStatic<cl::opt<unsigned>, CreateDebugBufferSize> DebugBufferSize;
static cl::opt<unsigned>
DebugBufferSize("debug-buffer-size",
cl::desc("Buffer the last N characters of debug output "
"until program termination. "
"[default 0 -- immediate print-out]"),
cl::Hidden,
cl::init(0));
namespace {
@ -121,33 +108,15 @@ struct DebugOnlyOpt {
CurrentDebugType->push_back(std::string(dbgType));
}
};
} // namespace
static DebugOnlyOpt DebugOnlyOptLoc;
namespace {
struct CreateDebugOnly {
static void *call() {
return new cl::opt<DebugOnlyOpt, true, cl::parser<std::string>>(
"debug-only",
cl::desc("Enable a specific type of debug output (comma separated list "
"of types)"),
cl::Hidden, cl::ZeroOrMore, cl::value_desc("debug string"),
cl::location(DebugOnlyOptLoc), cl::ValueRequired);
}
};
} // namespace
static ManagedStatic<cl::opt<DebugOnlyOpt, true, cl::parser<std::string>>,
CreateDebugOnly>
DebugOnly;
void llvm::initDebugOptions() {
*Debug;
*DebugBufferSize;
*DebugOnly;
}
static cl::opt<DebugOnlyOpt, true, cl::parser<std::string> >
DebugOnly("debug-only", cl::desc("Enable a specific type of debug output (comma separated list of types)"),
cl::Hidden, cl::ZeroOrMore, cl::value_desc("debug string"),
cl::location(DebugOnlyOptLoc), cl::ValueRequired);
// Signal handlers - dump debug output on termination.
static void debug_user_sig_handler(void *Cookie) {
// This is a bit sneaky. Since this is under #ifndef NDEBUG, we
@ -165,10 +134,10 @@ raw_ostream &llvm::dbgs() {
static struct dbgstream {
circular_raw_ostream strm;
dbgstream()
: strm(errs(), "*** Debug Log Output ***\n",
(!EnableDebugBuffering || !DebugFlag) ? 0 : *DebugBufferSize) {
if (EnableDebugBuffering && DebugFlag && *DebugBufferSize != 0)
dbgstream() :
strm(errs(), "*** Debug Log Output ***\n",
(!EnableDebugBuffering || !DebugFlag) ? 0 : DebugBufferSize) {
if (EnableDebugBuffering && DebugFlag && DebugBufferSize != 0)
// TODO: Add a handler for SIGUSER1-type signals so the user can
// force a debug dump.
sys::AddSignalHandler(&debug_user_sig_handler, nullptr);

View File

@ -1,7 +1,4 @@
#include "llvm/Support/DebugCounter.h"
#include "DebugOptions.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Format.h"
#include "llvm/Support/ManagedStatic.h"
@ -43,29 +40,17 @@ private:
}
}
};
struct CreateDebugCounterOption {
static void *call() {
return new DebugCounterList(
"debug-counter", cl::Hidden,
cl::desc("Comma separated list of debug counter skip and count"),
cl::CommaSeparated, cl::ZeroOrMore,
cl::location(DebugCounter::instance()));
}
};
} // namespace
static ManagedStatic<DebugCounterList, CreateDebugCounterOption>
DebugCounterOption;
static bool PrintDebugCounter;
// Create our command line option.
static DebugCounterList DebugCounterOption(
"debug-counter", cl::Hidden,
cl::desc("Comma separated list of debug counter skip and count"),
cl::CommaSeparated, cl::ZeroOrMore, cl::location(DebugCounter::instance()));
void llvm::initDebugCounterOptions() {
*DebugCounterOption;
static cl::opt<bool, true> RegisterPrintDebugCounter(
"print-debug-counter", cl::Hidden, cl::location(PrintDebugCounter),
cl::init(false), cl::Optional,
cl::desc("Print out debug counter info after all counters accumulated"));
}
static cl::opt<bool> PrintDebugCounter(
"print-debug-counter", cl::Hidden, cl::init(false), cl::Optional,
cl::desc("Print out debug counter info after all counters accumulated"));
static ManagedStatic<DebugCounter> DC;

View File

@ -1,29 +0,0 @@
//===-- DebugOptions.h - Global Command line opt for libSupport *- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
// This file defines the entry point to initialize the options registered on the
// command line for libSupport, this is internal to libSupport.
//
//===----------------------------------------------------------------------===//
namespace llvm {
// These are invoked internally before parsing command line options.
// This enables lazy-initialization of all the globals in libSupport, instead
// of eagerly loading everything on program startup.
void initDebugCounterOptions();
void initGraphWriterOptions();
void initSignalsOptions();
void initStatisticOptions();
void initTimerOptions();
void initTypeSizeOptions();
void initWithColorOptions();
void initDebugOptions();
void initRandomSeedOptions();
} // namespace llvm

View File

@ -16,7 +16,7 @@
using namespace llvm;
using namespace llvm::ELFAttrs;
static constexpr EnumEntry<unsigned> tagNames[] = {
static const EnumEntry<unsigned> tagNames[] = {
{"Tag_File", ELFAttrs::File},
{"Tag_Section", ELFAttrs::Section},
{"Tag_Symbol", ELFAttrs::Symbol},

View File

@ -11,9 +11,6 @@
//===----------------------------------------------------------------------===//
#include "llvm/Support/GraphWriter.h"
#include "DebugOptions.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringRef.h"
@ -32,21 +29,8 @@
using namespace llvm;
#ifdef __APPLE__
namespace {
struct CreateViewBackground {
static void *call() {
return new cl::opt<bool>("view-background", cl::Hidden,
cl::desc("Execute graph viewer in the background. "
"Creates tmp file litter."));
}
};
} // namespace
static ManagedStatic<cl::opt<bool>, CreateViewBackground> ViewBackground;
void llvm::initGraphWriterOptions() { *ViewBackground; }
#else
void llvm::initGraphWriterOptions() {}
#endif
static cl::opt<bool> ViewBackground("view-background", cl::Hidden,
cl::desc("Execute graph viewer in the background. Creates tmp file litter."));
std::string llvm::DOT::EscapeString(const std::string &Label) {
std::string Str(Label);

View File

@ -11,7 +11,7 @@
using namespace llvm;
using namespace llvm::RISCVAttrs;
static constexpr TagNameItem tagData[] = {
static const TagNameItem tagData[] = {
{STACK_ALIGN, "Tag_stack_align"},
{ARCH, "Tag_arch"},
{UNALIGNED_ACCESS, "Tag_unaligned_access"},
@ -20,7 +20,6 @@ static constexpr TagNameItem tagData[] = {
{PRIV_SPEC_REVISION, "Tag_priv_spec_revision"},
};
constexpr TagNameMap RISCVAttributeTags{tagData};
const TagNameMap &llvm::RISCVAttrs::getRISCVAttributeTags() {
return RISCVAttributeTags;
}
const TagNameMap llvm::RISCVAttrs::RISCVAttributeTags(tagData,
sizeof(tagData) /
sizeof(TagNameItem));

View File

@ -13,9 +13,6 @@
//===----------------------------------------------------------------------===//
#include "llvm/Support/RandomNumberGenerator.h"
#include "DebugOptions.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/raw_ostream.h"
@ -28,20 +25,13 @@
using namespace llvm;
#define DEBUG_TYPE "rng"
namespace {
struct CreateSeed {
static void *call() {
return new cl::opt<uint64_t>(
"rng-seed", cl::value_desc("seed"), cl::Hidden,
cl::desc("Seed for the random number generator"), cl::init(0));
}
};
} // namespace
static ManagedStatic<cl::opt<uint64_t>, CreateSeed> Seed;
void llvm::initRandomSeedOptions() { *Seed; }
static cl::opt<uint64_t> Seed("rng-seed", cl::value_desc("seed"), cl::Hidden,
cl::desc("Seed for the random number generator"),
cl::init(0));
RandomNumberGenerator::RandomNumberGenerator(StringRef Salt) {
LLVM_DEBUG(if (*Seed == 0) dbgs()
LLVM_DEBUG(if (Seed == 0) dbgs()
<< "Warning! Using unseeded random number generator.\n");
// Combine seed and salts using std::seed_seq.
@ -51,8 +41,8 @@ RandomNumberGenerator::RandomNumberGenerator(StringRef Salt) {
// twister constructor copies these correctly into its initial state.
std::vector<uint32_t> Data;
Data.resize(2 + Salt.size());
Data[0] = *Seed;
Data[1] = *Seed >> 32;
Data[0] = Seed;
Data[1] = Seed >> 32;
llvm::copy(Salt, Data.begin() + 2);

View File

@ -12,9 +12,6 @@
//===----------------------------------------------------------------------===//
#include "llvm/Support/Signals.h"
#include "DebugOptions.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Config/llvm-config.h"
@ -42,33 +39,15 @@ using namespace llvm;
// Use explicit storage to avoid accessing cl::opt in a signal handler.
static bool DisableSymbolicationFlag = false;
static ManagedStatic<std::string> CrashDiagnosticsDirectory;
namespace {
struct CreateDisableSymbolication {
static void *call() {
return new cl::opt<bool, true>(
"disable-symbolication",
cl::desc("Disable symbolizing crash backtraces."),
cl::location(DisableSymbolicationFlag), cl::Hidden);
}
};
struct CreateCrashDiagnosticsDir {
static void *call() {
return new cl::opt<std::string, true>(
"crash-diagnostics-dir", cl::value_desc("directory"),
cl::desc("Directory for crash diagnostic files."),
cl::location(*CrashDiagnosticsDirectory), cl::Hidden);
}
};
} // namespace
void llvm::initSignalsOptions() {
static ManagedStatic<cl::opt<bool, true>, CreateDisableSymbolication>
DisableSymbolication;
static ManagedStatic<cl::opt<std::string, true>, CreateCrashDiagnosticsDir>
CrashDiagnosticsDir;
*DisableSymbolication;
*CrashDiagnosticsDir;
}
static cl::opt<bool, true>
DisableSymbolication("disable-symbolication",
cl::desc("Disable symbolizing crash backtraces."),
cl::location(DisableSymbolicationFlag), cl::Hidden);
static std::string CrashDiagnosticsDirectory;
static cl::opt<std::string, true>
CrashDiagnosticsDir("crash-diagnostics-dir", cl::value_desc("directory"),
cl::desc("Directory for crash diagnostic files."),
cl::location(CrashDiagnosticsDirectory), cl::Hidden);
constexpr char DisableSymbolizationEnv[] = "LLVM_DISABLE_SYMBOLIZATION";
constexpr char LLVMSymbolizerPathEnv[] = "LLVM_SYMBOLIZER_PATH";

View File

@ -21,9 +21,6 @@
//===----------------------------------------------------------------------===//
#include "llvm/ADT/Statistic.h"
#include "DebugOptions.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Compiler.h"
@ -41,22 +38,18 @@ using namespace llvm;
/// -stats - Command line option to cause transformations to emit stats about
/// what they did.
///
static bool EnableStats;
static bool StatsAsJSON;
static cl::opt<bool> EnableStats(
"stats",
cl::desc("Enable statistics output from program (available with Asserts)"),
cl::Hidden);
static cl::opt<bool> StatsAsJSON("stats-json",
cl::desc("Display statistics as json data"),
cl::Hidden);
static bool Enabled;
static bool PrintOnExit;
void llvm::initStatisticOptions() {
static cl::opt<bool, true> registerEnableStats{
"stats",
cl::desc(
"Enable statistics output from program (available with Asserts)"),
cl::location(EnableStats), cl::Hidden};
static cl::opt<bool, true> registerStatsAsJson{
"stats-json", cl::desc("Display statistics as json data"),
cl::location(StatsAsJSON), cl::Hidden};
}
namespace {
/// This class is used in a ManagedStatic so that it is created on demand (when
/// the first statistic is bumped) and destroyed only when llvm_shutdown is
@ -135,7 +128,9 @@ void llvm::EnableStatistics(bool DoPrintOnExit) {
PrintOnExit = DoPrintOnExit;
}
bool llvm::AreStatisticsEnabled() { return Enabled || EnableStats; }
bool llvm::AreStatisticsEnabled() {
return Enabled || EnableStats;
}
void StatisticInfo::sort() {
llvm::stable_sort(

View File

@ -30,7 +30,7 @@ using namespace llvm;
static std::mutex Mu;
// List of all instances
static ManagedStatic<std::vector<TimeTraceProfiler *>>
static std::vector<TimeTraceProfiler *>
ThreadTimeTraceProfilerInstances; // GUARDED_BY(Mu)
// Per Thread instance
static LLVM_THREAD_LOCAL TimeTraceProfiler *TimeTraceProfilerInstance = nullptr;
@ -128,7 +128,7 @@ struct llvm::TimeTraceProfiler {
std::lock_guard<std::mutex> Lock(Mu);
assert(Stack.empty() &&
"All profiler sections should be ended when calling write");
assert(llvm::all_of(*ThreadTimeTraceProfilerInstances,
assert(llvm::all_of(ThreadTimeTraceProfilerInstances,
[](const auto &TTP) { return TTP->Stack.empty(); }) &&
"All profiler sections should be ended when calling write");
@ -156,7 +156,7 @@ struct llvm::TimeTraceProfiler {
};
for (const Entry &E : Entries)
writeEvent(E, this->Tid);
for (const TimeTraceProfiler *TTP : *ThreadTimeTraceProfilerInstances)
for (const TimeTraceProfiler *TTP : ThreadTimeTraceProfilerInstances)
for (const Entry &E : TTP->Entries)
writeEvent(E, TTP->Tid);
@ -164,7 +164,7 @@ struct llvm::TimeTraceProfiler {
// longest one.
// Find highest used thread id.
uint64_t MaxTid = this->Tid;
for (const TimeTraceProfiler *TTP : *ThreadTimeTraceProfilerInstances)
for (const TimeTraceProfiler *TTP : ThreadTimeTraceProfilerInstances)
MaxTid = std::max(MaxTid, TTP->Tid);
// Combine all CountAndTotalPerName from threads into one.
@ -178,7 +178,7 @@ struct llvm::TimeTraceProfiler {
};
for (const auto &Stat : CountAndTotalPerName)
combineStat(Stat);
for (const TimeTraceProfiler *TTP : *ThreadTimeTraceProfilerInstances)
for (const TimeTraceProfiler *TTP : ThreadTimeTraceProfilerInstances)
for (const auto &Stat : TTP->CountAndTotalPerName)
combineStat(Stat);
@ -229,7 +229,7 @@ struct llvm::TimeTraceProfiler {
writeMetadataEvent("process_name", Tid, ProcName);
writeMetadataEvent("thread_name", Tid, ThreadName);
for (const TimeTraceProfiler *TTP : *ThreadTimeTraceProfilerInstances)
for (const TimeTraceProfiler *TTP : ThreadTimeTraceProfilerInstances)
writeMetadataEvent("thread_name", TTP->Tid, TTP->ThreadName);
J.arrayEnd();
@ -273,16 +273,16 @@ void llvm::timeTraceProfilerInitialize(unsigned TimeTraceGranularity,
void llvm::timeTraceProfilerCleanup() {
delete TimeTraceProfilerInstance;
std::lock_guard<std::mutex> Lock(Mu);
for (auto TTP : *ThreadTimeTraceProfilerInstances)
for (auto TTP : ThreadTimeTraceProfilerInstances)
delete TTP;
ThreadTimeTraceProfilerInstances->clear();
ThreadTimeTraceProfilerInstances.clear();
}
// Finish TimeTraceProfilerInstance on a worker thread.
// This doesn't remove the instance, just moves the pointer to global vector.
void llvm::timeTraceProfilerFinishThread() {
std::lock_guard<std::mutex> Lock(Mu);
ThreadTimeTraceProfilerInstances->push_back(TimeTraceProfilerInstance);
ThreadTimeTraceProfilerInstances.push_back(TimeTraceProfilerInstance);
TimeTraceProfilerInstance = nullptr;
}

View File

@ -11,9 +11,6 @@
//===----------------------------------------------------------------------===//
#include "llvm/Support/Timer.h"
#include "DebugOptions.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/ADT/StringMap.h"
#include "llvm/Config/config.h"
@ -56,41 +53,20 @@ static ManagedStatic<sys::SmartMutex<true> > TimerLock;
static ManagedStatic<SignpostEmitter> Signposts;
namespace {
struct CreateTrackSpace {
static void *call() {
return new cl::opt<bool>("track-memory",
cl::desc("Enable -time-passes memory "
static cl::opt<bool>
TrackSpace("track-memory", cl::desc("Enable -time-passes memory "
"tracking (this may be slow)"),
cl::Hidden);
}
};
static ManagedStatic<cl::opt<bool>, CreateTrackSpace> TrackSpace;
struct CreateInfoOutputFilename {
static void *call() {
return new cl::opt<std::string, true>(
"info-output-file", cl::value_desc("filename"),
cl::desc("File to append -stats and -timer output to"), cl::Hidden,
cl::location(getLibSupportInfoOutputFilename()));
}
};
static ManagedStatic<cl::opt<std::string, true>, CreateInfoOutputFilename>
InfoOutputFilename;
struct CreateSortTimers {
static void *call() {
return new cl::opt<bool>(
"sort-timers",
cl::desc("In the report, sort the timers in each group "
"in wall clock time order"),
cl::init(true), cl::Hidden);
}
};
ManagedStatic<cl::opt<bool>, CreateSortTimers> SortTimers;
} // namespace
cl::Hidden);
void llvm::initTimerOptions() {
*TrackSpace;
*InfoOutputFilename;
*SortTimers;
static cl::opt<std::string, true>
InfoOutputFilename("info-output-file", cl::value_desc("filename"),
cl::desc("File to append -stats and -timer output to"),
cl::Hidden, cl::location(getLibSupportInfoOutputFilename()));
static cl::opt<bool>
SortTimers("sort-timers", cl::desc("In the report, sort the timers in each group "
"in wall clock time order"),
cl::init(true), cl::Hidden);
}
std::unique_ptr<raw_fd_ostream> llvm::CreateInfoOutputFile() {
@ -149,8 +125,7 @@ Timer::~Timer() {
}
static inline size_t getMemUsage() {
if (!*TrackSpace)
return 0;
if (!TrackSpace) return 0;
return sys::Process::GetMallocUsage();
}
@ -356,7 +331,7 @@ void TimerGroup::addTimer(Timer &T) {
void TimerGroup::PrintQueuedTimers(raw_ostream &OS) {
// Perhaps sort the timers in descending order by amount of time taken.
if (*SortTimers)
if (SortTimers)
llvm::sort(TimersToPrint);
TimeRecord Total;

View File

@ -9,35 +9,19 @@
#include "llvm/Support/TypeSize.h"
#include "llvm/Support/CommandLine.h"
#include "DebugOptions.h"
using namespace llvm;
#ifndef STRICT_FIXED_SIZE_VECTORS
namespace {
struct CreateScalableErrorAsWarning {
/// The ScalableErrorAsWarning is a temporary measure to suppress errors from
/// using the wrong interface on a scalable vector.
static void *call() {
return new cl::opt<bool>(
"treat-scalable-fixed-error-as-warning", cl::Hidden, cl::init(false),
cl::desc(
"Treat issues where a fixed-width property is requested from a "
"scalable type as a warning, instead of an error."),
cl::ZeroOrMore);
}
};
} // namespace
static ManagedStatic<cl::opt<bool>, CreateScalableErrorAsWarning>
ScalableErrorAsWarning;
void llvm::initTypeSizeOptions() { *ScalableErrorAsWarning; }
#else
void llvm::initTypeSizeOptions() {}
#endif
/// The ScalableErrorAsWarning is a temporary measure to suppress errors from
/// using the wrong interface on a scalable vector.
cl::opt<bool> ScalableErrorAsWarning(
"treat-scalable-fixed-error-as-warning", cl::Hidden, cl::init(false),
cl::desc("Treat issues where a fixed-width property is requested from a "
"scalable type as a warning, instead of an error."),
cl::ZeroOrMore);
void llvm::reportInvalidSizeRequest(const char *Msg) {
#ifndef STRICT_FIXED_SIZE_VECTORS
if (*ScalableErrorAsWarning) {
if (ScalableErrorAsWarning) {
WithColor::warning() << "Invalid size request on a scalable vector; " << Msg
<< "\n";
return;

View File

@ -773,7 +773,7 @@ WriteWindowsDumpFile(PMINIDUMP_EXCEPTION_INFORMATION ExceptionInfo) {
// (GetDumpFolder will return false either if the key is NULL or if there is
// no valid DumpFolder value at its location).
bool ExplicitDumpDirectorySet = true;
SmallString<MAX_PATH> DumpDirectory(*CrashDiagnosticsDirectory);
SmallString<MAX_PATH> DumpDirectory(CrashDiagnosticsDirectory);
if (DumpDirectory.empty())
if (!GetDumpFolder(AppSpecificKey, DumpDirectory))
if (!GetDumpFolder(DefaultLocalDumpsKey, DumpDirectory))

View File

@ -7,31 +7,17 @@
//===----------------------------------------------------------------------===//
#include "llvm/Support/WithColor.h"
#include "DebugOptions.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/ManagedStatic.h"
using namespace llvm;
cl::OptionCategory &llvm::getColorCategory() {
static cl::OptionCategory ColorCategory("Color Options");
return ColorCategory;
}
namespace {
struct CreateUseColor {
static void *call() {
return new cl::opt<cl::boolOrDefault>(
"color", cl::cat(getColorCategory()),
cl::desc("Use colors in output (default=autodetect)"),
cl::init(cl::BOU_UNSET));
}
};
} // namespace
static ManagedStatic<cl::opt<cl::boolOrDefault>, CreateUseColor> UseColor;
void llvm::initWithColorOptions() { *UseColor; }
cl::OptionCategory llvm::ColorCategory("Color Options");
static cl::opt<cl::boolOrDefault>
UseColor("color", cl::cat(ColorCategory),
cl::desc("Use colors in output (default=autodetect)"),
cl::init(cl::BOU_UNSET));
WithColor::WithColor(raw_ostream &OS, HighlightColor Color, ColorMode Mode)
: OS(OS), Mode(Mode) {
@ -127,8 +113,8 @@ bool WithColor::colorsEnabled() {
case ColorMode::Disable:
return false;
case ColorMode::Auto:
return *UseColor == cl::BOU_UNSET ? OS.has_colors()
: *UseColor == cl::BOU_TRUE;
return UseColor == cl::BOU_UNSET ? OS.has_colors()
: UseColor == cl::BOU_TRUE;
}
llvm_unreachable("All cases handled above.");
}

View File

@ -11325,8 +11325,8 @@ bool ARMAsmParser::parseDirectiveEabiAttr(SMLoc L) {
TagLoc = Parser.getTok().getLoc();
if (Parser.getTok().is(AsmToken::Identifier)) {
StringRef Name = Parser.getTok().getIdentifier();
Optional<unsigned> Ret = ELFAttrs::attrTypeFromString(
Name, ARMBuildAttrs::getARMAttributeTags());
Optional<unsigned> Ret =
ELFAttrs::attrTypeFromString(Name, ARMBuildAttrs::ARMAttributeTags);
if (!Ret.hasValue()) {
Error(TagLoc, "attribute name not recognised: " + Name);
return false;

View File

@ -176,8 +176,8 @@ void ARMTargetAsmStreamer::switchVendor(StringRef Vendor) {}
void ARMTargetAsmStreamer::emitAttribute(unsigned Attribute, unsigned Value) {
OS << "\t.eabi_attribute\t" << Attribute << ", " << Twine(Value);
if (IsVerboseAsm) {
StringRef Name = ELFAttrs::attrTypeAsString(
Attribute, ARMBuildAttrs::getARMAttributeTags());
StringRef Name =
ELFAttrs::attrTypeAsString(Attribute, ARMBuildAttrs::ARMAttributeTags);
if (!Name.empty())
OS << "\t@ " << Name;
}
@ -194,7 +194,7 @@ void ARMTargetAsmStreamer::emitTextAttribute(unsigned Attribute,
OS << "\t.eabi_attribute\t" << Attribute << ", \"" << String << "\"";
if (IsVerboseAsm) {
StringRef Name = ELFAttrs::attrTypeAsString(
Attribute, ARMBuildAttrs::getARMAttributeTags());
Attribute, ARMBuildAttrs::ARMAttributeTags);
if (!Name.empty())
OS << "\t@ " << Name;
}
@ -215,7 +215,7 @@ void ARMTargetAsmStreamer::emitIntTextAttribute(unsigned Attribute,
if (IsVerboseAsm)
OS << "\t@ "
<< ELFAttrs::attrTypeAsString(Attribute,
ARMBuildAttrs::getARMAttributeTags());
ARMBuildAttrs::ARMAttributeTags);
break;
}
OS << "\n";

View File

@ -1970,7 +1970,7 @@ bool RISCVAsmParser::parseDirectiveAttribute() {
if (Parser.getTok().is(AsmToken::Identifier)) {
StringRef Name = Parser.getTok().getIdentifier();
Optional<unsigned> Ret =
ELFAttrs::attrTypeFromString(Name, RISCVAttrs::getRISCVAttributeTags());
ELFAttrs::attrTypeFromString(Name, RISCVAttrs::RISCVAttributeTags);
if (!Ret.hasValue()) {
Error(TagLoc, "attribute name not recognised: " + Name);
return false;

View File

@ -623,8 +623,7 @@ int main(int argc, char **argv) {
llvm::InitializeAllTargetInfos();
llvm::InitializeAllTargetMCs();
HideUnrelatedOptions(
{&DwarfDumpCategory, &SectionCategory, &getColorCategory()});
HideUnrelatedOptions({&DwarfDumpCategory, &SectionCategory, &ColorCategory});
cl::ParseCommandLineOptions(
argc, argv,
"pretty-print DWARF debug information in object files"

View File

@ -571,7 +571,7 @@ static Expected<Config> parseCommandLine(int Argc, char **Argv) {
int main(int Argc, char **Argv) {
InitLLVM X(Argc, Argv);
cl::HideUnrelatedOptions({&LibtoolCategory, &getColorCategory()});
cl::HideUnrelatedOptions({&LibtoolCategory, &ColorCategory});
Expected<Config> ConfigOrErr = parseCommandLine(Argc, Argv);
if (!ConfigOrErr) {
WithColor::defaultErrorHandler(ConfigOrErr.takeError());

View File

@ -48,7 +48,7 @@ void testParseError(ArrayRef<uint8_t> bytes, const char *msg) {
}
bool testTagString(unsigned Tag, const char *name) {
return ELFAttrs::attrTypeAsString(Tag, ARMBuildAttrs::getARMAttributeTags())
return ELFAttrs::attrTypeAsString(Tag, ARMBuildAttrs::ARMAttributeTags)
.str() == name;
}

View File

@ -110,7 +110,7 @@ TEST(CommandLineTest, ModifyExisitingOption) {
ASSERT_NE(Retrieved->Categories.end(),
find_if(Retrieved->Categories,
[&](const llvm::cl::OptionCategory *Cat) {
return Cat == &cl::getGeneralCategory();
return Cat == &cl::GeneralCategory;
}))
<< "Incorrect default option category.";
@ -152,10 +152,10 @@ TEST(CommandLineTest, UseOptionCategory) {
TEST(CommandLineTest, UseMultipleCategories) {
StackOption<int> TestOption2("test-option2", cl::cat(TestCategory),
cl::cat(cl::getGeneralCategory()),
cl::cat(cl::getGeneralCategory()));
cl::cat(cl::GeneralCategory),
cl::cat(cl::GeneralCategory));
// Make sure cl::getGeneralCategory() wasn't added twice.
// Make sure cl::GeneralCategory wasn't added twice.
ASSERT_EQ(TestOption2.Categories.size(), 2U);
ASSERT_NE(TestOption2.Categories.end(),
@ -166,9 +166,9 @@ TEST(CommandLineTest, UseMultipleCategories) {
<< "Failed to assign Option Category.";
ASSERT_NE(TestOption2.Categories.end(),
find_if(TestOption2.Categories,
[&](const llvm::cl::OptionCategory *Cat) {
return Cat == &cl::getGeneralCategory();
}))
[&](const llvm::cl::OptionCategory *Cat) {
return Cat == &cl::GeneralCategory;
}))
<< "Failed to assign General Category.";
cl::OptionCategory AnotherCategory("Additional test Options", "Description");
@ -176,9 +176,9 @@ TEST(CommandLineTest, UseMultipleCategories) {
cl::cat(AnotherCategory));
ASSERT_EQ(TestOption.Categories.end(),
find_if(TestOption.Categories,
[&](const llvm::cl::OptionCategory *Cat) {
return Cat == &cl::getGeneralCategory();
}))
[&](const llvm::cl::OptionCategory *Cat) {
return Cat == &cl::GeneralCategory;
}))
<< "Failed to remove General Category.";
ASSERT_NE(TestOption.Categories.end(),
find_if(TestOption.Categories,

View File

@ -49,7 +49,7 @@ static bool testAttribute(unsigned Tag, unsigned Value, unsigned ExpectedTag,
}
static bool testTagString(unsigned Tag, const char *name) {
return ELFAttrs::attrTypeAsString(Tag, RISCVAttrs::getRISCVAttributeTags())
return ELFAttrs::attrTypeAsString(Tag, RISCVAttrs::RISCVAttributeTags)
.str() == name;
}