FrontendAction.cpp 21 KB

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