Skip to content

Commit

Permalink
Revert "Use ManagedStatic and lazy initialization of cl::opt in libSu…
Browse files Browse the repository at this point in the history
…pport to make it free of global initializer"

This reverts commit 42f588f.
Broke some buildbots
  • Loading branch information
joker-eph committed Jul 16, 2021
1 parent 42f588f commit 16b5e9d
Show file tree
Hide file tree
Showing 35 changed files with 288 additions and 525 deletions.
2 changes: 1 addition & 1 deletion clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class Command {
// By resetting the parser options, we lost the standard -help flag.
llvm::cl::opt<bool, false, llvm::cl::parser<bool>> Help{
"help", llvm::cl::desc("Display available options"),
llvm::cl::ValueDisallowed, llvm::cl::cat(llvm::cl::getGeneralCategory())};
llvm::cl::ValueDisallowed, llvm::cl::cat(llvm::cl::GeneralCategory)};
// FIXME: Allow commands to signal failure.
virtual void run() = 0;

Expand Down
2 changes: 1 addition & 1 deletion clang-tools-extra/clangd/indexer/IndexerMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ int main(int argc, const char **argv) {
)";

auto Executor = clang::tooling::createExecutorFromCommandLineArgs(
argc, argv, llvm::cl::getGeneralCategory(), Overview);
argc, argv, llvm::cl::GeneralCategory, Overview);

if (!Executor) {
llvm::errs() << llvm::toString(Executor.takeError()) << "\n";
Expand Down
6 changes: 3 additions & 3 deletions clang/tools/clang-refactor/ClangRefactor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ namespace opts {
static cl::OptionCategory CommonRefactorOptions("Refactoring options");

static cl::opt<bool> Verbose("v", cl::desc("Use verbose output"),
cl::cat(cl::getGeneralCategory()),
cl::cat(cl::GeneralCategory),
cl::sub(*cl::AllSubCommands));

static cl::opt<bool> Inplace("i", cl::desc("Inplace edit <file>s"),
cl::cat(cl::getGeneralCategory()),
cl::cat(cl::GeneralCategory),
cl::sub(*cl::AllSubCommands));

} // end namespace opts
Expand Down Expand Up @@ -613,7 +613,7 @@ int main(int argc, const char **argv) {
ClangRefactorTool RefactorTool;

auto ExpectedParser = CommonOptionsParser::create(
argc, argv, cl::getGeneralCategory(), cl::ZeroOrMore,
argc, argv, cl::GeneralCategory, cl::ZeroOrMore,
"Clang-based refactoring tool for C, C++ and Objective-C");
if (!ExpectedParser) {
llvm::errs() << ExpectedParser.takeError();
Expand Down
2 changes: 1 addition & 1 deletion llvm/docs/CommandLine.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
4 changes: 2 additions & 2 deletions llvm/include/llvm/Support/ARMAttributeParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -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") {}
};
}

Expand Down
2 changes: 1 addition & 1 deletion llvm/include/llvm/Support/ARMBuildAttributes.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions llvm/include/llvm/Support/CommandLine.h
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ class OptionCategory {
};

// The general Option Category (used as default category).
OptionCategory &getGeneralCategory();
extern OptionCategory GeneralCategory;

//===----------------------------------------------------------------------===//
// SubCommand class
Expand Down Expand Up @@ -342,7 +342,7 @@ class Option {
: 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; }
Expand Down
4 changes: 2 additions & 2 deletions llvm/include/llvm/Support/RISCVAttributeParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion llvm/include/llvm/Support/RISCVAttributes.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
namespace llvm {
namespace RISCVAttrs {

const TagNameMap &getRISCVAttributeTags();
extern const TagNameMap RISCVAttributeTags;

enum AttrType : unsigned {
// Attribute types in ELF/.riscv.attributes.
Expand Down
5 changes: 2 additions & 3 deletions llvm/include/llvm/Support/ScopedPrinter.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion llvm/include/llvm/Support/WithColor.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
7 changes: 3 additions & 4 deletions llvm/lib/Support/ARMBuildAttrs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Loading

0 comments on commit 16b5e9d

Please sign in to comment.