Index: clang/tools/clang-format/ClangFormat.cpp =================================================================== --- clang/tools/clang-format/ClangFormat.cpp +++ clang/tools/clang-format/ClangFormat.cpp @@ -23,7 +23,7 @@ #include "llvm/Support/CommandLine.h" #include "llvm/Support/FileSystem.h" #include "llvm/Support/Process.h" -#include "llvm/Support/Signals.h" +#include "llvm/Support/InitLLVM.h" using namespace llvm; using clang::tooling::Replacements; @@ -338,21 +338,13 @@ } int main(int argc, const char **argv) { - llvm::sys::PrintStackTraceOnErrorSignal(argv[0]); - - SmallVector Args; - llvm::SpecificBumpPtrAllocator ArgAllocator; - std::error_code EC = llvm::sys::Process::GetArgumentVector( - Args, llvm::makeArrayRef(argv, argc), ArgAllocator); - if (EC) { - llvm::errs() << "error: couldn't get arguments: " << EC.message() << '\n'; - } + llvm::InitLLVM X(argc, argv); cl::HideUnrelatedOptions(ClangFormatCategory); cl::SetVersionPrinter(PrintVersion); cl::ParseCommandLineOptions( - Args.size(), &Args[0], + argc, argv, "A tool to format C/C++/Java/JavaScript/Objective-C/Protobuf code.\n\n" "If no arguments are specified, it formats the code from standard input\n" "and writes the result to the standard output.\n" Index: clang/tools/driver/driver.cpp =================================================================== --- clang/tools/driver/driver.cpp +++ clang/tools/driver/driver.cpp @@ -34,9 +34,8 @@ #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/FileSystem.h" #include "llvm/Support/Host.h" -#include "llvm/Support/ManagedStatic.h" #include "llvm/Support/Path.h" -#include "llvm/Support/PrettyStackTrace.h" +#include "llvm/Support/InitLLVM.h" #include "llvm/Support/Process.h" #include "llvm/Support/Program.h" #include "llvm/Support/Regex.h" @@ -322,22 +321,12 @@ } int main(int argc_, const char **argv_) { - llvm::sys::PrintStackTraceOnErrorSignal(argv_[0]); - llvm::PrettyStackTraceProgram X(argc_, argv_); - llvm::llvm_shutdown_obj Y; // Call llvm_shutdown() on exit. + llvm::InitLLVM X(argc_, argv_); + SmallVector argv(argv_, argv_ + argc_); if (llvm::sys::Process::FixupStandardFileDescriptors()) return 1; - SmallVector argv; - llvm::SpecificBumpPtrAllocator ArgAllocator; - std::error_code EC = llvm::sys::Process::GetArgumentVector( - argv, llvm::makeArrayRef(argv_, argc_), ArgAllocator); - if (EC) { - llvm::errs() << "error: couldn't get arguments: " << EC.message() << '\n'; - return 1; - } - llvm::InitializeAllTargets(); auto TargetAndMode = ToolChain::getTargetAndModeFromProgramName(argv[0]);