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 07:38:16 +0000 (07:38 +0000)
commit76374573ce829b083b95b74937a11e9b91f8f45f
treed3d4858038abe40a2eb763e04e6c93f8902691af
parent8d051d854619956de633047409149cdab1e3319a
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