blob: 0753686a3476ced51d90aa0e3b13d04184088d5f [file] [log] [blame]
Daniel Dunbar4ee24092009-11-14 10:42:35 +00001//===--- FrontendAction.cpp -----------------------------------------------===//
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#include "clang/Frontend/FrontendAction.h"
Sebastian Redlffaab3e2010-07-30 00:29:29 +000011#include "clang/AST/ASTConsumer.h"
Daniel Dunbar4ee24092009-11-14 10:42:35 +000012#include "clang/AST/ASTContext.h"
Nico Weber5aa74af2011-01-25 20:34:14 +000013#include "clang/AST/DeclGroup.h"
Daniel Dunbar4ee24092009-11-14 10:42:35 +000014#include "clang/Lex/HeaderSearch.h"
15#include "clang/Lex/Preprocessor.h"
16#include "clang/Frontend/ASTUnit.h"
17#include "clang/Frontend/CompilerInstance.h"
18#include "clang/Frontend/FrontendDiagnostic.h"
Nico Weber5aa74af2011-01-25 20:34:14 +000019#include "clang/Frontend/FrontendPluginRegistry.h"
20#include "clang/Frontend/MultiplexConsumer.h"
John McCall19510852010-08-20 18:27:03 +000021#include "clang/Parse/ParseAST.h"
Argyrios Kyrtzidisb9728582010-10-14 20:14:18 +000022#include "clang/Serialization/ASTDeserializationListener.h"
Jonathan D. Turnere735e2d2011-08-05 22:17:03 +000023#include "clang/Serialization/ASTReader.h"
Argyrios Kyrtzidisb0f4b9a2011-03-09 17:21:42 +000024#include "clang/Serialization/ChainedIncludesSource.h"
Daniel Dunbar4ee24092009-11-14 10:42:35 +000025#include "llvm/Support/MemoryBuffer.h"
26#include "llvm/Support/Timer.h"
27#include "llvm/Support/ErrorHandling.h"
28#include "llvm/Support/raw_ostream.h"
29using namespace clang;
30
Argyrios Kyrtzidisb9728582010-10-14 20:14:18 +000031namespace {
32
33/// \brief Dumps deserialized declarations.
34class DeserializedDeclsDumper : public ASTDeserializationListener {
35 ASTDeserializationListener *Previous;
36
37public:
38 DeserializedDeclsDumper(ASTDeserializationListener *Previous)
39 : Previous(Previous) { }
40
41 virtual void DeclRead(serialization::DeclID ID, const Decl *D) {
42 llvm::outs() << "PCH DECL: " << D->getDeclKindName();
43 if (const NamedDecl *ND = dyn_cast<NamedDecl>(D))
44 llvm::outs() << " - " << ND->getNameAsString();
45 llvm::outs() << "\n";
46
47 if (Previous)
48 Previous->DeclRead(ID, D);
49 }
Argyrios Kyrtzidisb9728582010-10-14 20:14:18 +000050};
51
Argyrios Kyrtzidis3e785932010-10-14 20:14:25 +000052 /// \brief Checks deserialized declarations and emits error if a name
53 /// matches one given in command-line using -error-on-deserialized-decl.
54 class DeserializedDeclsChecker : public ASTDeserializationListener {
55 ASTContext &Ctx;
56 std::set<std::string> NamesToCheck;
57 ASTDeserializationListener *Previous;
58
59 public:
60 DeserializedDeclsChecker(ASTContext &Ctx,
61 const std::set<std::string> &NamesToCheck,
62 ASTDeserializationListener *Previous)
63 : Ctx(Ctx), NamesToCheck(NamesToCheck), Previous(Previous) { }
64
65 virtual void DeclRead(serialization::DeclID ID, const Decl *D) {
66 if (const NamedDecl *ND = dyn_cast<NamedDecl>(D))
67 if (NamesToCheck.find(ND->getNameAsString()) != NamesToCheck.end()) {
68 unsigned DiagID
69 = Ctx.getDiagnostics().getCustomDiagID(Diagnostic::Error,
70 "%0 was deserialized");
71 Ctx.getDiagnostics().Report(Ctx.getFullLoc(D->getLocation()), DiagID)
72 << ND->getNameAsString();
73 }
74
75 if (Previous)
76 Previous->DeclRead(ID, D);
77 }
Argyrios Kyrtzidis3e785932010-10-14 20:14:25 +000078};
79
Argyrios Kyrtzidisb9728582010-10-14 20:14:18 +000080} // end anonymous namespace
81
Kovarththanan Rajaratnamf79bafa2009-11-29 09:57:35 +000082FrontendAction::FrontendAction() : Instance(0) {}
Daniel Dunbar4ee24092009-11-14 10:42:35 +000083
84FrontendAction::~FrontendAction() {}
85
Chris Lattner5f9e2722011-07-23 10:55:15 +000086void FrontendAction::setCurrentFile(StringRef Value, InputKind Kind,
Daniel Dunbar685ac662010-06-07 23:25:49 +000087 ASTUnit *AST) {
Daniel Dunbar4ee24092009-11-14 10:42:35 +000088 CurrentFile = Value;
Daniel Dunbar685ac662010-06-07 23:25:49 +000089 CurrentFileKind = Kind;
Daniel Dunbar4ee24092009-11-14 10:42:35 +000090 CurrentASTUnit.reset(AST);
91}
92
Nico Weber5aa74af2011-01-25 20:34:14 +000093ASTConsumer* FrontendAction::CreateWrappedASTConsumer(CompilerInstance &CI,
Chris Lattner5f9e2722011-07-23 10:55:15 +000094 StringRef InFile) {
Nico Weber5aa74af2011-01-25 20:34:14 +000095 ASTConsumer* Consumer = CreateASTConsumer(CI, InFile);
96 if (!Consumer)
97 return 0;
98
99 if (CI.getFrontendOpts().AddPluginActions.size() == 0)
100 return Consumer;
101
102 // Make sure the non-plugin consumer is first, so that plugins can't
103 // modifiy the AST.
104 std::vector<ASTConsumer*> Consumers(1, Consumer);
105
106 for (size_t i = 0, e = CI.getFrontendOpts().AddPluginActions.size();
107 i != e; ++i) {
108 // This is O(|plugins| * |add_plugins|), but since both numbers are
109 // way below 50 in practice, that's ok.
110 for (FrontendPluginRegistry::iterator
111 it = FrontendPluginRegistry::begin(),
112 ie = FrontendPluginRegistry::end();
113 it != ie; ++it) {
114 if (it->getName() == CI.getFrontendOpts().AddPluginActions[i]) {
115 llvm::OwningPtr<PluginASTAction> P(it->instantiate());
116 FrontendAction* c = P.get();
Nico Weberf25649c2011-01-29 21:21:49 +0000117 if (P->ParseArgs(CI, CI.getFrontendOpts().AddPluginArgs[i]))
Nico Weber5aa74af2011-01-25 20:34:14 +0000118 Consumers.push_back(c->CreateASTConsumer(CI, InFile));
119 }
120 }
121 }
122
123 return new MultiplexConsumer(Consumers);
124}
125
Daniel Dunbar4ee24092009-11-14 10:42:35 +0000126bool FrontendAction::BeginSourceFile(CompilerInstance &CI,
Chris Lattner5f9e2722011-07-23 10:55:15 +0000127 StringRef Filename,
Daniel Dunbard3598a62010-06-07 23:23:06 +0000128 InputKind InputKind) {
Daniel Dunbar4ee24092009-11-14 10:42:35 +0000129 assert(!Instance && "Already processing a source file!");
130 assert(!Filename.empty() && "Unexpected empty filename!");
Daniel Dunbar685ac662010-06-07 23:25:49 +0000131 setCurrentFile(Filename, InputKind);
Daniel Dunbar4ee24092009-11-14 10:42:35 +0000132 setCompilerInstance(&CI);
133
Argyrios Kyrtzidise665d692011-06-18 00:53:41 +0000134 if (!BeginInvocation(CI))
135 goto failure;
136
Daniel Dunbar4ee24092009-11-14 10:42:35 +0000137 // AST files follow a very different path, since they share objects via the
138 // AST unit.
Daniel Dunbar20560482010-06-07 23:23:50 +0000139 if (InputKind == IK_AST) {
Daniel Dunbar4ee24092009-11-14 10:42:35 +0000140 assert(!usesPreprocessorOnly() &&
141 "Attempt to pass AST file to preprocessor only action!");
Daniel Dunbareb58d832010-06-07 23:24:43 +0000142 assert(hasASTFileSupport() &&
143 "This action does not have AST file support!");
Daniel Dunbar4ee24092009-11-14 10:42:35 +0000144
Douglas Gregor28019772010-04-05 23:52:57 +0000145 llvm::IntrusiveRefCntPtr<Diagnostic> Diags(&CI.getDiagnostics());
Daniel Dunbar4ee24092009-11-14 10:42:35 +0000146 std::string Error;
Argyrios Kyrtzidis389db162010-11-03 22:45:23 +0000147 ASTUnit *AST = ASTUnit::LoadFromASTFile(Filename, Diags,
148 CI.getFileSystemOpts());
Daniel Dunbar5262fda2009-12-03 01:45:44 +0000149 if (!AST)
Daniel Dunbar4ee24092009-11-14 10:42:35 +0000150 goto failure;
Daniel Dunbar4ee24092009-11-14 10:42:35 +0000151
Daniel Dunbar685ac662010-06-07 23:25:49 +0000152 setCurrentFile(Filename, InputKind, AST);
Daniel Dunbar4ee24092009-11-14 10:42:35 +0000153
154 // Set the shared objects, these are reset when we finish processing the
155 // file, otherwise the CompilerInstance will happily destroy them.
156 CI.setFileManager(&AST->getFileManager());
157 CI.setSourceManager(&AST->getSourceManager());
158 CI.setPreprocessor(&AST->getPreprocessor());
159 CI.setASTContext(&AST->getASTContext());
160
161 // Initialize the action.
162 if (!BeginSourceFileAction(CI, Filename))
163 goto failure;
164
165 /// Create the AST consumer.
Nico Weber5aa74af2011-01-25 20:34:14 +0000166 CI.setASTConsumer(CreateWrappedASTConsumer(CI, Filename));
Daniel Dunbar4ee24092009-11-14 10:42:35 +0000167 if (!CI.hasASTConsumer())
168 goto failure;
169
170 return true;
171 }
172
Daniel Dunbarfaddc3e2010-06-07 23:26:47 +0000173 // Set up the file and source managers, if needed.
Daniel Dunbar20560482010-06-07 23:23:50 +0000174 if (!CI.hasFileManager())
175 CI.createFileManager();
176 if (!CI.hasSourceManager())
Chris Lattner39b49bc2010-11-23 08:35:12 +0000177 CI.createSourceManager(CI.getFileManager());
Daniel Dunbarfaddc3e2010-06-07 23:26:47 +0000178
179 // IR files bypass the rest of initialization.
180 if (InputKind == IK_LLVM_IR) {
181 assert(hasIRSupport() &&
182 "This action does not have IR file support!");
183
184 // Inform the diagnostic client we are processing a source file.
185 CI.getDiagnosticClient().BeginSourceFile(CI.getLangOpts(), 0);
186
187 // Initialize the action.
188 if (!BeginSourceFileAction(CI, Filename))
189 goto failure;
190
191 return true;
192 }
193
194 // Set up the preprocessor.
Daniel Dunbar20560482010-06-07 23:23:50 +0000195 CI.createPreprocessor();
196
Daniel Dunbar4ee24092009-11-14 10:42:35 +0000197 // Inform the diagnostic client we are processing a source file.
198 CI.getDiagnosticClient().BeginSourceFile(CI.getLangOpts(),
199 &CI.getPreprocessor());
200
201 // Initialize the action.
202 if (!BeginSourceFileAction(CI, Filename))
203 goto failure;
204
205 /// Create the AST context and consumer unless this is a preprocessor only
206 /// action.
207 if (!usesPreprocessorOnly()) {
208 CI.createASTContext();
Daniel Dunbar4ee24092009-11-14 10:42:35 +0000209
Nico Weber5aa74af2011-01-25 20:34:14 +0000210 llvm::OwningPtr<ASTConsumer> Consumer(
211 CreateWrappedASTConsumer(CI, Filename));
Fariborz Jahaniand3057192010-10-29 19:49:13 +0000212 if (!Consumer)
213 goto failure;
Sebastian Redlffaab3e2010-07-30 00:29:29 +0000214
Argyrios Kyrtzidis7b903402010-10-24 17:26:36 +0000215 CI.getASTContext().setASTMutationListener(Consumer->GetASTMutationListener());
216
Argyrios Kyrtzidisb0f4b9a2011-03-09 17:21:42 +0000217 if (!CI.getPreprocessorOpts().ChainedIncludes.empty()) {
218 // Convert headers to PCH and chain them.
219 llvm::OwningPtr<ExternalASTSource> source;
220 source.reset(ChainedIncludesSource::create(CI));
221 if (!source)
222 goto failure;
223 CI.getASTContext().setExternalSource(source);
224
225 } else if (!CI.getPreprocessorOpts().ImplicitPCHInclude.empty()) {
226 // Use PCH.
Daniel Dunbar4ee24092009-11-14 10:42:35 +0000227 assert(hasPCHSupport() && "This action does not have PCH support!");
Douglas Gregorf62d43d2011-07-19 16:10:42 +0000228 ASTDeserializationListener *DeserialListener =
229 Consumer->GetASTDeserializationListener();
Argyrios Kyrtzidisb9728582010-10-14 20:14:18 +0000230 if (CI.getPreprocessorOpts().DumpDeserializedPCHDecls)
231 DeserialListener = new DeserializedDeclsDumper(DeserialListener);
Argyrios Kyrtzidis3e785932010-10-14 20:14:25 +0000232 if (!CI.getPreprocessorOpts().DeserializedPCHDeclsToErrorOn.empty())
233 DeserialListener = new DeserializedDeclsChecker(CI.getASTContext(),
234 CI.getPreprocessorOpts().DeserializedPCHDeclsToErrorOn,
235 DeserialListener);
Daniel Dunbar4ee24092009-11-14 10:42:35 +0000236 CI.createPCHExternalASTSource(
Douglas Gregorfae3b2f2010-07-27 00:27:13 +0000237 CI.getPreprocessorOpts().ImplicitPCHInclude,
Sebastian Redlffaab3e2010-07-30 00:29:29 +0000238 CI.getPreprocessorOpts().DisablePCHValidation,
Douglas Gregor8ef6c8c2011-02-05 19:42:43 +0000239 CI.getPreprocessorOpts().DisableStatCache,
Argyrios Kyrtzidisb9728582010-10-14 20:14:18 +0000240 DeserialListener);
Daniel Dunbar4ee24092009-11-14 10:42:35 +0000241 if (!CI.getASTContext().getExternalSource())
242 goto failure;
Jonathan D. Turnere735e2d2011-08-05 22:17:03 +0000243 } else if (!CI.getPreprocessorOpts().Modules.empty()) {
244 // Use PCH.
245 assert(hasPCHSupport() && "This action does not have PCH support!");
246 ASTDeserializationListener *DeserialListener =
247 Consumer->GetASTDeserializationListener();
248 if (CI.getPreprocessorOpts().DumpDeserializedPCHDecls)
249 DeserialListener = new DeserializedDeclsDumper(DeserialListener);
250 if (!CI.getPreprocessorOpts().DeserializedPCHDeclsToErrorOn.empty())
251 DeserialListener = new DeserializedDeclsChecker(CI.getASTContext(),
252 CI.getPreprocessorOpts().DeserializedPCHDeclsToErrorOn,
253 DeserialListener);
254
255 CI.createPCHExternalASTSource(CI.getPreprocessorOpts().Modules[0],
256 true, true, DeserialListener);
257
258 for (unsigned I = 1, E = CI.getPreprocessorOpts().Modules.size(); I != E;
259 ++I) {
260
261 ASTReader *ModMgr = CI.getModuleManager();
262 ModMgr->ReadAST(CI.getPreprocessorOpts().Modules[I],
263 serialization::MK_Module);
264 }
265 if (!CI.getASTContext().getExternalSource())
266 goto failure;
Daniel Dunbar4ee24092009-11-14 10:42:35 +0000267 }
Sebastian Redl77f46032010-07-09 21:00:24 +0000268
Sebastian Redlffaab3e2010-07-30 00:29:29 +0000269 CI.setASTConsumer(Consumer.take());
Sebastian Redl77f46032010-07-09 21:00:24 +0000270 if (!CI.hasASTConsumer())
271 goto failure;
Daniel Dunbar4ee24092009-11-14 10:42:35 +0000272 }
273
Jonathan D. Turnere735e2d2011-08-05 22:17:03 +0000274 // Initialize built-in info as long as we aren't using an external AST
Daniel Dunbar4ee24092009-11-14 10:42:35 +0000275 // source.
276 if (!CI.hasASTContext() || !CI.getASTContext().getExternalSource()) {
277 Preprocessor &PP = CI.getPreprocessor();
278 PP.getBuiltinInfo().InitializeBuiltins(PP.getIdentifierTable(),
Fariborz Jahanian67aba812010-11-30 17:35:24 +0000279 PP.getLangOptions());
Daniel Dunbar4ee24092009-11-14 10:42:35 +0000280 }
281
282 return true;
283
284 // If we failed, reset state since the client will not end up calling the
285 // matching EndSourceFile().
286 failure:
287 if (isCurrentFileAST()) {
Ted Kremenek4f327862011-03-21 18:40:17 +0000288 CI.setASTContext(0);
289 CI.setPreprocessor(0);
290 CI.setSourceManager(0);
291 CI.setFileManager(0);
Daniel Dunbar4ee24092009-11-14 10:42:35 +0000292 }
293
294 CI.getDiagnosticClient().EndSourceFile();
Daniel Dunbar685ac662010-06-07 23:25:49 +0000295 setCurrentFile("", IK_None);
Daniel Dunbar4ee24092009-11-14 10:42:35 +0000296 setCompilerInstance(0);
297 return false;
298}
299
300void FrontendAction::Execute() {
301 CompilerInstance &CI = getCompilerInstance();
302
303 // Initialize the main file entry. This needs to be delayed until after PCH
304 // has loaded.
305 if (isCurrentFileAST()) {
306 // Set the main file ID to an empty file.
307 //
308 // FIXME: We probably shouldn't need this, but for now this is the
309 // simplest way to reuse the logic in ParseAST.
310 const char *EmptyStr = "";
311 llvm::MemoryBuffer *SB =
Chris Lattnera0a270c2010-04-05 22:42:27 +0000312 llvm::MemoryBuffer::getMemBuffer(EmptyStr, "<dummy input>");
Daniel Dunbar4ee24092009-11-14 10:42:35 +0000313 CI.getSourceManager().createMainFileIDForMemBuffer(SB);
314 } else {
315 if (!CI.InitializeSourceManager(getCurrentFile()))
316 return;
317 }
318
Kovarththanan Rajaratnamf79bafa2009-11-29 09:57:35 +0000319 if (CI.hasFrontendTimer()) {
320 llvm::TimeRegion Timer(CI.getFrontendTimer());
321 ExecuteAction();
322 }
323 else ExecuteAction();
Daniel Dunbar4ee24092009-11-14 10:42:35 +0000324}
325
326void FrontendAction::EndSourceFile() {
327 CompilerInstance &CI = getCompilerInstance();
328
Douglas Gregor92b97f22011-02-09 18:47:31 +0000329 // Inform the diagnostic client we are done with this source file.
330 CI.getDiagnosticClient().EndSourceFile();
331
Daniel Dunbar4ee24092009-11-14 10:42:35 +0000332 // Finalize the action.
333 EndSourceFileAction();
334
335 // Release the consumer and the AST, in that order since the consumer may
336 // perform actions in its destructor which require the context.
337 //
338 // FIXME: There is more per-file stuff we could just drop here?
339 if (CI.getFrontendOpts().DisableFree) {
340 CI.takeASTConsumer();
Douglas Gregorf18d0d82010-08-12 23:31:19 +0000341 if (!isCurrentFileAST()) {
342 CI.takeSema();
Ted Kremenek4f327862011-03-21 18:40:17 +0000343 CI.resetAndLeakASTContext();
Douglas Gregorf18d0d82010-08-12 23:31:19 +0000344 }
Daniel Dunbar4ee24092009-11-14 10:42:35 +0000345 } else {
Douglas Gregorf18d0d82010-08-12 23:31:19 +0000346 if (!isCurrentFileAST()) {
347 CI.setSema(0);
Daniel Dunbar4ee24092009-11-14 10:42:35 +0000348 CI.setASTContext(0);
Douglas Gregorf18d0d82010-08-12 23:31:19 +0000349 }
350 CI.setASTConsumer(0);
Daniel Dunbar4ee24092009-11-14 10:42:35 +0000351 }
352
Daniel Dunbardbd82092010-03-23 05:09:10 +0000353 // Inform the preprocessor we are done.
354 if (CI.hasPreprocessor())
355 CI.getPreprocessor().EndSourceFile();
356
Daniel Dunbar4ee24092009-11-14 10:42:35 +0000357 if (CI.getFrontendOpts().ShowStats) {
358 llvm::errs() << "\nSTATISTICS FOR '" << getCurrentFile() << "':\n";
359 CI.getPreprocessor().PrintStats();
360 CI.getPreprocessor().getIdentifierTable().PrintStats();
361 CI.getPreprocessor().getHeaderSearchInfo().PrintStats();
362 CI.getSourceManager().PrintStats();
363 llvm::errs() << "\n";
364 }
365
366 // Cleanup the output streams, and erase the output files if we encountered
367 // an error.
Argyrios Kyrtzidisbe3aab62010-11-18 21:47:07 +0000368 CI.clearOutputFiles(/*EraseFiles=*/CI.getDiagnostics().hasErrorOccurred());
Daniel Dunbar4ee24092009-11-14 10:42:35 +0000369
Daniel Dunbar4ee24092009-11-14 10:42:35 +0000370 if (isCurrentFileAST()) {
Douglas Gregorf18d0d82010-08-12 23:31:19 +0000371 CI.takeSema();
Ted Kremenek4f327862011-03-21 18:40:17 +0000372 CI.resetAndLeakASTContext();
373 CI.resetAndLeakPreprocessor();
374 CI.resetAndLeakSourceManager();
375 CI.resetAndLeakFileManager();
Daniel Dunbar4ee24092009-11-14 10:42:35 +0000376 }
377
378 setCompilerInstance(0);
Daniel Dunbar685ac662010-06-07 23:25:49 +0000379 setCurrentFile("", IK_None);
Daniel Dunbar4ee24092009-11-14 10:42:35 +0000380}
381
382//===----------------------------------------------------------------------===//
383// Utility Actions
384//===----------------------------------------------------------------------===//
385
386void ASTFrontendAction::ExecuteAction() {
387 CompilerInstance &CI = getCompilerInstance();
388
389 // FIXME: Move the truncation aspect of this into Sema, we delayed this till
390 // here so the source manager would be initialized.
391 if (hasCodeCompletionSupport() &&
392 !CI.getFrontendOpts().CodeCompletionAt.FileName.empty())
393 CI.createCodeCompletionConsumer();
394
395 // Use a code completion consumer?
396 CodeCompleteConsumer *CompletionConsumer = 0;
397 if (CI.hasCodeCompletionConsumer())
398 CompletionConsumer = &CI.getCodeCompletionConsumer();
399
Douglas Gregorf18d0d82010-08-12 23:31:19 +0000400 if (!CI.hasSema())
401 CI.createSema(usesCompleteTranslationUnit(), CompletionConsumer);
402
403 ParseAST(CI.getSema(), CI.getFrontendOpts().ShowStats);
Daniel Dunbar4ee24092009-11-14 10:42:35 +0000404}
405
406ASTConsumer *
407PreprocessorFrontendAction::CreateASTConsumer(CompilerInstance &CI,
Chris Lattner5f9e2722011-07-23 10:55:15 +0000408 StringRef InFile) {
Jeffrey Yasskin9f61aa92009-12-12 05:05:38 +0000409 llvm_unreachable("Invalid CreateASTConsumer on preprocessor action!");
Daniel Dunbar4ee24092009-11-14 10:42:35 +0000410}
Chandler Carruthf7f81882011-06-16 16:17:05 +0000411
412ASTConsumer *WrapperFrontendAction::CreateASTConsumer(CompilerInstance &CI,
Chris Lattner5f9e2722011-07-23 10:55:15 +0000413 StringRef InFile) {
Chandler Carruthf7f81882011-06-16 16:17:05 +0000414 return WrappedAction->CreateASTConsumer(CI, InFile);
415}
Argyrios Kyrtzidise665d692011-06-18 00:53:41 +0000416bool WrapperFrontendAction::BeginInvocation(CompilerInstance &CI) {
417 return WrappedAction->BeginInvocation(CI);
418}
Chandler Carruthf7f81882011-06-16 16:17:05 +0000419bool WrapperFrontendAction::BeginSourceFileAction(CompilerInstance &CI,
Chris Lattner5f9e2722011-07-23 10:55:15 +0000420 StringRef Filename) {
Argyrios Kyrtzidise665d692011-06-18 00:53:41 +0000421 WrappedAction->setCurrentFile(getCurrentFile(), getCurrentFileKind());
422 WrappedAction->setCompilerInstance(&CI);
Chandler Carruthf7f81882011-06-16 16:17:05 +0000423 return WrappedAction->BeginSourceFileAction(CI, Filename);
424}
425void WrapperFrontendAction::ExecuteAction() {
426 WrappedAction->ExecuteAction();
427}
428void WrapperFrontendAction::EndSourceFileAction() {
429 WrappedAction->EndSourceFileAction();
430}
431
432bool WrapperFrontendAction::usesPreprocessorOnly() const {
433 return WrappedAction->usesPreprocessorOnly();
434}
435bool WrapperFrontendAction::usesCompleteTranslationUnit() {
436 return WrappedAction->usesCompleteTranslationUnit();
437}
438bool WrapperFrontendAction::hasPCHSupport() const {
439 return WrappedAction->hasPCHSupport();
440}
441bool WrapperFrontendAction::hasASTFileSupport() const {
442 return WrappedAction->hasASTFileSupport();
443}
444bool WrapperFrontendAction::hasIRSupport() const {
445 return WrappedAction->hasIRSupport();
446}
447bool WrapperFrontendAction::hasCodeCompletionSupport() const {
448 return WrappedAction->hasCodeCompletionSupport();
449}
450
451WrapperFrontendAction::WrapperFrontendAction(FrontendAction *WrappedAction)
452 : WrappedAction(WrappedAction) {}
453