clang  3.7.0
FrontendOptions.h
Go to the documentation of this file.
1 //===--- FrontendOptions.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_CLANG_FRONTEND_FRONTENDOPTIONS_H
11 #define LLVM_CLANG_FRONTEND_FRONTENDOPTIONS_H
12 
15 #include "llvm/ADT/StringRef.h"
16 #include <string>
17 #include <vector>
18 
19 namespace llvm {
20 class MemoryBuffer;
21 }
22 
23 namespace clang {
24 
25 namespace frontend {
26  enum ActionKind {
27  ASTDeclList, ///< Parse ASTs and list Decl nodes.
28  ASTDump, ///< Parse ASTs and dump them.
29  ASTPrint, ///< Parse ASTs and print them.
30  ASTView, ///< Parse ASTs and view them in Graphviz.
31  DumpRawTokens, ///< Dump out raw tokens.
32  DumpTokens, ///< Dump out preprocessed tokens.
33  EmitAssembly, ///< Emit a .s file.
34  EmitBC, ///< Emit a .bc file.
35  EmitHTML, ///< Translate input source into HTML.
36  EmitLLVM, ///< Emit a .ll file.
37  EmitLLVMOnly, ///< Generate LLVM IR, but do not emit anything.
38  EmitCodeGenOnly, ///< Generate machine code, but don't emit anything.
39  EmitObj, ///< Emit a .o file.
40  FixIt, ///< Parse and apply any fixits to the source.
41  GenerateModule, ///< Generate pre-compiled module.
42  GeneratePCH, ///< Generate pre-compiled header.
43  GeneratePTH, ///< Generate pre-tokenized header.
44  InitOnly, ///< Only execute frontend initialization.
45  ModuleFileInfo, ///< Dump information about a module file.
46  VerifyPCH, ///< Load and verify that a PCH file is usable.
47  ParseSyntaxOnly, ///< Parse and perform semantic analysis.
48  PluginAction, ///< Run a plugin action, \see ActionName.
49  PrintDeclContext, ///< Print DeclContext and their Decls.
50  PrintPreamble, ///< Print the "preamble" of the input file
51  PrintPreprocessedInput, ///< -E mode.
52  RewriteMacros, ///< Expand macros but not \#includes.
53  RewriteObjC, ///< ObjC->C Rewriter.
54  RewriteTest, ///< Rewriter playground
55  RunAnalysis, ///< Run one or more source code analyses.
56  MigrateSource, ///< Run migrator.
57  RunPreprocessorOnly ///< Just lex, no output.
58  };
59 }
60 
61 enum InputKind {
77 };
78 
79 
80 /// \brief An input file for the front end.
82  /// \brief The file name, or "-" to read from standard input.
83  std::string File;
84 
85  llvm::MemoryBuffer *Buffer;
86 
87  /// \brief The kind of input, e.g., C source, AST file, LLVM IR.
89 
90  /// \brief Whether we're dealing with a 'system' input (vs. a 'user' input).
91  bool IsSystem;
92 
93 public:
94  FrontendInputFile() : Buffer(nullptr), Kind(IK_None) { }
95  FrontendInputFile(StringRef File, InputKind Kind, bool IsSystem = false)
96  : File(File.str()), Buffer(nullptr), Kind(Kind), IsSystem(IsSystem) { }
97  FrontendInputFile(llvm::MemoryBuffer *buffer, InputKind Kind,
98  bool IsSystem = false)
99  : Buffer(buffer), Kind(Kind), IsSystem(IsSystem) { }
100 
101  InputKind getKind() const { return Kind; }
102  bool isSystem() const { return IsSystem; }
103 
104  bool isEmpty() const { return File.empty() && Buffer == nullptr; }
105  bool isFile() const { return !isBuffer(); }
106  bool isBuffer() const { return Buffer != nullptr; }
107 
108  StringRef getFile() const {
109  assert(isFile());
110  return File;
111  }
112  llvm::MemoryBuffer *getBuffer() const {
113  assert(isBuffer());
114  return Buffer;
115  }
116 };
117 
118 /// FrontendOptions - Options for controlling the behavior of the frontend.
120 public:
121  unsigned DisableFree : 1; ///< Disable memory freeing on exit.
122  unsigned RelocatablePCH : 1; ///< When generating PCH files,
123  /// instruct the AST writer to create
124  /// relocatable PCH files.
125  unsigned ShowHelp : 1; ///< Show the -help text.
126  unsigned ShowStats : 1; ///< Show frontend performance
127  /// metrics and statistics.
128  unsigned ShowTimers : 1; ///< Show timers for individual
129  /// actions.
130  unsigned ShowVersion : 1; ///< Show the -version text.
131  unsigned FixWhatYouCan : 1; ///< Apply fixes even if there are
132  /// unfixable errors.
133  unsigned FixOnlyWarnings : 1; ///< Apply fixes only for warnings.
134  unsigned FixAndRecompile : 1; ///< Apply fixes and recompile.
135  unsigned FixToTemporaries : 1; ///< Apply fixes to temporary files.
136  unsigned ARCMTMigrateEmitARCErrors : 1; /// Emit ARC errors even if the
137  /// migrator can fix them
138  unsigned SkipFunctionBodies : 1; ///< Skip over function bodies to
139  /// speed up parsing in cases you do
140  /// not need them (e.g. with code
141  /// completion).
142  unsigned UseGlobalModuleIndex : 1; ///< Whether we can use the
143  ///< global module index if available.
144  unsigned GenerateGlobalModuleIndex : 1; ///< Whether we can generate the
145  ///< global module index if needed.
146  unsigned ASTDumpDecls : 1; ///< Whether we include declaration
147  ///< dumps in AST dumps.
148  unsigned ASTDumpLookups : 1; ///< Whether we include lookup table
149  ///< dumps in AST dumps.
150 
152 
153  enum {
158  } ARCMTAction;
159 
160  enum {
162  /// \brief Enable migration to modern ObjC literals.
164  /// \brief Enable migration to modern ObjC subscripting.
166  /// \brief Enable migration to modern ObjC readonly property.
168  /// \brief Enable migration to modern ObjC readwrite property.
170  /// \brief Enable migration to modern ObjC property.
172  /// \brief Enable annotation of ObjCMethods of all kinds.
174  /// \brief Enable migration of ObjC methods to 'instancetype'.
176  /// \brief Enable migration to NS_ENUM/NS_OPTIONS macros.
178  /// \brief Enable migration to add conforming protocols.
180  /// \brief prefer 'atomic' property over 'nonatomic'.
182  /// \brief annotate property with NS_RETURNS_INNER_POINTER
184  /// \brief use NS_NONATOMIC_IOSONLY for property 'atomic' attribute
186  /// \brief Enable inferring NS_DESIGNATED_INITIALIZER for ObjC methods.
188  /// \brief Enable converting setter/getter expressions to property-dot syntx.
197  };
198  unsigned ObjCMTAction;
199  std::string ObjCMTWhiteListPath;
200 
201  std::string MTMigrateDir;
203 
204  /// The input files and their types.
205  std::vector<FrontendInputFile> Inputs;
206 
207  /// The output file, if any.
208  std::string OutputFile;
209 
210  /// If given, the new suffix for fix-it rewritten files.
211  std::string FixItSuffix;
212 
213  /// If given, filter dumped AST Decl nodes by this substring.
214  std::string ASTDumpFilter;
215 
216  /// If given, enable code completion at the provided location.
218 
219  /// The frontend action to perform.
221 
222  /// The name of the action to run when using a plugin action.
223  std::string ActionName;
224 
225  /// Args to pass to the plugin
226  std::vector<std::string> PluginArgs;
227 
228  /// The list of plugin actions to run in addition to the normal action.
229  std::vector<std::string> AddPluginActions;
230 
231  /// Args to pass to the additional plugins
232  std::vector<std::vector<std::string> > AddPluginArgs;
233 
234  /// The list of plugins to load.
235  std::vector<std::string> Plugins;
236 
237  /// \brief The list of module map files to load before processing the input.
238  std::vector<std::string> ModuleMapFiles;
239 
240  /// \brief The list of additional prebuilt module files to load before
241  /// processing the input.
242  std::vector<std::string> ModuleFiles;
243 
244  /// \brief The list of AST files to merge.
245  std::vector<std::string> ASTMergeFiles;
246 
247  /// \brief A list of arguments to forward to LLVM's option processing; this
248  /// should only be used for debugging and experimental features.
249  std::vector<std::string> LLVMArgs;
250 
251  /// \brief File name of the file that will provide record layouts
252  /// (in the format produced by -fdump-record-layouts).
254 
255 public:
263  ARCMTAction(ARCMT_None), ObjCMTAction(ObjCMT_None),
264  ProgramAction(frontend::ParseSyntaxOnly)
265  {}
266 
267  /// getInputKindForExtension - Return the appropriate input kind for a file
268  /// extension. For example, "c" would return IK_C.
269  ///
270  /// \return The input kind for the extension, or IK_None if the extension is
271  /// not recognized.
272  static InputKind getInputKindForExtension(StringRef Extension);
273 };
274 
275 } // end namespace clang
276 
277 #endif
Expand macros but not #includes.
std::string OutputFile
The output file, if any.
std::string ObjCMTWhiteListPath
std::vector< std::vector< std::string > > AddPluginArgs
Args to pass to the additional plugins.
Generate pre-compiled module.
FrontendInputFile(llvm::MemoryBuffer *buffer, InputKind Kind, bool IsSystem=false)
Parse and perform semantic analysis.
Emit a .bc file.
Parse ASTs and print them.
Enable migration of ObjC methods to 'instancetype'.
std::string ASTDumpFilter
If given, filter dumped AST Decl nodes by this substring.
std::vector< std::string > PluginArgs
Args to pass to the plugin.
std::string FixItSuffix
If given, the new suffix for fix-it rewritten files.
Parse and apply any fixits to the source.
Translate input source into HTML.
A source location that has been parsed on the command line.
llvm::MemoryBuffer * getBuffer() const
FrontendInputFile(StringRef File, InputKind Kind, bool IsSystem=false)
std::vector< std::string > ASTMergeFiles
The list of AST files to merge.
Enable migration to add conforming protocols.
Print DeclContext and their Decls.
Generate LLVM IR, but do not emit anything.
Enable annotation of ObjCMethods of all kinds.
unsigned FixAndRecompile
Apply fixes and recompile.
Dump out preprocessed tokens.
Enable migration to modern ObjC literals.
std::vector< std::string > Plugins
The list of plugins to load.
Only execute frontend initialization.
Print the "preamble" of the input file.
Enable migration to modern ObjC property.
Rewriter playground.
unsigned FixOnlyWarnings
Apply fixes only for warnings.
Enable migration to modern ObjC readwrite property.
An input file for the front end.
Options controlling the behavior of code completion.
Enable inferring NS_DESIGNATED_INITIALIZER for ObjC methods.
#define false
Definition: stdbool.h:33
Kind
Generate machine code, but don't emit anything.
std::vector< std::string > ModuleFiles
The list of additional prebuilt module files to load before processing the input. ...
ParsedSourceLocation CodeCompletionAt
If given, enable code completion at the provided location.
std::vector< FrontendInputFile > Inputs
The input files and their types.
Parse ASTs and view them in Graphviz.
annotate property with NS_RETURNS_INNER_POINTER
Enable migration to modern ObjC readonly property.
Parse ASTs and list Decl nodes.
InputKind getKind() const
Enable migration to modern ObjC subscripting.
Load and verify that a PCH file is usable.
unsigned ShowVersion
Show the -version text.
unsigned ShowHelp
Show the -help text.
std::string OverrideRecordLayoutsFile
File name of the file that will provide record layouts (in the format produced by -fdump-record-layou...
unsigned FixToTemporaries
Apply fixes to temporary files.
StringRef getFile() const
frontend::ActionKind ProgramAction
The frontend action to perform.
Enable migration to NS_ENUM/NS_OPTIONS macros.
std::string ARCMTMigrateReportOut
enum clang::FrontendOptions::@156 ARCMTAction
FrontendOptions - Options for controlling the behavior of the frontend.
Run a plugin action,.
Parse ASTs and dump them.
CodeCompleteOptions CodeCompleteOpts
std::vector< std::string > AddPluginActions
The list of plugin actions to run in addition to the normal action.
unsigned DisableFree
Disable memory freeing on exit.
Generate pre-compiled header.
Enable converting setter/getter expressions to property-dot syntx.
std::string ActionName
The name of the action to run when using a plugin action.
Run one or more source code analyses.
std::vector< std::string > LLVMArgs
A list of arguments to forward to LLVM's option processing; this should only be used for debugging an...
Dump information about a module file.
prefer 'atomic' property over 'nonatomic'.
Generate pre-tokenized header.
static InputKind getInputKindForExtension(StringRef Extension)
#define true
Definition: stdbool.h:32
use NS_NONATOMIC_IOSONLY for property 'atomic' attribute
std::vector< std::string > ModuleMapFiles
The list of module map files to load before processing the input.