1 //===--- 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"
11 #include "clang/AST/ASTConsumer.h"
12 #include "clang/AST/ASTContext.h"
13 #include "clang/AST/DeclGroup.h"
14 #include "clang/Frontend/ASTUnit.h"
15 #include "clang/Frontend/CompilerInstance.h"
16 #include "clang/Frontend/FrontendDiagnostic.h"
17 #include "clang/Frontend/FrontendPluginRegistry.h"
18 #include "clang/Frontend/LayoutOverrideSource.h"
19 #include "clang/Frontend/MultiplexConsumer.h"
20 #include "clang/Frontend/Utils.h"
21 #include "clang/Lex/HeaderSearch.h"
22 #include "clang/Lex/Preprocessor.h"
23 #include "clang/Lex/PreprocessorOptions.h"
24 #include "clang/Parse/ParseAST.h"
25 #include "clang/Serialization/ASTDeserializationListener.h"
26 #include "clang/Serialization/ASTReader.h"
27 #include "clang/Serialization/GlobalModuleIndex.h"
28 #include "llvm/Support/ErrorHandling.h"
29 #include "llvm/Support/FileSystem.h"
30 #include "llvm/Support/Path.h"
31 #include "llvm/Support/Timer.h"
32 #include "llvm/Support/raw_ostream.h"
33 #include <system_error>
34 using namespace clang;
35 
36 LLVM_INSTANTIATE_REGISTRY(FrontendPluginRegistry)
37 
38 namespace {
39 
40 class DelegatingDeserializationListener : public ASTDeserializationListener {
41   ASTDeserializationListener *Previous;
42   bool DeletePrevious;
43 
44 public:
45   explicit DelegatingDeserializationListener(
46       ASTDeserializationListener *Previous, bool DeletePrevious)
47       : Previous(Previous), DeletePrevious(DeletePrevious) {}
48   ~DelegatingDeserializationListener() override {
49     if (DeletePrevious)
50       delete Previous;
51   }
52 
53   void ReaderInitialized(ASTReader *Reader) override {
54     if (Previous)
55       Previous->ReaderInitialized(Reader);
56   }
57   void IdentifierRead(serialization::IdentID ID,
58                       IdentifierInfo *II) override {
59     if (Previous)
60       Previous->IdentifierRead(ID, II);
61   }
62   void TypeRead(serialization::TypeIdx Idx, QualType T) override {
63     if (Previous)
64       Previous->TypeRead(Idx, T);
65   }
66   void DeclRead(serialization::DeclID ID, const Decl *D) override {
67     if (Previous)
68       Previous->DeclRead(ID, D);
69   }
70   void SelectorRead(serialization::SelectorID ID, Selector Sel) override {
71     if (Previous)
72       Previous->SelectorRead(ID, Sel);
73   }
74   void MacroDefinitionRead(serialization::PreprocessedEntityID PPID,
75                            MacroDefinitionRecord *MD) override {
76     if (Previous)
77       Previous->MacroDefinitionRead(PPID, MD);
78   }
79 };
80 
81 /// \brief Dumps deserialized declarations.
82 class DeserializedDeclsDumper : public DelegatingDeserializationListener {
83 public:
84   explicit DeserializedDeclsDumper(ASTDeserializationListener *Previous,
85                                    bool DeletePrevious)
86       : DelegatingDeserializationListener(Previous, DeletePrevious) {}
87 
88   void DeclRead(serialization::DeclID ID, const Decl *D) override {
89     llvm::outs() << "PCH DECL: " << D->getDeclKindName();
90     if (const NamedDecl *ND = dyn_cast<NamedDecl>(D))
91       llvm::outs() << " - " << *ND;
92     llvm::outs() << "\n";
93 
94     DelegatingDeserializationListener::DeclRead(ID, D);
95   }
96 };
97 
98 /// \brief Checks deserialized declarations and emits error if a name
99 /// matches one given in command-line using -error-on-deserialized-decl.
100 class DeserializedDeclsChecker : public DelegatingDeserializationListener {
101   ASTContext &Ctx;
102   std::set<std::string> NamesToCheck;
103 
104 public:
105   DeserializedDeclsChecker(ASTContext &Ctx,
106                            const std::set<std::string> &NamesToCheck,
107                            ASTDeserializationListener *Previous,
108                            bool DeletePrevious)
109       : DelegatingDeserializationListener(Previous, DeletePrevious), Ctx(Ctx),
110         NamesToCheck(NamesToCheck) {}
111 
112   void DeclRead(serialization::DeclID ID, const Decl *D) override {
113     if (const NamedDecl *ND = dyn_cast<NamedDecl>(D))
114       if (NamesToCheck.find(ND->getNameAsString()) != NamesToCheck.end()) {
115         unsigned DiagID
116           = Ctx.getDiagnostics().getCustomDiagID(DiagnosticsEngine::Error,
117                                                  "%0 was deserialized");
118         Ctx.getDiagnostics().Report(Ctx.getFullLoc(D->getLocation()), DiagID)
119             << ND->getNameAsString();
120       }
121 
122     DelegatingDeserializationListener::DeclRead(ID, D);
123   }
124 };
125 
126 } // end anonymous namespace
127 
128 FrontendAction::FrontendAction() : Instance(nullptr) {}
129 
130 FrontendAction::~FrontendAction() {}
131 
132 void FrontendAction::setCurrentInput(const FrontendInputFile &CurrentInput,
133                                      std::unique_ptr<ASTUnit> AST) {
134   this->CurrentInput = CurrentInput;
135   CurrentASTUnit = std::move(AST);
136 }
137 
138 std::unique_ptr<ASTConsumer>
139 FrontendAction::CreateWrappedASTConsumer(CompilerInstance &CI,
140                                          StringRef InFile) {
141   std::unique_ptr<ASTConsumer> Consumer = CreateASTConsumer(CI, InFile);
142   if (!Consumer)
143     return nullptr;
144 
145   // If there are no registered plugins we don't need to wrap the consumer
146   if (FrontendPluginRegistry::begin() == FrontendPluginRegistry::end())
147     return Consumer;
148 
149   // Collect the list of plugins that go before the main action (in Consumers)
150   // or after it (in AfterConsumers)
151   std::vector<std::unique_ptr<ASTConsumer>> Consumers;
152   std::vector<std::unique_ptr<ASTConsumer>> AfterConsumers;
153   for (FrontendPluginRegistry::iterator it = FrontendPluginRegistry::begin(),
154                                         ie = FrontendPluginRegistry::end();
155        it != ie; ++it) {
156     std::unique_ptr<PluginASTAction> P = it->instantiate();
157     PluginASTAction::ActionType ActionType = P->getActionType();
158     if (ActionType == PluginASTAction::Cmdline) {
159       // This is O(|plugins| * |add_plugins|), but since both numbers are
160       // way below 50 in practice, that's ok.
161       for (size_t i = 0, e = CI.getFrontendOpts().AddPluginActions.size();
162            i != e; ++i) {
163         if (it->getName() == CI.getFrontendOpts().AddPluginActions[i]) {
164           ActionType = PluginASTAction::AddAfterMainAction;
165           break;
166         }
167       }
168     }
169     if ((ActionType == PluginASTAction::AddBeforeMainAction ||
170          ActionType == PluginASTAction::AddAfterMainAction) &&
171         P->ParseArgs(CI, CI.getFrontendOpts().PluginArgs[it->getName()])) {
172       std::unique_ptr<ASTConsumer> PluginConsumer = P->CreateASTConsumer(CI, InFile);
173       if (ActionType == PluginASTAction::AddBeforeMainAction) {
174         Consumers.push_back(std::move(PluginConsumer));
175       } else {
176         AfterConsumers.push_back(std::move(PluginConsumer));
177       }
178     }
179   }
180 
181   // Add to Consumers the main consumer, then all the plugins that go after it
182   Consumers.push_back(std::move(Consumer));
183   for (auto &C : AfterConsumers) {
184     Consumers.push_back(std::move(C));
185   }
186 
187   return llvm::make_unique<MultiplexConsumer>(std::move(Consumers));
188 }
189 
190 bool FrontendAction::BeginSourceFile(CompilerInstance &CI,
191                                      const FrontendInputFile &Input) {
192   assert(!Instance && "Already processing a source file!");
193   assert(!Input.isEmpty() && "Unexpected empty filename!");
194   setCurrentInput(Input);
195   setCompilerInstance(&CI);
196 
197   StringRef InputFile = Input.getFile();
198   bool HasBegunSourceFile = false;
199   if (!BeginInvocation(CI))
200     goto failure;
201 
202   // AST files follow a very different path, since they share objects via the
203   // AST unit.
204   if (Input.getKind() == IK_AST) {
205     assert(!usesPreprocessorOnly() &&
206            "Attempt to pass AST file to preprocessor only action!");
207     assert(hasASTFileSupport() &&
208            "This action does not have AST file support!");
209 
210     IntrusiveRefCntPtr<DiagnosticsEngine> Diags(&CI.getDiagnostics());
211 
212     std::unique_ptr<ASTUnit> AST = ASTUnit::LoadFromASTFile(
213         InputFile, CI.getPCHContainerReader(), Diags, CI.getFileSystemOpts(),
214         CI.getCodeGenOpts().DebugTypeExtRefs);
215 
216     if (!AST)
217       goto failure;
218 
219     // Inform the diagnostic client we are processing a source file.
220     CI.getDiagnosticClient().BeginSourceFile(CI.getLangOpts(), nullptr);
221     HasBegunSourceFile = true;
222 
223     // Set the shared objects, these are reset when we finish processing the
224     // file, otherwise the CompilerInstance will happily destroy them.
225     CI.setFileManager(&AST->getFileManager());
226     CI.setSourceManager(&AST->getSourceManager());
227     CI.setPreprocessor(AST->getPreprocessorPtr());
228     CI.setASTContext(&AST->getASTContext());
229 
230     setCurrentInput(Input, std::move(AST));
231 
232     // Initialize the action.
233     if (!BeginSourceFileAction(CI, InputFile))
234       goto failure;
235 
236     // Create the AST consumer.
237     CI.setASTConsumer(CreateWrappedASTConsumer(CI, InputFile));
238     if (!CI.hasASTConsumer())
239       goto failure;
240 
241     return true;
242   }
243 
244   if (!CI.hasVirtualFileSystem()) {
245     if (IntrusiveRefCntPtr<vfs::FileSystem> VFS =
246           createVFSFromCompilerInvocation(CI.getInvocation(),
247                                           CI.getDiagnostics()))
248       CI.setVirtualFileSystem(VFS);
249     else
250       goto failure;
251   }
252 
253   // Set up the file and source managers, if needed.
254   if (!CI.hasFileManager())
255     CI.createFileManager();
256   if (!CI.hasSourceManager())
257     CI.createSourceManager(CI.getFileManager());
258 
259   // IR files bypass the rest of initialization.
260   if (Input.getKind() == IK_LLVM_IR) {
261     assert(hasIRSupport() &&
262            "This action does not have IR file support!");
263 
264     // Inform the diagnostic client we are processing a source file.
265     CI.getDiagnosticClient().BeginSourceFile(CI.getLangOpts(), nullptr);
266     HasBegunSourceFile = true;
267 
268     // Initialize the action.
269     if (!BeginSourceFileAction(CI, InputFile))
270       goto failure;
271 
272     // Initialize the main file entry.
273     if (!CI.InitializeSourceManager(CurrentInput))
274       goto failure;
275 
276     return true;
277   }
278 
279   // If the implicit PCH include is actually a directory, rather than
280   // a single file, search for a suitable PCH file in that directory.
281   if (!CI.getPreprocessorOpts().ImplicitPCHInclude.empty()) {
282     FileManager &FileMgr = CI.getFileManager();
283     PreprocessorOptions &PPOpts = CI.getPreprocessorOpts();
284     StringRef PCHInclude = PPOpts.ImplicitPCHInclude;
285     std::string SpecificModuleCachePath = CI.getSpecificModuleCachePath();
286     if (const DirectoryEntry *PCHDir = FileMgr.getDirectory(PCHInclude)) {
287       std::error_code EC;
288       SmallString<128> DirNative;
289       llvm::sys::path::native(PCHDir->getName(), DirNative);
290       bool Found = false;
291       vfs::FileSystem &FS = *FileMgr.getVirtualFileSystem();
292       for (vfs::directory_iterator Dir = FS.dir_begin(DirNative, EC), DirEnd;
293            Dir != DirEnd && !EC; Dir.increment(EC)) {
294         // Check whether this is an acceptable AST file.
295         if (ASTReader::isAcceptableASTFile(
296                 Dir->getName(), FileMgr, CI.getPCHContainerReader(),
297                 CI.getLangOpts(), CI.getTargetOpts(), CI.getPreprocessorOpts(),
298                 SpecificModuleCachePath)) {
299           PPOpts.ImplicitPCHInclude = Dir->getName();
300           Found = true;
301           break;
302         }
303       }
304 
305       if (!Found) {
306         CI.getDiagnostics().Report(diag::err_fe_no_pch_in_dir) << PCHInclude;
307         goto failure;
308       }
309     }
310   }
311 
312   // Set up the preprocessor if needed. When parsing model files the
313   // preprocessor of the original source is reused.
314   if (!isModelParsingAction())
315     CI.createPreprocessor(getTranslationUnitKind());
316 
317   // Inform the diagnostic client we are processing a source file.
318   CI.getDiagnosticClient().BeginSourceFile(CI.getLangOpts(),
319                                            &CI.getPreprocessor());
320   HasBegunSourceFile = true;
321 
322   // Initialize the action.
323   if (!BeginSourceFileAction(CI, InputFile))
324     goto failure;
325 
326   // Initialize the main file entry. It is important that this occurs after
327   // BeginSourceFileAction, which may change CurrentInput during module builds.
328   if (!CI.InitializeSourceManager(CurrentInput))
329     goto failure;
330 
331   // Create the AST context and consumer unless this is a preprocessor only
332   // action.
333   if (!usesPreprocessorOnly()) {
334     // Parsing a model file should reuse the existing ASTContext.
335     if (!isModelParsingAction())
336       CI.createASTContext();
337 
338     std::unique_ptr<ASTConsumer> Consumer =
339         CreateWrappedASTConsumer(CI, InputFile);
340     if (!Consumer)
341       goto failure;
342 
343     // FIXME: should not overwrite ASTMutationListener when parsing model files?
344     if (!isModelParsingAction())
345       CI.getASTContext().setASTMutationListener(Consumer->GetASTMutationListener());
346 
347     if (!CI.getPreprocessorOpts().ChainedIncludes.empty()) {
348       // Convert headers to PCH and chain them.
349       IntrusiveRefCntPtr<ExternalSemaSource> source, FinalReader;
350       source = createChainedIncludesSource(CI, FinalReader);
351       if (!source)
352         goto failure;
353       CI.setModuleManager(static_cast<ASTReader *>(FinalReader.get()));
354       CI.getASTContext().setExternalSource(source);
355     } else if (CI.getLangOpts().Modules ||
356                !CI.getPreprocessorOpts().ImplicitPCHInclude.empty()) {
357       // Use PCM or PCH.
358       assert(hasPCHSupport() && "This action does not have PCH support!");
359       ASTDeserializationListener *DeserialListener =
360           Consumer->GetASTDeserializationListener();
361       bool DeleteDeserialListener = false;
362       if (CI.getPreprocessorOpts().DumpDeserializedPCHDecls) {
363         DeserialListener = new DeserializedDeclsDumper(DeserialListener,
364                                                        DeleteDeserialListener);
365         DeleteDeserialListener = true;
366       }
367       if (!CI.getPreprocessorOpts().DeserializedPCHDeclsToErrorOn.empty()) {
368         DeserialListener = new DeserializedDeclsChecker(
369             CI.getASTContext(),
370             CI.getPreprocessorOpts().DeserializedPCHDeclsToErrorOn,
371             DeserialListener, DeleteDeserialListener);
372         DeleteDeserialListener = true;
373       }
374       if (!CI.getPreprocessorOpts().ImplicitPCHInclude.empty()) {
375         CI.createPCHExternalASTSource(
376             CI.getPreprocessorOpts().ImplicitPCHInclude,
377             CI.getPreprocessorOpts().DisablePCHValidation,
378           CI.getPreprocessorOpts().AllowPCHWithCompilerErrors, DeserialListener,
379             DeleteDeserialListener);
380         if (!CI.getASTContext().getExternalSource())
381           goto failure;
382       }
383       // If modules are enabled, create the module manager before creating
384       // any builtins, so that all declarations know that they might be
385       // extended by an external source.
386       if (CI.getLangOpts().Modules || !CI.hasASTContext() ||
387           !CI.getASTContext().getExternalSource()) {
388         CI.createModuleManager();
389         CI.getModuleManager()->setDeserializationListener(DeserialListener,
390                                                         DeleteDeserialListener);
391       }
392     }
393 
394     CI.setASTConsumer(std::move(Consumer));
395     if (!CI.hasASTConsumer())
396       goto failure;
397   }
398 
399   // Initialize built-in info as long as we aren't using an external AST
400   // source.
401   if (CI.getLangOpts().Modules || !CI.hasASTContext() ||
402       !CI.getASTContext().getExternalSource()) {
403     Preprocessor &PP = CI.getPreprocessor();
404     PP.getBuiltinInfo().initializeBuiltins(PP.getIdentifierTable(),
405                                            PP.getLangOpts());
406   } else {
407     // FIXME: If this is a problem, recover from it by creating a multiplex
408     // source.
409     assert((!CI.getLangOpts().Modules || CI.getModuleManager()) &&
410            "modules enabled but created an external source that "
411            "doesn't support modules");
412   }
413 
414   // If we were asked to load any module map files, do so now.
415   for (const auto &Filename : CI.getFrontendOpts().ModuleMapFiles) {
416     if (auto *File = CI.getFileManager().getFile(Filename))
417       CI.getPreprocessor().getHeaderSearchInfo().loadModuleMapFile(
418           File, /*IsSystem*/false);
419     else
420       CI.getDiagnostics().Report(diag::err_module_map_not_found) << Filename;
421   }
422 
423   // If we were asked to load any module files, do so now.
424   for (const auto &ModuleFile : CI.getFrontendOpts().ModuleFiles)
425     if (!CI.loadModuleFile(ModuleFile))
426       goto failure;
427 
428   // If there is a layout overrides file, attach an external AST source that
429   // provides the layouts from that file.
430   if (!CI.getFrontendOpts().OverrideRecordLayoutsFile.empty() &&
431       CI.hasASTContext() && !CI.getASTContext().getExternalSource()) {
432     IntrusiveRefCntPtr<ExternalASTSource>
433       Override(new LayoutOverrideSource(
434                      CI.getFrontendOpts().OverrideRecordLayoutsFile));
435     CI.getASTContext().setExternalSource(Override);
436   }
437 
438   return true;
439 
440   // If we failed, reset state since the client will not end up calling the
441   // matching EndSourceFile().
442   failure:
443   if (isCurrentFileAST()) {
444     CI.setASTContext(nullptr);
445     CI.setPreprocessor(nullptr);
446     CI.setSourceManager(nullptr);
447     CI.setFileManager(nullptr);
448   }
449 
450   if (HasBegunSourceFile)
451     CI.getDiagnosticClient().EndSourceFile();
452   CI.clearOutputFiles(/*EraseFiles=*/true);
453   setCurrentInput(FrontendInputFile());
454   setCompilerInstance(nullptr);
455   return false;
456 }
457 
458 bool FrontendAction::Execute() {
459   CompilerInstance &CI = getCompilerInstance();
460 
461   if (CI.hasFrontendTimer()) {
462     llvm::TimeRegion Timer(CI.getFrontendTimer());
463     ExecuteAction();
464   }
465   else ExecuteAction();
466 
467   // If we are supposed to rebuild the global module index, do so now unless
468   // there were any module-build failures.
469   if (CI.shouldBuildGlobalModuleIndex() && CI.hasFileManager() &&
470       CI.hasPreprocessor()) {
471     StringRef Cache =
472         CI.getPreprocessor().getHeaderSearchInfo().getModuleCachePath();
473     if (!Cache.empty())
474       GlobalModuleIndex::writeIndex(CI.getFileManager(),
475                                     CI.getPCHContainerReader(), Cache);
476   }
477 
478   return true;
479 }
480 
481 void FrontendAction::EndSourceFile() {
482   CompilerInstance &CI = getCompilerInstance();
483 
484   // Inform the diagnostic client we are done with this source file.
485   CI.getDiagnosticClient().EndSourceFile();
486 
487   // Inform the preprocessor we are done.
488   if (CI.hasPreprocessor())
489     CI.getPreprocessor().EndSourceFile();
490 
491   // Finalize the action.
492   EndSourceFileAction();
493 
494   // Sema references the ast consumer, so reset sema first.
495   //
496   // FIXME: There is more per-file stuff we could just drop here?
497   bool DisableFree = CI.getFrontendOpts().DisableFree;
498   if (DisableFree) {
499     CI.resetAndLeakSema();
500     CI.resetAndLeakASTContext();
501     BuryPointer(CI.takeASTConsumer().get());
502   } else {
503     CI.setSema(nullptr);
504     CI.setASTContext(nullptr);
505     CI.setASTConsumer(nullptr);
506   }
507 
508   if (CI.getFrontendOpts().ShowStats) {
509     llvm::errs() << "\nSTATISTICS FOR '" << getCurrentFile() << "':\n";
510     CI.getPreprocessor().PrintStats();
511     CI.getPreprocessor().getIdentifierTable().PrintStats();
512     CI.getPreprocessor().getHeaderSearchInfo().PrintStats();
513     CI.getSourceManager().PrintStats();
514     llvm::errs() << "\n";
515   }
516 
517   // Cleanup the output streams, and erase the output files if instructed by the
518   // FrontendAction.
519   CI.clearOutputFiles(/*EraseFiles=*/shouldEraseOutputFiles());
520 
521   if (isCurrentFileAST()) {
522     if (DisableFree) {
523       CI.resetAndLeakPreprocessor();
524       CI.resetAndLeakSourceManager();
525       CI.resetAndLeakFileManager();
526     } else {
527       CI.setPreprocessor(nullptr);
528       CI.setSourceManager(nullptr);
529       CI.setFileManager(nullptr);
530     }
531   }
532 
533   setCompilerInstance(nullptr);
534   setCurrentInput(FrontendInputFile());
535 }
536 
537 bool FrontendAction::shouldEraseOutputFiles() {
538   return getCompilerInstance().getDiagnostics().hasErrorOccurred();
539 }
540 
541 //===----------------------------------------------------------------------===//
542 // Utility Actions
543 //===----------------------------------------------------------------------===//
544 
545 void ASTFrontendAction::ExecuteAction() {
546   CompilerInstance &CI = getCompilerInstance();
547   if (!CI.hasPreprocessor())
548     return;
549 
550   // FIXME: Move the truncation aspect of this into Sema, we delayed this till
551   // here so the source manager would be initialized.
552   if (hasCodeCompletionSupport() &&
553       !CI.getFrontendOpts().CodeCompletionAt.FileName.empty())
554     CI.createCodeCompletionConsumer();
555 
556   // Use a code completion consumer?
557   CodeCompleteConsumer *CompletionConsumer = nullptr;
558   if (CI.hasCodeCompletionConsumer())
559     CompletionConsumer = &CI.getCodeCompletionConsumer();
560 
561   if (!CI.hasSema())
562     CI.createSema(getTranslationUnitKind(), CompletionConsumer);
563 
564   ParseAST(CI.getSema(), CI.getFrontendOpts().ShowStats,
565            CI.getFrontendOpts().SkipFunctionBodies);
566 }
567 
568 void PluginASTAction::anchor() { }
569 
570 std::unique_ptr<ASTConsumer>
571 PreprocessorFrontendAction::CreateASTConsumer(CompilerInstance &CI,
572                                               StringRef InFile) {
573   llvm_unreachable("Invalid CreateASTConsumer on preprocessor action!");
574 }
575 
576 std::unique_ptr<ASTConsumer>
577 WrapperFrontendAction::CreateASTConsumer(CompilerInstance &CI,
578                                          StringRef InFile) {
579   return WrappedAction->CreateASTConsumer(CI, InFile);
580 }
581 bool WrapperFrontendAction::BeginInvocation(CompilerInstance &CI) {
582   return WrappedAction->BeginInvocation(CI);
583 }
584 bool WrapperFrontendAction::BeginSourceFileAction(CompilerInstance &CI,
585                                                   StringRef Filename) {
586   WrappedAction->setCurrentInput(getCurrentInput());
587   WrappedAction->setCompilerInstance(&CI);
588   auto Ret = WrappedAction->BeginSourceFileAction(CI, Filename);
589   // BeginSourceFileAction may change CurrentInput, e.g. during module builds.
590   setCurrentInput(WrappedAction->getCurrentInput());
591   return Ret;
592 }
593 void WrapperFrontendAction::ExecuteAction() {
594   WrappedAction->ExecuteAction();
595 }
596 void WrapperFrontendAction::EndSourceFileAction() {
597   WrappedAction->EndSourceFileAction();
598 }
599 
600 bool WrapperFrontendAction::usesPreprocessorOnly() const {
601   return WrappedAction->usesPreprocessorOnly();
602 }
603 TranslationUnitKind WrapperFrontendAction::getTranslationUnitKind() {
604   return WrappedAction->getTranslationUnitKind();
605 }
606 bool WrapperFrontendAction::hasPCHSupport() const {
607   return WrappedAction->hasPCHSupport();
608 }
609 bool WrapperFrontendAction::hasASTFileSupport() const {
610   return WrappedAction->hasASTFileSupport();
611 }
612 bool WrapperFrontendAction::hasIRSupport() const {
613   return WrappedAction->hasIRSupport();
614 }
615 bool WrapperFrontendAction::hasCodeCompletionSupport() const {
616   return WrappedAction->hasCodeCompletionSupport();
617 }
618 
619 WrapperFrontendAction::WrapperFrontendAction(
620     std::unique_ptr<FrontendAction> WrappedAction)
621   : WrappedAction(std::move(WrappedAction)) {}
622 
623