Use ManagedStatic and lazy initialization of cl::opt in libSupport to make it free...
authorMehdi Amini <joker.eph@gmail.com>
Thu, 15 Jul 2021 23:52:44 +0000 (23:52 +0000)
committerMehdi Amini <joker.eph@gmail.com>
Fri, 16 Jul 2021 06:54:26 +0000 (06:54 +0000)
commitaf9321739b20becf170e6bb5060b8d780e1dc8dd
treeb6102c00e02d67904fab6a4638b0f0e3d1afca9b
parent20113d66c7bfe935cf2b300fc6cc3ef996bb847d
Use ManagedStatic and lazy initialization of cl::opt in libSupport to make it free of global initializer

We can build it with -Werror=global-constructors now. This helps
in situation where libSupport is embedded as a shared library,
potential with dlopen/dlclose scenario, and when command-line
parsing or other facilities may not be involved. Avoiding the
implicit construction of these cl::opt can avoid double-registration
issues and other kind of behavior.

Reviewed By: lattner, jpienaar

Differential Revision: https://reviews.llvm.org/D105959
36 files changed:
clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp
clang-tools-extra/clangd/indexer/IndexerMain.cpp
clang/tools/clang-refactor/ClangRefactor.cpp
llvm/docs/CommandLine.rst
llvm/include/llvm/Support/ARMAttributeParser.h
llvm/include/llvm/Support/ARMBuildAttributes.h
llvm/include/llvm/Support/CommandLine.h
llvm/include/llvm/Support/RISCVAttributeParser.h
llvm/include/llvm/Support/RISCVAttributes.h
llvm/include/llvm/Support/ScopedPrinter.h
llvm/include/llvm/Support/WithColor.h
llvm/lib/Support/ARMBuildAttrs.cpp
llvm/lib/Support/CommandLine.cpp
llvm/lib/Support/Debug.cpp
llvm/lib/Support/DebugCounter.cpp
llvm/lib/Support/DebugOptions.h [new file with mode: 0644]
llvm/lib/Support/ELFAttributeParser.cpp
llvm/lib/Support/GraphWriter.cpp
llvm/lib/Support/RISCVAttributes.cpp
llvm/lib/Support/RandomNumberGenerator.cpp
llvm/lib/Support/Signals.cpp
llvm/lib/Support/Statistic.cpp
llvm/lib/Support/TimeProfiler.cpp
llvm/lib/Support/Timer.cpp
llvm/lib/Support/TypeSize.cpp
llvm/lib/Support/Windows/Signals.inc
llvm/lib/Support/WithColor.cpp
llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
llvm/lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp
llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
llvm/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp
llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp
llvm/tools/llvm-libtool-darwin/llvm-libtool-darwin.cpp
llvm/unittests/Support/ARMAttributeParser.cpp
llvm/unittests/Support/CommandLineTest.cpp
llvm/unittests/Support/RISCVAttributeParserTest.cpp