]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/clang/include/clang/Frontend/FrontendActions.h
Update xz to release 5.0.0
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / clang / include / clang / Frontend / FrontendActions.h
1 //===-- FrontendActions.h - Useful Frontend Actions -------------*- 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_FRONTENDACTIONS_H
11 #define LLVM_CLANG_FRONTEND_FRONTENDACTIONS_H
12
13 #include "clang/Frontend/FrontendAction.h"
14 #include <string>
15 #include <vector>
16
17 namespace clang {
18
19 //===----------------------------------------------------------------------===//
20 // Custom Consumer Actions
21 //===----------------------------------------------------------------------===//
22
23 class InitOnlyAction : public FrontendAction {
24   virtual void ExecuteAction();
25
26   virtual ASTConsumer *CreateASTConsumer(CompilerInstance &CI,
27                                          llvm::StringRef InFile);
28
29 public:
30   // Don't claim to only use the preprocessor, we want to follow the AST path,
31   // but do nothing.
32   virtual bool usesPreprocessorOnly() const { return false; }
33 };
34
35 //===----------------------------------------------------------------------===//
36 // AST Consumer Actions
37 //===----------------------------------------------------------------------===//
38
39 class ASTPrintAction : public ASTFrontendAction {
40 protected:
41   virtual ASTConsumer *CreateASTConsumer(CompilerInstance &CI,
42                                          llvm::StringRef InFile);
43 };
44
45 class ASTPrintXMLAction : public ASTFrontendAction {
46 protected:
47   virtual ASTConsumer *CreateASTConsumer(CompilerInstance &CI,
48                                          llvm::StringRef InFile);
49 };
50
51 class ASTDumpAction : public ASTFrontendAction {
52 protected:
53   virtual ASTConsumer *CreateASTConsumer(CompilerInstance &CI,
54                                          llvm::StringRef InFile);
55 };
56
57 class ASTViewAction : public ASTFrontendAction {
58 protected:
59   virtual ASTConsumer *CreateASTConsumer(CompilerInstance &CI,
60                                          llvm::StringRef InFile);
61 };
62
63 class DeclContextPrintAction : public ASTFrontendAction {
64 protected:
65   virtual ASTConsumer *CreateASTConsumer(CompilerInstance &CI,
66                                          llvm::StringRef InFile);
67 };
68
69 class GeneratePCHAction : public ASTFrontendAction {
70 protected:
71   virtual ASTConsumer *CreateASTConsumer(CompilerInstance &CI,
72                                          llvm::StringRef InFile);
73
74   virtual bool usesCompleteTranslationUnit() { return false; }
75
76   virtual bool hasASTFileSupport() const { return false; }
77
78 public:
79   /// \brief Compute the AST consumer arguments that will be used to
80   /// create the PCHGenerator instance returned by CreateASTConsumer.
81   ///
82   /// \returns true if an error occurred, false otherwise.
83   static bool ComputeASTConsumerArguments(CompilerInstance &CI,
84                                           llvm::StringRef InFile,
85                                           std::string &Sysroot,
86                                           llvm::raw_ostream *&OS,
87                                           bool &Chaining);
88 };
89
90 class InheritanceViewAction : public ASTFrontendAction {
91 protected:
92   virtual ASTConsumer *CreateASTConsumer(CompilerInstance &CI,
93                                          llvm::StringRef InFile);
94 };
95
96 class SyntaxOnlyAction : public ASTFrontendAction {
97 protected:
98   virtual ASTConsumer *CreateASTConsumer(CompilerInstance &CI,
99                                          llvm::StringRef InFile);
100
101 public:
102   virtual bool hasCodeCompletionSupport() const { return true; }
103 };
104
105 class BoostConAction : public SyntaxOnlyAction {
106 protected:
107   virtual ASTConsumer *CreateASTConsumer(CompilerInstance &CI,
108                                          llvm::StringRef InFile);
109 };
110
111 /**
112  * \brief Frontend action adaptor that merges ASTs together.
113  *
114  * This action takes an existing AST file and "merges" it into the AST
115  * context, producing a merged context. This action is an action
116  * adaptor, which forwards most of its calls to another action that
117  * will consume the merged context.
118  */
119 class ASTMergeAction : public FrontendAction {
120   /// \brief The action that the merge action adapts.
121   FrontendAction *AdaptedAction;
122   
123   /// \brief The set of AST files to merge.
124   std::vector<std::string> ASTFiles;
125
126 protected:
127   virtual ASTConsumer *CreateASTConsumer(CompilerInstance &CI,
128                                          llvm::StringRef InFile);
129
130   virtual bool BeginSourceFileAction(CompilerInstance &CI,
131                                      llvm::StringRef Filename);
132
133   virtual void ExecuteAction();
134   virtual void EndSourceFileAction();
135
136 public:
137   ASTMergeAction(FrontendAction *AdaptedAction,
138                  std::string *ASTFiles, unsigned NumASTFiles);
139   virtual ~ASTMergeAction();
140
141   virtual bool usesPreprocessorOnly() const;
142   virtual bool usesCompleteTranslationUnit();
143   virtual bool hasPCHSupport() const;
144   virtual bool hasASTFileSupport() const;
145   virtual bool hasCodeCompletionSupport() const;
146 };
147
148 class PrintPreambleAction : public FrontendAction {
149 protected:
150   void ExecuteAction();
151   virtual ASTConsumer *CreateASTConsumer(CompilerInstance &, llvm::StringRef) { 
152     return 0; 
153   }
154   
155   virtual bool usesPreprocessorOnly() const { return true; }
156 };
157   
158 //===----------------------------------------------------------------------===//
159 // Preprocessor Actions
160 //===----------------------------------------------------------------------===//
161
162 class DumpRawTokensAction : public PreprocessorFrontendAction {
163 protected:
164   void ExecuteAction();
165 };
166
167 class DumpTokensAction : public PreprocessorFrontendAction {
168 protected:
169   void ExecuteAction();
170 };
171
172 class GeneratePTHAction : public PreprocessorFrontendAction {
173 protected:
174   void ExecuteAction();
175 };
176
177 class PreprocessOnlyAction : public PreprocessorFrontendAction {
178 protected:
179   void ExecuteAction();
180 };
181
182 class PrintPreprocessedAction : public PreprocessorFrontendAction {
183 protected:
184   void ExecuteAction();
185
186   virtual bool hasPCHSupport() const { return true; }
187 };
188   
189 }  // end namespace clang
190
191 #endif