Replace uses of ManagedStatics by function-local static variables.
Also fix a corruption issue when LLVM is used as a shared library in a
plugin setting.
Consider the case where A depends on B depends on LLVM, where B is a
shared compiler library built on LLVM that defines command-line options
because it can also be used in a non-plugin setting.
If A is loaded and unloaded multiple times, causing B to be loaded and
unloaded multiple times while LLVM *isn't* unloaded, then corruption
results without this change: as B is unloaded, its cl::opt globals
disappear but the GlobalParser still holds a (dangling) reference to
them. Furthermore, if A and B are loaded a second time, the cl::opt
globals are constructed again which fails because options of the
same name are still registered.
The straightforward fix is to remove options from the GlobalParser
in the cl::Option destructor (which was previously defaulted but
already non-trivial).
"This option must have been the last option registered. For testing purposes only."
Is this still accurate? Is it an issue here?