зеркало из https://github.com/microsoft/clang-1.git
The diagtool registration system tries to use a global variable from a method
called on another global variable. Use ManagedStatic to ensure that the global we register with actually exists when we need it. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@137406 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
579ad7ac56
Коммит
83f06e8223
|
@ -64,5 +64,5 @@ void DiagTools::printCommands(llvm::raw_ostream &out) {
|
|||
}
|
||||
|
||||
namespace diagtool {
|
||||
DiagTools diagTools;
|
||||
llvm::ManagedStatic<DiagTools> diagTools;
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
|
||||
#include "llvm/ADT/StringRef.h"
|
||||
#include "llvm/Support/raw_ostream.h"
|
||||
#include "llvm/Support/ManagedStatic.h"
|
||||
#include <string>
|
||||
|
||||
|
||||
|
@ -45,12 +46,12 @@ public:
|
|||
void printCommands(llvm::raw_ostream &out);
|
||||
};
|
||||
|
||||
extern DiagTools diagTools;
|
||||
|
||||
extern llvm::ManagedStatic<DiagTools> diagTools;
|
||||
|
||||
template <typename DIAGTOOL>
|
||||
class RegisterDiagTool {
|
||||
public:
|
||||
RegisterDiagTool() { diagTools.registerTool(new DIAGTOOL()); }
|
||||
RegisterDiagTool() { diagTools->registerTool(new DIAGTOOL()); }
|
||||
};
|
||||
|
||||
} // end diagtool namespace
|
||||
|
|
|
@ -50,7 +50,7 @@ int ListWarnings::run(unsigned int argc, char **argv, llvm::raw_ostream &out) {
|
|||
llvm::IntrusiveRefCntPtr<DiagnosticIDs> Diags(new DiagnosticIDs);
|
||||
Diagnostic D(Diags);
|
||||
|
||||
std::vector<Entry> Flagged, Unflagged;;
|
||||
std::vector<Entry> Flagged, Unflagged;
|
||||
llvm::StringMap<std::vector<unsigned> > flagHistogram;
|
||||
|
||||
for (DiagnosticIDs::diag_iterator di = DiagnosticIDs::diags_begin(),
|
||||
|
|
|
@ -17,10 +17,10 @@ using namespace diagtool;
|
|||
|
||||
int main(int argc, char *argv[]) {
|
||||
if (argc > 1)
|
||||
if (DiagTool *tool = diagTools.getTool(argv[1]))
|
||||
if (DiagTool *tool = diagTools->getTool(argv[1]))
|
||||
return tool->run(argc - 1, &argv[2], llvm::errs());
|
||||
|
||||
llvm::errs() << "usage: diagtool <command> [<args>]\n\n";
|
||||
diagTools.printCommands(llvm::errs());
|
||||
diagTools->printCommands(llvm::errs());
|
||||
return 1;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче