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