]> CyberLeo.Net >> Repos - FreeBSD/stable/9.git/blob - contrib/llvm/tools/clang/include/clang/Frontend/CompilerInvocation.h
Copy head to stable/9 as part of 9.0-RELEASE release cycle.
[FreeBSD/stable/9.git] / contrib / llvm / tools / clang / include / clang / Frontend / CompilerInvocation.h
1 //===-- CompilerInvocation.h - Compiler Invocation Helper Data --*- 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_CLANG_FRONTEND_COMPILERINVOCATION_H_
11 #define LLVM_CLANG_FRONTEND_COMPILERINVOCATION_H_
12
13 #include "clang/Basic/LangOptions.h"
14 #include "clang/Basic/TargetOptions.h"
15 #include "clang/Basic/FileSystemOptions.h"
16 #include "clang/Frontend/AnalyzerOptions.h"
17 #include "clang/Frontend/CodeGenOptions.h"
18 #include "clang/Frontend/DependencyOutputOptions.h"
19 #include "clang/Frontend/DiagnosticOptions.h"
20 #include "clang/Frontend/FrontendOptions.h"
21 #include "clang/Frontend/HeaderSearchOptions.h"
22 #include "clang/Frontend/LangStandard.h"
23 #include "clang/Frontend/PreprocessorOptions.h"
24 #include "clang/Frontend/PreprocessorOutputOptions.h"
25 #include "llvm/ADT/IntrusiveRefCntPtr.h"
26 #include "llvm/ADT/StringRef.h"
27 #include "llvm/ADT/StringMap.h"
28 #include <string>
29 #include <vector>
30
31 namespace llvm {
32   template<typename T> class SmallVectorImpl;
33 }
34
35 namespace clang {
36
37 class Diagnostic;
38
39 /// CompilerInvocation - Helper class for holding the data necessary to invoke
40 /// the compiler.
41 ///
42 /// This class is designed to represent an abstract "invocation" of the
43 /// compiler, including data such as the include paths, the code generation
44 /// options, the warning flags, and so on.
45 class CompilerInvocation : public llvm::RefCountedBase<CompilerInvocation> {
46   /// Options controlling the static analyzer.
47   AnalyzerOptions AnalyzerOpts;
48
49   /// Options controlling IRgen and the backend.
50   CodeGenOptions CodeGenOpts;
51
52   /// Options controlling dependency output.
53   DependencyOutputOptions DependencyOutputOpts;
54
55   /// Options controlling the diagnostic engine.
56   DiagnosticOptions DiagnosticOpts;
57
58   /// Options controlling file system operations.
59   FileSystemOptions FileSystemOpts;
60
61   /// Options controlling the frontend itself.
62   FrontendOptions FrontendOpts;
63
64   /// Options controlling the #include directive.
65   HeaderSearchOptions HeaderSearchOpts;
66
67   /// Options controlling the language variant.
68   LangOptions LangOpts;
69
70   /// Options controlling the preprocessor (aside from #include handling).
71   PreprocessorOptions PreprocessorOpts;
72
73   /// Options controlling preprocessed output.
74   PreprocessorOutputOptions PreprocessorOutputOpts;
75
76   /// Options controlling the target.
77   TargetOptions TargetOpts;
78
79 public:
80   CompilerInvocation() {}
81
82   /// @name Utility Methods
83   /// @{
84
85   /// CreateFromArgs - Create a compiler invocation from a list of input
86   /// options.
87   ///
88   /// \param Res [out] - The resulting invocation.
89   /// \param ArgBegin - The first element in the argument vector.
90   /// \param ArgEnd - The last element in the argument vector.
91   /// \param Diags - The diagnostic engine to use for errors.
92   static void CreateFromArgs(CompilerInvocation &Res,
93                              const char* const *ArgBegin,
94                              const char* const *ArgEnd,
95                              Diagnostic &Diags);
96
97   /// GetBuiltinIncludePath - Get the directory where the compiler headers
98   /// reside, relative to the compiler binary (found by the passed in
99   /// arguments).
100   ///
101   /// \param Argv0 - The program path (from argv[0]), for finding the builtin
102   /// compiler path.
103   /// \param MainAddr - The address of main (or some other function in the main
104   /// executable), for finding the builtin compiler path.
105   static std::string GetResourcesPath(const char *Argv0, void *MainAddr);
106
107   /// toArgs - Convert the CompilerInvocation to a list of strings suitable for
108   /// passing to CreateFromArgs.
109   void toArgs(std::vector<std::string> &Res);
110
111   /// setLangDefaults - Set language defaults for the given input language and
112   /// language standard in this CompilerInvocation.
113   ///
114   /// \param IK - The input language.
115   /// \param LangStd - The input language standard.
116   void setLangDefaults(InputKind IK,
117                   LangStandard::Kind LangStd = LangStandard::lang_unspecified) {
118     setLangDefaults(LangOpts, IK, LangStd);
119   }
120
121   /// setLangDefaults - Set language defaults for the given input language and
122   /// language standard in the given LangOptions object.
123   ///
124   /// \param LangOpts - The LangOptions object to set up.
125   /// \param IK - The input language.
126   /// \param LangStd - The input language standard.
127   static void setLangDefaults(LangOptions &Opts, InputKind IK,
128                    LangStandard::Kind LangStd = LangStandard::lang_unspecified);
129   
130   /// @}
131   /// @name Option Subgroups
132   /// @{
133
134   AnalyzerOptions &getAnalyzerOpts() { return AnalyzerOpts; }
135   const AnalyzerOptions &getAnalyzerOpts() const {
136     return AnalyzerOpts;
137   }
138
139   CodeGenOptions &getCodeGenOpts() { return CodeGenOpts; }
140   const CodeGenOptions &getCodeGenOpts() const {
141     return CodeGenOpts;
142   }
143
144   DependencyOutputOptions &getDependencyOutputOpts() {
145     return DependencyOutputOpts;
146   }
147   const DependencyOutputOptions &getDependencyOutputOpts() const {
148     return DependencyOutputOpts;
149   }
150
151   DiagnosticOptions &getDiagnosticOpts() { return DiagnosticOpts; }
152   const DiagnosticOptions &getDiagnosticOpts() const { return DiagnosticOpts; }
153
154   FileSystemOptions &getFileSystemOpts() { return FileSystemOpts; }
155   const FileSystemOptions &getFileSystemOpts() const {
156     return FileSystemOpts;
157   }
158
159   HeaderSearchOptions &getHeaderSearchOpts() { return HeaderSearchOpts; }
160   const HeaderSearchOptions &getHeaderSearchOpts() const {
161     return HeaderSearchOpts;
162   }
163
164   FrontendOptions &getFrontendOpts() { return FrontendOpts; }
165   const FrontendOptions &getFrontendOpts() const {
166     return FrontendOpts;
167   }
168
169   LangOptions &getLangOpts() { return LangOpts; }
170   const LangOptions &getLangOpts() const { return LangOpts; }
171
172   PreprocessorOptions &getPreprocessorOpts() { return PreprocessorOpts; }
173   const PreprocessorOptions &getPreprocessorOpts() const {
174     return PreprocessorOpts;
175   }
176
177   PreprocessorOutputOptions &getPreprocessorOutputOpts() {
178     return PreprocessorOutputOpts;
179   }
180   const PreprocessorOutputOptions &getPreprocessorOutputOpts() const {
181     return PreprocessorOutputOpts;
182   }
183
184   TargetOptions &getTargetOpts() { return TargetOpts; }
185   const TargetOptions &getTargetOpts() const {
186     return TargetOpts;
187   }
188
189   /// @}
190 };
191
192 } // end namespace clang
193
194 #endif