1 //===- InitLLVM.h -----------------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef LLVM_SUPPORT_LLVM_H
11 #define LLVM_SUPPORT_LLVM_H
13 #include "llvm/ADT/SmallVector.h"
14 #include "llvm/Support/Allocator.h"
15 #include "llvm/Support/PrettyStackTrace.h"
17 // The main() functions in typical LLVM tools start with InitLLVM which does
18 // the following one-time initializations:
20 // 1. Setting up a signal handler so that pretty stack trace is printed out
21 // if a process crashes.
23 // 2. If running on Windows, obtain command line arguments using a
24 // multibyte character-aware API and convert arguments into UTF-8
25 // encoding, so that you can assume that command line arguments are
26 // always encoded in UTF-8 on any platform.
28 // InitLLVM calls llvm_shutdown() on destruction, which cleans up
29 // ManagedStatic objects.
33 InitLLVM(int &Argc, const char **&Argv);
34 InitLLVM(int &Argc, char **&Argv)
35 : InitLLVM(Argc, const_cast<const char **&>(Argv)) {}
40 BumpPtrAllocator Alloc;
41 SmallVector<const char *, 0> Args;
42 PrettyStackTraceProgram StackPrinter;