Revert "Use InitLLVM to setup a pretty stack printer"
authorNico Weber <thakis@chromium.org>
Tue, 26 Nov 2019 02:06:56 +0000 (21:06 -0500)
committerNico Weber <thakis@chromium.org>
Tue, 26 Nov 2019 02:06:56 +0000 (21:06 -0500)
This reverts commit 3f76260dc0674cc0acb25f550a0f0c594cf537ea.
Breaks at least these tests on Windows:
    Clang :: Driver/clang-offload-bundler.c
    Clang :: Driver/clang-offload-wrapper.c

19 files changed:
clang-tools-extra/clang-change-namespace/tool/ClangChangeNamespace.cpp
clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
clang-tools-extra/clang-move/tool/ClangMove.cpp
clang-tools-extra/clang-query/tool/ClangQuery.cpp
clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp
clang-tools-extra/clangd/indexer/IndexerMain.cpp
clang-tools-extra/clangd/tool/ClangdMain.cpp
clang-tools-extra/tool-template/ToolTemplate.cpp
clang/tools/arcmt-test/arcmt-test.cpp
clang/tools/c-index-test/core_main.cpp
clang/tools/clang-check/ClangCheck.cpp
clang/tools/clang-extdef-mapping/ClangExtDefMapGen.cpp
clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
clang/tools/clang-offload-wrapper/ClangOffloadWrapper.cpp
clang/tools/clang-refactor/ClangRefactor.cpp
clang/utils/TableGen/TableGen.cpp
llvm/utils/KillTheDoctor/KillTheDoctor.cpp
llvm/utils/TableGen/TableGen.cpp

index a567d7f..a97be99 100644 (file)
@@ -37,7 +37,6 @@
 #include "clang/Tooling/Refactoring.h"
 #include "clang/Tooling/Tooling.h"
 #include "llvm/Support/CommandLine.h"
-#include "llvm/Support/InitLLVM.h"
 #include "llvm/Support/Signals.h"
 #include "llvm/Support/YAMLTraits.h"
 
