Line data Source code
1 : //===- InitLLVM.h -----------------------------------------------*- C++ -*-===//
2 : //
3 : // The LLVM Compiler Infrastructure
4 : //
5 : // This file is distributed under the University of Illinois Open Source
6 : // License. See LICENSE.TXT for details.
7 : //
8 : //===----------------------------------------------------------------------===//
9 :
10 : #ifndef LLVM_SUPPORT_LLVM_H
11 : #define LLVM_SUPPORT_LLVM_H
12 :
13 : #include "llvm/ADT/SmallVector.h"
14 : #include "llvm/Support/Allocator.h"
15 : #include "llvm/Support/PrettyStackTrace.h"
16 :
17 : // The main() functions in typical LLVM tools start with InitLLVM which does
18 : // the following one-time initializations:
19 : //
20 : // 1. Setting up a signal handler so that pretty stack trace is printed out
21 : // if a process crashes.
22 : //
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.
27 : //
28 : // InitLLVM calls llvm_shutdown() on destruction, which cleans up
29 : // ManagedStatic objects.
30 : namespace llvm {
31 : class InitLLVM {
32 : public:
33 : InitLLVM(int &Argc, const char **&Argv);
34 : InitLLVM(int &Argc, char **&Argv)
35 110445 : : InitLLVM(Argc, const_cast<const char **&>(Argv)) {}
36 :
37 : ~InitLLVM();
38 :
39 : private:
40 : BumpPtrAllocator Alloc;
41 : SmallVector<const char *, 0> Args;
42 : PrettyStackTraceProgram StackPrinter;
43 : };
44 : } // namespace llvm
45 :
46 : #endif
|