FrontendOptions.h revision 49ac8e63a0622ce049e58decab9e844b1e8c7ecd
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 13#include "clang/Frontend/CommandLineSourceLoc.h" 14#include "llvm/ADT/StringRef.h" 15#include <string> 16#include <vector> 17 18namespace clang { 19 20namespace frontend { 21 enum ActionKind { 22 ASTDump, ///< Parse ASTs and dump them. 23 ASTPrint, ///< Parse ASTs and print them. 24 ASTPrintXML, ///< Parse ASTs and print them in XML. 25 ASTView, ///< Parse ASTs and view them in Graphviz. 26 DumpRawTokens, ///< Dump out raw tokens. 27 DumpRecordLayouts, ///< Dump record layout information. 28 DumpTokens, ///< Dump out preprocessed tokens. 29 EmitAssembly, ///< Emit a .s file. 30 EmitBC, ///< Emit a .bc file. 31 EmitHTML, ///< Translate input source into HTML. 32 EmitLLVM, ///< Emit a .ll file. 33 EmitLLVMOnly, ///< Generate LLVM IR, but do not 34 FixIt, ///< Parse and apply any fixits to the source. 35 GeneratePCH, ///< Generate pre-compiled header. 36 GeneratePTH, ///< Generate pre-tokenized header. 37 InheritanceView, ///< View C++ inheritance for a specified class. 38 ParseNoop, ///< Parse with noop callbacks. 39 ParsePrintCallbacks, ///< Parse and print each callback. 40 ParseSyntaxOnly, ///< Parse and perform semantic analysis. 41 PluginAction, ///< Run a plugin action, \see ActionName. 42 PrintDeclContext, ///< Print DeclContext and their Decls. 43 PrintPreprocessedInput, ///< -E mode. 44 RewriteMacros, ///< Expand macros but not #includes. 45 RewriteObjC, ///< ObjC->C Rewriter. 46 RewriteTest, ///< Rewriter playground 47 RunAnalysis, ///< Run one or more source code analyses. 48 RunPreprocessorOnly ///< Just lex, no output. 49 }; 50} 51 52/// FrontendOptions - Options for controlling the behavior of the frontend. 53class FrontendOptions { 54public: 55 enum InputKind { 56 IK_None, 57 IK_Asm, 58 IK_C, 59 IK_CXX, 60 IK_ObjC, 61 IK_ObjCXX, 62 IK_PreprocessedC, 63 IK_PreprocessedCXX, 64 IK_PreprocessedObjC, 65 IK_PreprocessedObjCXX, 66 IK_OpenCL, 67 IK_AST 68 }; 69 70 unsigned DebugCodeCompletionPrinter : 1; ///< Use the debug printer for code 71 /// completion results. 72 unsigned DisableFree : 1; ///< Disable memory freeing on exit. 73 unsigned EmptyInputOnly : 1; ///< Force input files to be treated 74 /// as if they were empty, for timing 75 /// the frontend startup. 76 unsigned RelocatablePCH : 1; ///< When generating PCH files, 77 /// instruct the PCH writer to create 78 /// relocatable PCH files. 79 unsigned ShowHelp : 1; ///< Show the -help text. 80 unsigned ShowMacrosInCodeCompletion : 1; ///< Show macros in code completion 81 /// results. 82 unsigned ShowStats : 1; ///< Show frontend performance 83 /// metrics and statistics. 84 unsigned ShowTimers : 1; ///< Show timers for individual 85 /// actions. 86 unsigned ShowVersion : 1; ///< Show the -version text. 87 88 /// The input files and their types. 89 std::vector<std::pair<InputKind, std::string> > Inputs; 90 91 /// The output file, if any. 92 std::string OutputFile; 93 94 /// If given, the name for a C++ class to view the inheritance of. 95 std::string ViewClassInheritance; 96 97 /// A list of locations to apply fix-its at. 98 std::vector<ParsedSourceLocation> FixItLocations; 99 100 /// If given, enable code completion at the provided location. 101 ParsedSourceLocation CodeCompletionAt; 102 103 /// The frontend action to perform. 104 frontend::ActionKind ProgramAction; 105 106 /// The name of the action to run when using a plugin action. 107 std::string ActionName; 108 109 /// The list of plugins to load. 110 std::vector<std::string> Plugins; 111 112public: 113 FrontendOptions() { 114 DebugCodeCompletionPrinter = 1; 115 DisableFree = 0; 116 EmptyInputOnly = 0; 117 ProgramAction = frontend::ParseSyntaxOnly; 118 ActionName = ""; 119 RelocatablePCH = 0; 120 ShowHelp = 0; 121 ShowMacrosInCodeCompletion = 0; 122 ShowStats = 0; 123 ShowTimers = 0; 124 ShowVersion = 0; 125 } 126 127 /// getInputKindForExtension - Return the appropriate input kind for a file 128 /// extension. For example, "c" would return IK_C. 129 /// 130 /// \return The input kind for the extension, or IK_None if the extension is 131 /// not recognized. 132 static InputKind getInputKindForExtension(llvm::StringRef Extension); 133}; 134 135} // end namespace clang 136 137#endif 138