@@ -99,7 +98,7 @@ llvm::ErrorOr<std::vector<std::string>> GetWhiteListedSymbolPatterns() {
 } // anonymous namespace
 
 int main(int argc, const char **argv) {
-  llvm::InitLLVM X(argc, argv);
+  llvm::sys::PrintStackTraceOnErrorSignal(argv[0]);
   tooling::CommonOptionsParser OptionsParser(argc, argv,
                                              ChangeNamespaceCategory);
   const auto &Files = OptionsParser.getSourcePathList();
index d27a012..38b781e 100644 (file)
@@ -36,7 +36,6 @@
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Support/FileSystem.h"
-#include "llvm/Support/InitLLVM.h"
 #include "llvm/Support/Mutex.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/Process.h"
@@ -180,7 +179,7 @@ llvm::Expected<llvm::SmallString<128>> getInfoOutputFile(StringRef Root,
 }
 
 int main(int argc, const char **argv) {
-  llvm::InitLLVM X(argc, argv);
+  llvm::sys::PrintStackTraceOnErrorSignal(argv[0]);
   std::error_code OK;
 
   ExecutorName.setInitialValue("all-TUs");
index fdf83ab..2df7df7 100644 (file)
@@ -15,7 +15,6 @@
 #include "clang/Tooling/Tooling.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/CommandLine.h"
-#include "llvm/Support/InitLLVM.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/Process.h"
 #include "llvm/Support/Signals.h"
@@ -95,7 +94,7 @@ cl::opt<bool> DumpDecls(
 } // namespace
 
 int main(int argc, const char **argv) {
-  llvm::InitLLVM X(argc, argv);
+  llvm::sys::PrintStackTraceOnErrorSignal(argv[0]);
   tooling::CommonOptionsParser OptionsParser(argc, argv, ClangMoveCategory);
 
   if (OldDependOnNew && NewDependOnOld) {
index 56a1e25..80e1c60 100644 (file)
@@ -33,7 +33,6 @@
 #include "clang/Tooling/Tooling.h"
 #include "llvm/LineEditor/LineEditor.h"
 #include "llvm/Support/CommandLine.h"
-#include "llvm/Support/InitLLVM.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/Signals.h"
 #include <fstream>
@@ -82,7 +81,7 @@ bool runCommandsInFile(const char *ExeName, std::string const &FileName,
 }
 
 int main(int argc, const char **argv) {
-  llvm::InitLLVM X(argc, argv);
+  llvm::sys::PrintStackTraceOnErrorSignal(argv[0]);
 
   CommonOptionsParser OptionsParser(argc, argv, ClangQueryCategory);
 
index ad6182d..df83de8 100644 (file)
@@ -18,7 +18,6 @@
 #include "../ClangTidyForceLinker.h"
 #include "../GlobList.h"
 #include "clang/Tooling/CommonOptionsParser.h"
-#include "llvm/Support/InitLLVM.h"
 #include "llvm/Support/Process.h"
 #include "llvm/Support/Signals.h"
 #include "llvm/Support/TargetSelect.h"
@@ -328,7 +327,7 @@ getVfsFromFile(const std::string &OverlayFile,
 }
 
 static int clangTidyMain(int argc, const char **argv) {
-  llvm::InitLLVM X(argc, argv);
+  llvm::sys::PrintStackTraceOnErrorSignal(argv[0]);
   CommonOptionsParser OptionsParser(argc, argv, ClangTidyCategory,
                                     cl::ZeroOrMore);
   llvm::IntrusiveRefCntPtr<vfs::OverlayFileSystem> BaseFS(
index a026f25..81e435f 100644 (file)
@@ -19,7 +19,6 @@
 #include "llvm/ADT/StringSwitch.h"
 #include "llvm/LineEditor/LineEditor.h"
 #include "llvm/Support/CommandLine.h"
-#include "llvm/Support/InitLLVM.h"
 #include "llvm/Support/Signals.h"
 
 namespace clang {
@@ -276,9 +275,9 @@ std::unique_ptr<SymbolIndex> openIndex(llvm::StringRef Index) {
 int main(int argc, const char *argv[]) {
   using namespace clang::clangd;
 
-  llvm::InitLLVM X(argc, argv);
   llvm::cl::ParseCommandLineOptions(argc, argv, Overview);
   llvm::cl::ResetCommandLineParser(); // We reuse it for REPL commands.
+  llvm::sys::PrintStackTraceOnErrorSignal(argv[0]);
 
   std::unique_ptr<SymbolIndex> Index;
   reportTime("Dex build", [&]() {
index 1bff91f..dac0383 100644 (file)
@@ -21,7 +21,6 @@
 #include "clang/Tooling/Execution.h"
 #include "clang/Tooling/Tooling.h"
 #include "llvm/Support/CommandLine.h"
-#include "llvm/Support/InitLLVM.h"
 #include "llvm/Support/Signals.h"
 
 namespace clang {
@@ -93,7 +92,7 @@ private:
 } // namespace clang
 
 int main(int argc, const char **argv) {
-  llvm::InitLLVM X(argc, argv);
+  llvm::sys::PrintStackTraceOnErrorSignal(argv[0]);
 
   const char *Overview = R"(
   Creates an index of symbol information etc in a whole project.
index b8df361..2639df3 100644 (file)
@@ -21,7 +21,6 @@
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/FileSystem.h"
-#include "llvm/Support/InitLLVM.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/Process.h"
 #include "llvm/Support/Program.h"
@@ -434,8 +433,8 @@ int main(int argc, char *argv[]) {
   using namespace clang;
   using namespace clang::clangd;
 
-  llvm::InitLLVM X(argc, argv);
   llvm::InitializeAllTargetInfos();
+  llvm::sys::PrintStackTraceOnErrorSignal(argv[0]);
   llvm::cl::SetVersionPrinter([](llvm::raw_ostream &OS) {
     OS << clang::getClangToolFullVersion("clangd") << "\n";
   });
index f9949d7..3220eb3 100644 (file)
@@ -44,7 +44,6 @@
 #include "clang/Tooling/Refactoring/AtomicChange.h"
 #include "clang/Tooling/Tooling.h"
 #include "llvm/Support/CommandLine.h"
-#include "llvm/Support/InitLLVM.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/Signals.h"
 
@@ -89,7 +88,7 @@ static cl::extrahelp CommonHelp(CommonOptionsParser::HelpMessage);
 static cl::OptionCategory ToolTemplateCategory("tool-template options");
 
 int main(int argc, const char **argv) {
-  llvm::InitLLVM X(argc, argv);
+  llvm::sys::PrintStackTraceOnErrorSignal(argv[0]);
 
   auto Executor = clang::tooling::createExecutorFromCommandLineArgs(
       argc, argv, ToolTemplateCategory);
index 5c79321..c4ba12d 100644 (file)
@@ -15,7 +15,6 @@
 #include "clang/Lex/Preprocessor.h"
 #include "clang/Lex/PreprocessorOptions.h"
 #include "llvm/Support/FileSystem.h"
-#include "llvm/Support/InitLLVM.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/Signals.h"
@@ -341,8 +340,8 @@ static void printSourceRange(CharSourceRange range, ASTContext &Ctx,
 //===----------------------------------------------------------------------===//
 
 int main(int argc, const char **argv) {
-  llvm::InitLLVM X(argc, argv);
   void *MainAddr = (void*) (intptr_t) GetExecutablePath;
+  llvm::sys::PrintStackTraceOnErrorSignal(argv[0]);
 
   std::string
     resourcesPath = CompilerInvocation::GetResourcesPath(argv[0], MainAddr);
index 6a8877b..faf8b66 100644 (file)
 #include "clang/Frontend/CompilerInstance.h"
 #include "clang/Frontend/CompilerInvocation.h"
 #include "clang/Frontend/FrontendAction.h"
-#include "clang/Index/IndexDataConsumer.h"
 #include "clang/Index/IndexingAction.h"
+#include "clang/Index/IndexDataConsumer.h"
 #include "clang/Index/USRGeneration.h"
 #include "clang/Lex/Preprocessor.h"
 #include "clang/Serialization/ASTReader.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/FileSystem.h"
-#include "llvm/Support/InitLLVM.h"
-#include "llvm/Support/PrettyStackTrace.h"
 #include "llvm/Support/Signals.h"
 #include "llvm/Support/raw_ostream.h"
+#include "llvm/Support/PrettyStackTrace.h"
 
 using namespace clang;
 using namespace clang::index;
@@ -321,7 +320,8 @@ static void printSymbolNameAndUSR(const clang::Module *Mod, raw_ostream &OS) {
 //===----------------------------------------------------------------------===//
 
 int indextest_core_main(int argc, const char **argv) {
-  llvm::InitLLVM X(argc, argv);
+  sys::PrintStackTraceOnErrorSignal(argv[0]);
+  PrettyStackTraceProgram X(argc, argv);
   void *MainAddr = (void*) (intptr_t) indextest_core_main;
   std::string Executable = llvm::sys::fs::getMainExecutable(argv[0], MainAddr);
 
index 466dac9..2f59e2b 100644 (file)
@@ -27,7 +27,6 @@
 #include "clang/Tooling/Tooling.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/Option/OptTable.h"
-#include "llvm/Support/InitLLVM.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/Signals.h"
 #include "llvm/Support/TargetSelect.h"
@@ -152,7 +151,7 @@ public:
 } // namespace
 
 int main(int argc, const char **argv) {
-  llvm::InitLLVM X(argc, argv);
+  llvm::sys::PrintStackTraceOnErrorSignal(argv[0]);
 
   // Initialize targets for clang module support.
   llvm::InitializeAllTargets();
index 8776dee..0047aa4 100644 (file)
@@ -20,7 +20,6 @@
 #include "clang/Tooling/CommonOptionsParser.h"
 #include "clang/Tooling/Tooling.h"
 #include "llvm/Support/CommandLine.h"
-#include "llvm/Support/InitLLVM.h"
 #include "llvm/Support/Signals.h"
 #include <sstream>
 #include <string>
@@ -114,7 +113,8 @@ static cl::extrahelp CommonHelp(CommonOptionsParser::HelpMessage);
 
 int main(int argc, const char **argv) {
   // Print a stack trace if we signal out.
-  llvm::InitLLVM X(argc, argv);
+  sys::PrintStackTraceOnErrorSignal(argv[0], false);
+  PrettyStackTraceProgram X(argc, argv);
 
   const char *Overview = "\nThis tool collects the USR name and location "
                          "of external definitions in the source files "
index 27d5cc4..a75d2a6 100644 (file)
@@ -30,7 +30,6 @@
 #include "llvm/Support/Error.h"
 #include "llvm/Support/ErrorOr.h"
 #include "llvm/Support/FileSystem.h"
-#include "llvm/Support/InitLLVM.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/Program.h"
@@ -817,7 +816,7 @@ static void PrintVersion(raw_ostream &OS) {
 }
 
 int main(int argc, const char **argv) {
-  llvm::InitLLVM X(argc, argv);
+  sys::PrintStackTraceOnErrorSignal(argv[0]);
 
   cl::HideUnrelatedOptions(ClangOffloadBundlerCategory);
   cl::SetVersionPrinter(PrintVersion);
index f232eaf..c386342 100644 (file)
@@ -27,7 +27,6 @@
 #include "llvm/Support/Errc.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Support/ErrorOr.h"
-#include "llvm/Support/InitLLVM.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/Signals.h"
 #include "llvm/Support/ToolOutputFile.h"
@@ -304,7 +303,7 @@ public:
 } // anonymous namespace
 
 int main(int argc, const char **argv) {
-  llvm::InitLLVM X(argc, argv);
+  sys::PrintStackTraceOnErrorSignal(argv[0]);
 
   cl::HideUnrelatedOptions(ClangOffloadWrapperCategory);
   cl::SetVersionPrinter([](raw_ostream &OS) {
index 2314317..8b44c7f 100644 (file)
@@ -24,7 +24,6 @@
 #include "clang/Tooling/Tooling.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/FileSystem.h"
-#include "llvm/Support/InitLLVM.h"
 #include "llvm/Support/Signals.h"
 #include "llvm/Support/raw_ostream.h"
 #include <string>
@@ -609,7 +608,7 @@ private:
 } // end anonymous namespace
 
 int main(int argc, const char **argv) {
-  llvm::InitLLVM X(argc, argv);
+  llvm::sys::PrintStackTraceOnErrorSignal(argv[0]);
 
   ClangRefactorTool RefactorTool;
 
index 3b9c833..c988a58 100644 (file)
 //
 //===----------------------------------------------------------------------===//
 
-#include "ClangASTEmitters.h"
 #include "TableGenBackends.h" // Declares all backends.
+#include "ClangASTEmitters.h"
 #include "llvm/Support/CommandLine.h"
-#include "llvm/Support/InitLLVM.h"
 #include "llvm/Support/PrettyStackTrace.h"
 #include "llvm/Support/Signals.h"
 #include "llvm/TableGen/Error.h"
@@ -350,7 +349,8 @@ bool ClangTableGenMain(raw_ostream &OS, RecordKeeper &Records) {
 }
 
 int main(int argc, char **argv) {
-  llvm::InitLLVM X(argc, argv);
+  sys::PrintStackTraceOnErrorSignal(argv[0]);
+  PrettyStackTraceProgram X(argc, argv);
   cl::ParseCommandLineOptions(argc, argv);
 
   llvm_shutdown_obj Y;
index c5501f9..358ef16 100644 (file)
@@ -36,7 +36,6 @@
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/Twine.h"
 #include "llvm/Support/CommandLine.h"
-#include "llvm/Support/InitLLVM.h"
 #include "llvm/Support/ManagedStatic.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/PrettyStackTrace.h"
@@ -296,7 +295,8 @@ static StringRef ExceptionCodeToString(DWORD ExceptionCode) {
 
 int main(int argc, char **argv) {
   // Print a stack trace if we signal out.
-  llvm::InitLLVM X(argc, argv);
+  sys::PrintStackTraceOnErrorSignal(argv[0]);
+  PrettyStackTraceProgram X(argc, argv);
   llvm_shutdown_obj Y;  // Call llvm_shutdown() on exit.
 
   ToolName = argv[0];
index e7f96c2..086560e 100644 (file)
@@ -12,7 +12,6 @@
 
 #include "TableGenBackends.h" // Declares all backends.
 #include "llvm/Support/CommandLine.h"
-#include "llvm/Support/InitLLVM.h"
 #include "llvm/Support/ManagedStatic.h"
 #include "llvm/Support/PrettyStackTrace.h"
 #include "llvm/Support/Signals.h"
@@ -267,7 +266,8 @@ bool LLVMTableGenMain(raw_ostream &OS, RecordKeeper &Records) {
 }
 
 int main(int argc, char **argv) {
-  llvm::InitLLVM X(argc, argv);
+  sys::PrintStackTraceOnErrorSignal(argv[0]);
+  PrettyStackTraceProgram X(argc, argv);
   cl::ParseCommandLineOptions(argc, argv);
 
   llvm_shutdown_obj Y;