FrontendOptions.h revision 69325d5b7cfecf1b3128745efc33612aedf1b8b4
126266885d6eba8ee197577dd42a8e68a0e4dd2e8Daniel Dunbar//===--- FrontendOptions.h --------------------------------------*- C++ -*-===// 226266885d6eba8ee197577dd42a8e68a0e4dd2e8Daniel Dunbar// 326266885d6eba8ee197577dd42a8e68a0e4dd2e8Daniel Dunbar// The LLVM Compiler Infrastructure 426266885d6eba8ee197577dd42a8e68a0e4dd2e8Daniel Dunbar// 526266885d6eba8ee197577dd42a8e68a0e4dd2e8Daniel Dunbar// This file is distributed under the University of Illinois Open Source 626266885d6eba8ee197577dd42a8e68a0e4dd2e8Daniel Dunbar// License. See LICENSE.TXT for details. 726266885d6eba8ee197577dd42a8e68a0e4dd2e8Daniel Dunbar// 826266885d6eba8ee197577dd42a8e68a0e4dd2e8Daniel Dunbar//===----------------------------------------------------------------------===// 926266885d6eba8ee197577dd42a8e68a0e4dd2e8Daniel Dunbar 1026266885d6eba8ee197577dd42a8e68a0e4dd2e8Daniel Dunbar#ifndef LLVM_CLANG_FRONTEND_FRONTENDOPTIONS_H 1126266885d6eba8ee197577dd42a8e68a0e4dd2e8Daniel Dunbar#define LLVM_CLANG_FRONTEND_FRONTENDOPTIONS_H 1226266885d6eba8ee197577dd42a8e68a0e4dd2e8Daniel Dunbar 13c86804bc9c3f1953520b59084c9ad75104aba123Daniel Dunbar#include "clang/Frontend/CommandLineSourceLoc.h" 14c34ce3fa613d5e4a283e53615fceafd17390445bDaniel Dunbar#include "clang/Frontend/FrontendAction.h" 15fbe2fafe317a757031e4f24026a77dd305607d32Daniel Dunbar#include "llvm/ADT/StringRef.h" 1626266885d6eba8ee197577dd42a8e68a0e4dd2e8Daniel Dunbar#include <string> 1726266885d6eba8ee197577dd42a8e68a0e4dd2e8Daniel Dunbar#include <vector> 1826266885d6eba8ee197577dd42a8e68a0e4dd2e8Daniel Dunbar 1926266885d6eba8ee197577dd42a8e68a0e4dd2e8Daniel Dunbarnamespace clang { 2026266885d6eba8ee197577dd42a8e68a0e4dd2e8Daniel Dunbar 219a8a83b8fe5be9a4ca20ec6eeaafaf201ce594f9Daniel Dunbarnamespace frontend { 229a8a83b8fe5be9a4ca20ec6eeaafaf201ce594f9Daniel Dunbar enum ActionKind { 239a8a83b8fe5be9a4ca20ec6eeaafaf201ce594f9Daniel Dunbar ASTDump, ///< Parse ASTs and dump them. 24f35142413974e9dfe2c5f202084db4bd1c2073e9John McCall ASTDumpXML, ///< Parse ASTs and dump them in XML. 259a8a83b8fe5be9a4ca20ec6eeaafaf201ce594f9Daniel Dunbar ASTPrint, ///< Parse ASTs and print them. 269a8a83b8fe5be9a4ca20ec6eeaafaf201ce594f9Daniel Dunbar ASTView, ///< Parse ASTs and view them in Graphviz. 27e55fd871b0cf3e4ebc708cf46831908d74eab40aSebastian Redl CreateModule, ///< Create module definition 289a8a83b8fe5be9a4ca20ec6eeaafaf201ce594f9Daniel Dunbar DumpRawTokens, ///< Dump out raw tokens. 299a8a83b8fe5be9a4ca20ec6eeaafaf201ce594f9Daniel Dunbar DumpTokens, ///< Dump out preprocessed tokens. 309a8a83b8fe5be9a4ca20ec6eeaafaf201ce594f9Daniel Dunbar EmitAssembly, ///< Emit a .s file. 319a8a83b8fe5be9a4ca20ec6eeaafaf201ce594f9Daniel Dunbar EmitBC, ///< Emit a .bc file. 329a8a83b8fe5be9a4ca20ec6eeaafaf201ce594f9Daniel Dunbar EmitHTML, ///< Translate input source into HTML. 339a8a83b8fe5be9a4ca20ec6eeaafaf201ce594f9Daniel Dunbar EmitLLVM, ///< Emit a .ll file. 3432148cef25570a4fbe3ad0ec497ce3ae2cf1b774Daniel Dunbar EmitLLVMOnly, ///< Generate LLVM IR, but do not emit anything. 3532148cef25570a4fbe3ad0ec497ce3ae2cf1b774Daniel Dunbar EmitCodeGenOnly, ///< Generate machine code, but don't emit anything. 36da1573f95902a42aa4d11e8f45ab98ec7e27bc28Daniel Dunbar EmitObj, ///< Emit a .o file. 379a8a83b8fe5be9a4ca20ec6eeaafaf201ce594f9Daniel Dunbar FixIt, ///< Parse and apply any fixits to the source. 389a8a83b8fe5be9a4ca20ec6eeaafaf201ce594f9Daniel Dunbar GeneratePCH, ///< Generate pre-compiled header. 399a8a83b8fe5be9a4ca20ec6eeaafaf201ce594f9Daniel Dunbar GeneratePTH, ///< Generate pre-tokenized header. 402758595023c5c7c0495f19260089f975022c50dcDaniel Dunbar InitOnly, ///< Only execute frontend initialization. 419a8a83b8fe5be9a4ca20ec6eeaafaf201ce594f9Daniel Dunbar ParseSyntaxOnly, ///< Parse and perform semantic analysis. 42d10c5b88334d860d19284032a7126dc2219f57edDaniel Dunbar PluginAction, ///< Run a plugin action, \see ActionName. 439a8a83b8fe5be9a4ca20ec6eeaafaf201ce594f9Daniel Dunbar PrintDeclContext, ///< Print DeclContext and their Decls. 44f033f1da4a34f8df6e95e9929dc04ff54bb8fb01Douglas Gregor PrintPreamble, ///< Print the "preamble" of the input file 459a8a83b8fe5be9a4ca20ec6eeaafaf201ce594f9Daniel Dunbar PrintPreprocessedInput, ///< -E mode. 469a8a83b8fe5be9a4ca20ec6eeaafaf201ce594f9Daniel Dunbar RewriteMacros, ///< Expand macros but not #includes. 479a8a83b8fe5be9a4ca20ec6eeaafaf201ce594f9Daniel Dunbar RewriteObjC, ///< ObjC->C Rewriter. 489a8a83b8fe5be9a4ca20ec6eeaafaf201ce594f9Daniel Dunbar RewriteTest, ///< Rewriter playground 499a8a83b8fe5be9a4ca20ec6eeaafaf201ce594f9Daniel Dunbar RunAnalysis, ///< Run one or more source code analyses. 509a8a83b8fe5be9a4ca20ec6eeaafaf201ce594f9Daniel Dunbar RunPreprocessorOnly ///< Just lex, no output. 519a8a83b8fe5be9a4ca20ec6eeaafaf201ce594f9Daniel Dunbar }; 529a8a83b8fe5be9a4ca20ec6eeaafaf201ce594f9Daniel Dunbar} 539a8a83b8fe5be9a4ca20ec6eeaafaf201ce594f9Daniel Dunbar 5426266885d6eba8ee197577dd42a8e68a0e4dd2e8Daniel Dunbar/// FrontendOptions - Options for controlling the behavior of the frontend. 5526266885d6eba8ee197577dd42a8e68a0e4dd2e8Daniel Dunbarclass FrontendOptions { 5626266885d6eba8ee197577dd42a8e68a0e4dd2e8Daniel Dunbarpublic: 57914474ca51d202369241a81013208833a6bb3f12Daniel Dunbar unsigned DisableFree : 1; ///< Disable memory freeing on exit. 58914474ca51d202369241a81013208833a6bb3f12Daniel Dunbar unsigned RelocatablePCH : 1; ///< When generating PCH files, 593c7f4134603d04b44f997b43c0a9def270f25386Sebastian Redl /// instruct the AST writer to create 60914474ca51d202369241a81013208833a6bb3f12Daniel Dunbar /// relocatable PCH files. 61d6ac4524cd441808f152f7e10900a8315ea31c08Sebastian Redl unsigned ChainedPCH : 1; ///< When generating PCH files, 623c7f4134603d04b44f997b43c0a9def270f25386Sebastian Redl /// instruct the AST writer to create 63d6ac4524cd441808f152f7e10900a8315ea31c08Sebastian Redl /// chained PCH files. 649b5e9ae08defd14441acca1d7d4502b933bf6c5aDaniel Dunbar unsigned ShowHelp : 1; ///< Show the -help text. 65914474ca51d202369241a81013208833a6bb3f12Daniel Dunbar unsigned ShowMacrosInCodeCompletion : 1; ///< Show macros in code completion 66914474ca51d202369241a81013208833a6bb3f12Daniel Dunbar /// results. 67d8e8a58ee35ab334ab9d0c2154dca029c1822e8aDouglas Gregor unsigned ShowCodePatternsInCodeCompletion : 1; ///< Show code patterns in code 68d8e8a58ee35ab334ab9d0c2154dca029c1822e8aDouglas Gregor /// completion results. 698071e4212ae08f8014e0c3ae6d18b7388003a5ccDouglas Gregor unsigned ShowGlobalSymbolsInCodeCompletion : 1; ///< Show top-level decls in 708071e4212ae08f8014e0c3ae6d18b7388003a5ccDouglas Gregor /// code completion results. 71914474ca51d202369241a81013208833a6bb3f12Daniel Dunbar unsigned ShowStats : 1; ///< Show frontend performance 72914474ca51d202369241a81013208833a6bb3f12Daniel Dunbar /// metrics and statistics. 73914474ca51d202369241a81013208833a6bb3f12Daniel Dunbar unsigned ShowTimers : 1; ///< Show timers for individual 74914474ca51d202369241a81013208833a6bb3f12Daniel Dunbar /// actions. 759b5e9ae08defd14441acca1d7d4502b933bf6c5aDaniel Dunbar unsigned ShowVersion : 1; ///< Show the -version text. 761450f265fcc84a7ca64dd9f3b8d4492c5bd55e23Nick Lewycky unsigned FixWhatYouCan : 1; ///< Apply fixes even if there are 771450f265fcc84a7ca64dd9f3b8d4492c5bd55e23Nick Lewycky /// unfixable errors. 7826266885d6eba8ee197577dd42a8e68a0e4dd2e8Daniel Dunbar 79f85e193739c953358c865005855253af4f68a497John McCall enum { 80f85e193739c953358c865005855253af4f68a497John McCall ARCMT_None, 81f85e193739c953358c865005855253af4f68a497John McCall ARCMT_Check, 8269325d5b7cfecf1b3128745efc33612aedf1b8b4Argyrios Kyrtzidis ARCMT_Modify, 8369325d5b7cfecf1b3128745efc33612aedf1b8b4Argyrios Kyrtzidis ARCMT_Migrate 84f85e193739c953358c865005855253af4f68a497John McCall } ARCMTAction; 85f85e193739c953358c865005855253af4f68a497John McCall 8669325d5b7cfecf1b3128745efc33612aedf1b8b4Argyrios Kyrtzidis std::string ARCMTMigrateDir; 8769325d5b7cfecf1b3128745efc33612aedf1b8b4Argyrios Kyrtzidis 88fbe2fafe317a757031e4f24026a77dd305607d32Daniel Dunbar /// The input files and their types. 89fbe2fafe317a757031e4f24026a77dd305607d32Daniel Dunbar std::vector<std::pair<InputKind, std::string> > Inputs; 9026266885d6eba8ee197577dd42a8e68a0e4dd2e8Daniel Dunbar 9126266885d6eba8ee197577dd42a8e68a0e4dd2e8Daniel Dunbar /// The output file, if any. 9226266885d6eba8ee197577dd42a8e68a0e4dd2e8Daniel Dunbar std::string OutputFile; 9326266885d6eba8ee197577dd42a8e68a0e4dd2e8Daniel Dunbar 94ba5f6eced29937e4e4851a2c0980744768413d66Nick Lewycky /// If given, the new suffix for fix-it rewritten files. 95ba5f6eced29937e4e4851a2c0980744768413d66Nick Lewycky std::string FixItSuffix; 96c86804bc9c3f1953520b59084c9ad75104aba123Daniel Dunbar 97914474ca51d202369241a81013208833a6bb3f12Daniel Dunbar /// If given, enable code completion at the provided location. 98914474ca51d202369241a81013208833a6bb3f12Daniel Dunbar ParsedSourceLocation CodeCompletionAt; 99914474ca51d202369241a81013208833a6bb3f12Daniel Dunbar 1009a8a83b8fe5be9a4ca20ec6eeaafaf201ce594f9Daniel Dunbar /// The frontend action to perform. 1019a8a83b8fe5be9a4ca20ec6eeaafaf201ce594f9Daniel Dunbar frontend::ActionKind ProgramAction; 1029a8a83b8fe5be9a4ca20ec6eeaafaf201ce594f9Daniel Dunbar 103d10c5b88334d860d19284032a7126dc2219f57edDaniel Dunbar /// The name of the action to run when using a plugin action. 104d10c5b88334d860d19284032a7126dc2219f57edDaniel Dunbar std::string ActionName; 105d10c5b88334d860d19284032a7126dc2219f57edDaniel Dunbar 106f25649c74397d2620e6ac61f1045261644707c80Nico Weber /// Args to pass to the plugin 1073177aae51a21f61ab483c52f97124bdb707da7f1Daniel Dunbar std::vector<std::string> PluginArgs; 1083177aae51a21f61ab483c52f97124bdb707da7f1Daniel Dunbar 1095aa74affa5d61d04c4b034b3722ca41aec0cba6eNico Weber /// The list of plugin actions to run in addition to the normal action. 1105aa74affa5d61d04c4b034b3722ca41aec0cba6eNico Weber std::vector<std::string> AddPluginActions; 1115aa74affa5d61d04c4b034b3722ca41aec0cba6eNico Weber 112f25649c74397d2620e6ac61f1045261644707c80Nico Weber /// Args to pass to the additional plugins 113f25649c74397d2620e6ac61f1045261644707c80Nico Weber std::vector<std::vector<std::string> > AddPluginArgs; 114f25649c74397d2620e6ac61f1045261644707c80Nico Weber 115efba227cc5459554eca466aafe786b5132dcb68cDaniel Dunbar /// The list of plugins to load. 116efba227cc5459554eca466aafe786b5132dcb68cDaniel Dunbar std::vector<std::string> Plugins; 117efba227cc5459554eca466aafe786b5132dcb68cDaniel Dunbar 1189bed8798964d9f07599c2c9199701f86fbc70e20Douglas Gregor /// \brief The list of AST files to merge. 1199bed8798964d9f07599c2c9199701f86fbc70e20Douglas Gregor std::vector<std::string> ASTMergeFiles; 1209bed8798964d9f07599c2c9199701f86fbc70e20Douglas Gregor 121e55fd871b0cf3e4ebc708cf46831908d74eab40aSebastian Redl /// \brief The list of modules to import. 122e55fd871b0cf3e4ebc708cf46831908d74eab40aSebastian Redl std::vector<std::string> Modules; 123e55fd871b0cf3e4ebc708cf46831908d74eab40aSebastian Redl 1243f87fb08dd502309960646db01099fb4c1be9a7cDaniel Dunbar /// \brief A list of arguments to forward to LLVM's option processing; this 1253f87fb08dd502309960646db01099fb4c1be9a7cDaniel Dunbar /// should only be used for debugging and experimental features. 1263f87fb08dd502309960646db01099fb4c1be9a7cDaniel Dunbar std::vector<std::string> LLVMArgs; 1273f87fb08dd502309960646db01099fb4c1be9a7cDaniel Dunbar 12826266885d6eba8ee197577dd42a8e68a0e4dd2e8Daniel Dunbarpublic: 12926266885d6eba8ee197577dd42a8e68a0e4dd2e8Daniel Dunbar FrontendOptions() { 13026266885d6eba8ee197577dd42a8e68a0e4dd2e8Daniel Dunbar DisableFree = 0; 1319a8a83b8fe5be9a4ca20ec6eeaafaf201ce594f9Daniel Dunbar ProgramAction = frontend::ParseSyntaxOnly; 132d10c5b88334d860d19284032a7126dc2219f57edDaniel Dunbar ActionName = ""; 13326266885d6eba8ee197577dd42a8e68a0e4dd2e8Daniel Dunbar RelocatablePCH = 0; 134d6ac4524cd441808f152f7e10900a8315ea31c08Sebastian Redl ChainedPCH = 0; 1359b5e9ae08defd14441acca1d7d4502b933bf6c5aDaniel Dunbar ShowHelp = 0; 136914474ca51d202369241a81013208833a6bb3f12Daniel Dunbar ShowMacrosInCodeCompletion = 0; 137d8e8a58ee35ab334ab9d0c2154dca029c1822e8aDouglas Gregor ShowCodePatternsInCodeCompletion = 0; 1388071e4212ae08f8014e0c3ae6d18b7388003a5ccDouglas Gregor ShowGlobalSymbolsInCodeCompletion = 1; 13926266885d6eba8ee197577dd42a8e68a0e4dd2e8Daniel Dunbar ShowStats = 0; 14026266885d6eba8ee197577dd42a8e68a0e4dd2e8Daniel Dunbar ShowTimers = 0; 1419b5e9ae08defd14441acca1d7d4502b933bf6c5aDaniel Dunbar ShowVersion = 0; 142f85e193739c953358c865005855253af4f68a497John McCall ARCMTAction = ARCMT_None; 14326266885d6eba8ee197577dd42a8e68a0e4dd2e8Daniel Dunbar } 144fbe2fafe317a757031e4f24026a77dd305607d32Daniel Dunbar 145fbe2fafe317a757031e4f24026a77dd305607d32Daniel Dunbar /// getInputKindForExtension - Return the appropriate input kind for a file 146fbe2fafe317a757031e4f24026a77dd305607d32Daniel Dunbar /// extension. For example, "c" would return IK_C. 147fbe2fafe317a757031e4f24026a77dd305607d32Daniel Dunbar /// 148fbe2fafe317a757031e4f24026a77dd305607d32Daniel Dunbar /// \return The input kind for the extension, or IK_None if the extension is 149fbe2fafe317a757031e4f24026a77dd305607d32Daniel Dunbar /// not recognized. 150fbe2fafe317a757031e4f24026a77dd305607d32Daniel Dunbar static InputKind getInputKindForExtension(llvm::StringRef Extension); 15126266885d6eba8ee197577dd42a8e68a0e4dd2e8Daniel Dunbar}; 15226266885d6eba8ee197577dd42a8e68a0e4dd2e8Daniel Dunbar 15326266885d6eba8ee197577dd42a8e68a0e4dd2e8Daniel Dunbar} // end namespace clang 15426266885d6eba8ee197577dd42a8e68a0e4dd2e8Daniel Dunbar 15526266885d6eba8ee197577dd42a8e68a0e4dd2e8Daniel Dunbar#endif 156