]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - include/clang/Frontend/FrontendOptions.h
Update clang to r90226.
[FreeBSD/FreeBSD.git] / include / clang / Frontend / FrontendOptions.h
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
18 namespace clang {
19
20 namespace 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     RewriteBlocks,          ///< ObjC->C Rewriter for Blocks.
45     RewriteMacros,          ///< Expand macros but not #includes.
46     RewriteObjC,            ///< ObjC->C Rewriter.
47     RewriteTest,            ///< Rewriter playground
48     RunAnalysis,            ///< Run one or more source code analyses.
49     RunPreprocessorOnly     ///< Just lex, no output.
50   };
51 }
52
53 /// FrontendOptions - Options for controlling the behavior of the frontend.
54 class FrontendOptions {
55 public:
56   enum InputKind {
57     IK_None,
58     IK_Asm,
59     IK_C,
60     IK_CXX,
61     IK_ObjC,
62     IK_ObjCXX,
63     IK_PreprocessedC,
64     IK_PreprocessedCXX,
65     IK_PreprocessedObjC,
66     IK_PreprocessedObjCXX,
67     IK_OpenCL,
68     IK_AST
69   };
70
71   unsigned DebugCodeCompletionPrinter : 1; ///< Use the debug printer for code
72                                            /// completion results.
73   unsigned DisableFree : 1;                ///< Disable memory freeing on exit.
74   unsigned EmptyInputOnly : 1;             ///< Force input files to be treated
75                                            /// as if they were empty, for timing
76                                            /// the frontend startup.
77   unsigned RelocatablePCH : 1;             ///< When generating PCH files,
78                                            /// instruct the PCH writer to create
79                                            /// relocatable PCH files.
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
87   /// The input files and their types.
88   std::vector<std::pair<InputKind, std::string> > Inputs;
89
90   /// The output file, if any.
91   std::string OutputFile;
92
93   /// If given, the name for a C++ class to view the inheritance of.
94   std::string ViewClassInheritance;
95
96   /// A list of locations to apply fix-its at.
97   std::vector<ParsedSourceLocation> FixItLocations;
98
99   /// If given, enable code completion at the provided location.
100   ParsedSourceLocation CodeCompletionAt;
101
102   /// The frontend action to perform.
103   frontend::ActionKind ProgramAction;
104
105   /// The name of the action to run when using a plugin action.
106   std::string ActionName;
107
108 public:
109   FrontendOptions() {
110     DebugCodeCompletionPrinter = 1;
111     DisableFree = 0;
112     EmptyInputOnly = 0;
113     ProgramAction = frontend::ParseSyntaxOnly;
114     ActionName = "";
115     RelocatablePCH = 0;
116     ShowMacrosInCodeCompletion = 0;
117     ShowStats = 0;
118     ShowTimers = 0;
119   }
120
121   /// getInputKindForExtension - Return the appropriate input kind for a file
122   /// extension. For example, "c" would return IK_C.
123   ///
124   /// \return The input kind for the extension, or IK_None if the extension is
125   /// not recognized.
126   static InputKind getInputKindForExtension(llvm::StringRef Extension);
127 };
128
129 }  // end namespace clang
130
131 #endif