]> CyberLeo.Net >> Repos - FreeBSD/releng/10.2.git/blob - contrib/llvm/tools/clang/include/clang/Frontend/Utils.h
- Copy stable/10@285827 to releng/10.2 in preparation for 10.2-RC1
[FreeBSD/releng/10.2.git] / contrib / llvm / tools / clang / include / clang / Frontend / Utils.h
1 //===--- Utils.h - Misc utilities for the front-end -------------*- 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 //  This header contains miscellaneous utilities for various front-end actions.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #ifndef LLVM_CLANG_FRONTEND_UTILS_H
15 #define LLVM_CLANG_FRONTEND_UTILS_H
16
17 #include "clang/Basic/Diagnostic.h"
18 #include "llvm/ADT/IntrusiveRefCntPtr.h"
19 #include "llvm/ADT/StringRef.h"
20 #include "llvm/Option/OptSpecifier.h"
21
22 namespace llvm {
23 class raw_fd_ostream;
24 class Triple;
25
26 namespace opt {
27 class ArgList;
28 }
29 }
30
31 namespace clang {
32 class ASTConsumer;
33 class CompilerInstance;
34 class CompilerInvocation;
35 class Decl;
36 class DependencyOutputOptions;
37 class DiagnosticsEngine;
38 class DiagnosticOptions;
39 class FileManager;
40 class HeaderSearch;
41 class HeaderSearchOptions;
42 class IdentifierTable;
43 class LangOptions;
44 class Preprocessor;
45 class PreprocessorOptions;
46 class PreprocessorOutputOptions;
47 class SourceManager;
48 class Stmt;
49 class TargetInfo;
50 class FrontendOptions;
51
52 /// Apply the header search options to get given HeaderSearch object.
53 void ApplyHeaderSearchOptions(HeaderSearch &HS,
54                               const HeaderSearchOptions &HSOpts,
55                               const LangOptions &Lang,
56                               const llvm::Triple &triple);
57
58 /// InitializePreprocessor - Initialize the preprocessor getting it and the
59 /// environment ready to process a single file.
60 void InitializePreprocessor(Preprocessor &PP,
61                             const PreprocessorOptions &PPOpts,
62                             const HeaderSearchOptions &HSOpts,
63                             const FrontendOptions &FEOpts);
64
65 /// ProcessWarningOptions - Initialize the diagnostic client and process the
66 /// warning options specified on the command line.
67 void ProcessWarningOptions(DiagnosticsEngine &Diags,
68                            const DiagnosticOptions &Opts,
69                            bool ReportDiags = true);
70
71 /// DoPrintPreprocessedInput - Implement -E mode.
72 void DoPrintPreprocessedInput(Preprocessor &PP, raw_ostream* OS,
73                               const PreprocessorOutputOptions &Opts);
74
75 /// AttachDependencyFileGen - Create a dependency file generator, and attach
76 /// it to the given preprocessor.  This takes ownership of the output stream.
77 void AttachDependencyFileGen(Preprocessor &PP,
78                              const DependencyOutputOptions &Opts);
79
80 /// AttachDependencyGraphGen - Create a dependency graph generator, and attach
81 /// it to the given preprocessor.
82   void AttachDependencyGraphGen(Preprocessor &PP, StringRef OutputFile,
83                                 StringRef SysRoot);
84
85 /// AttachHeaderIncludeGen - Create a header include list generator, and attach
86 /// it to the given preprocessor.
87 ///
88 /// \param ShowAllHeaders - If true, show all header information instead of just
89 /// headers following the predefines buffer. This is useful for making sure
90 /// includes mentioned on the command line are also reported, but differs from
91 /// the default behavior used by -H.
92 /// \param OutputPath - If non-empty, a path to write the header include
93 /// information to, instead of writing to stderr.
94 /// \param ShowDepth - Whether to indent to show the nesting of the includes.
95 /// \param MSStyle - Whether to print in cl.exe /showIncludes style.
96 void AttachHeaderIncludeGen(Preprocessor &PP, bool ShowAllHeaders = false,
97                             StringRef OutputPath = "",
98                             bool ShowDepth = true, bool MSStyle = false);
99
100 /// CacheTokens - Cache tokens for use with PCH. Note that this requires
101 /// a seekable stream.
102 void CacheTokens(Preprocessor &PP, llvm::raw_fd_ostream* OS);
103
104 /// createInvocationFromCommandLine - Construct a compiler invocation object for
105 /// a command line argument vector.
106 ///
107 /// \return A CompilerInvocation, or 0 if none was built for the given
108 /// argument vector.
109 CompilerInvocation *
110 createInvocationFromCommandLine(ArrayRef<const char *> Args,
111                             IntrusiveRefCntPtr<DiagnosticsEngine> Diags =
112                                 IntrusiveRefCntPtr<DiagnosticsEngine>());
113
114 /// Return the value of the last argument as an integer, or a default. If Diags
115 /// is non-null, emits an error if the argument is given, but non-integral.
116 int getLastArgIntValue(const llvm::opt::ArgList &Args,
117                        llvm::opt::OptSpecifier Id, int Default,
118                        DiagnosticsEngine *Diags = 0);
119
120 inline int getLastArgIntValue(const llvm::opt::ArgList &Args,
121                               llvm::opt::OptSpecifier Id, int Default,
122                               DiagnosticsEngine &Diags) {
123   return getLastArgIntValue(Args, Id, Default, &Diags);
124 }
125
126 } // end namespace clang
127
128 #endif