1 //===--- FrontendOptions.h --------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef LLVM_CLANG_FRONTEND_FRONTENDOPTIONS_H
11 #define LLVM_CLANG_FRONTEND_FRONTENDOPTIONS_H
13 #include "clang/Frontend/CommandLineSourceLoc.h"
14 #include "clang/Frontend/FrontendAction.h"
15 #include "llvm/ADT/StringRef.h"
23 ASTDump, ///< Parse ASTs and dump them.
24 ASTDumpXML, ///< Parse ASTs and dump them in XML.
25 ASTPrint, ///< Parse ASTs and print them.
26 ASTView, ///< Parse ASTs and view them in Graphviz.
27 CreateModule, ///< Create module definition
28 DumpRawTokens, ///< Dump out raw tokens.
29 DumpTokens, ///< Dump out preprocessed tokens.
30 EmitAssembly, ///< Emit a .s file.
31 EmitBC, ///< Emit a .bc file.
32 EmitHTML, ///< Translate input source into HTML.
33 EmitLLVM, ///< Emit a .ll file.
34 EmitLLVMOnly, ///< Generate LLVM IR, but do not emit anything.
35 EmitCodeGenOnly, ///< Generate machine code, but don't emit anything.
36 EmitObj, ///< Emit a .o file.
37 FixIt, ///< Parse and apply any fixits to the source.
38 GeneratePCH, ///< Generate pre-compiled header.
39 GeneratePTH, ///< Generate pre-tokenized header.
40 InitOnly, ///< Only execute frontend initialization.
41 ParseSyntaxOnly, ///< Parse and perform semantic analysis.
42 PluginAction, ///< Run a plugin action, \see ActionName.
43 PrintDeclContext, ///< Print DeclContext and their Decls.
44 PrintPreamble, ///< Print the "preamble" of the input file
45 PrintPreprocessedInput, ///< -E mode.
46 RewriteMacros, ///< Expand macros but not #includes.
47 RewriteObjC, ///< ObjC->C Rewriter.
48 RewriteTest, ///< Rewriter playground
49 RunAnalysis, ///< Run one or more source code analyses.
50 RunPreprocessorOnly ///< Just lex, no output.
54 /// FrontendOptions - Options for controlling the behavior of the frontend.
55 class FrontendOptions {
57 unsigned DisableFree : 1; ///< Disable memory freeing on exit.
58 unsigned RelocatablePCH : 1; ///< When generating PCH files,
59 /// instruct the AST writer to create
60 /// relocatable PCH files.
61 unsigned ChainedPCH : 1; ///< When generating PCH files,
62 /// instruct the AST writer to create
63 /// chained PCH files.
64 unsigned ShowHelp : 1; ///< Show the -help text.
65 unsigned ShowMacrosInCodeCompletion : 1; ///< Show macros in code completion
67 unsigned ShowCodePatternsInCodeCompletion : 1; ///< Show code patterns in code
68 /// completion results.
69 unsigned ShowGlobalSymbolsInCodeCompletion : 1; ///< Show top-level decls in
70 /// code completion results.
71 unsigned ShowStats : 1; ///< Show frontend performance
72 /// metrics and statistics.
73 unsigned ShowTimers : 1; ///< Show timers for individual
75 unsigned ShowVersion : 1; ///< Show the -version text.
76 unsigned FixWhatYouCan : 1; ///< Apply fixes even if there are
86 std::string ARCMTMigrateDir;
88 /// The input files and their types.
89 std::vector<std::pair<InputKind, std::string> > Inputs;
91 /// The output file, if any.
92 std::string OutputFile;
94 /// If given, the new suffix for fix-it rewritten files.
95 std::string FixItSuffix;
97 /// If given, enable code completion at the provided location.
98 ParsedSourceLocation CodeCompletionAt;
100 /// The frontend action to perform.
101 frontend::ActionKind ProgramAction;
103 /// The name of the action to run when using a plugin action.
104 std::string ActionName;
106 /// Args to pass to the plugin
107 std::vector<std::string> PluginArgs;
109 /// The list of plugin actions to run in addition to the normal action.
110 std::vector<std::string> AddPluginActions;
112 /// Args to pass to the additional plugins
113 std::vector<std::vector<std::string> > AddPluginArgs;
115 /// The list of plugins to load.
116 std::vector<std::string> Plugins;
118 /// \brief The list of AST files to merge.
119 std::vector<std::string> ASTMergeFiles;
121 /// \brief The list of modules to import.
122 std::vector<std::string> Modules;
124 /// \brief A list of arguments to forward to LLVM's option processing; this
125 /// should only be used for debugging and experimental features.
126 std::vector<std::string> LLVMArgs;
131 ProgramAction = frontend::ParseSyntaxOnly;
136 ShowMacrosInCodeCompletion = 0;
137 ShowCodePatternsInCodeCompletion = 0;
138 ShowGlobalSymbolsInCodeCompletion = 1;
142 ARCMTAction = ARCMT_None;
145 /// getInputKindForExtension - Return the appropriate input kind for a file
146 /// extension. For example, "c" would return IK_C.
148 /// \return The input kind for the extension, or IK_None if the extension is
150 static InputKind getInputKindForExtension(llvm::StringRef Extension);
153 } // end namespace clang