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