Author: rsmith Date: Thu Jun 8 20:36:10 2017 New Revision: 305045 URL: http://llvm.org/viewvc/llvm-project?rev=305045&view=rev Log: Remove 'Filename' parameter from BeginSourceFileAction.
No-one was using this, and it's not meaningful in general -- FrontendActions can be run on inputs that don't have a corresponding source file. The current frontend input can be obtained by asking the FrontendAction if any future action actually needs it. Modified: cfe/trunk/include/clang/Frontend/FrontendAction.h cfe/trunk/include/clang/Frontend/FrontendActions.h cfe/trunk/include/clang/Rewrite/Frontend/FrontendActions.h cfe/trunk/include/clang/Tooling/Tooling.h cfe/trunk/lib/Frontend/ASTMerge.cpp cfe/trunk/lib/Frontend/FrontendAction.cpp cfe/trunk/lib/Frontend/FrontendActions.cpp cfe/trunk/lib/Frontend/Rewrite/FrontendActions.cpp cfe/trunk/tools/clang-check/ClangCheck.cpp cfe/trunk/unittests/Frontend/FrontendActionTest.cpp cfe/trunk/unittests/Tooling/CommentHandlerTest.cpp cfe/trunk/unittests/Tooling/ToolingTest.cpp Modified: cfe/trunk/include/clang/Frontend/FrontendAction.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/FrontendAction.h?rev=305045&r1=305044&r2=305045&view=diff ============================================================================== --- cfe/trunk/include/clang/Frontend/FrontendAction.h (original) +++ cfe/trunk/include/clang/Frontend/FrontendAction.h Thu Jun 8 20:36:10 2017 @@ -76,8 +76,7 @@ protected: /// /// \return True on success; on failure ExecutionAction() and /// EndSourceFileAction() will not be called. - virtual bool BeginSourceFileAction(CompilerInstance &CI, - StringRef Filename) { + virtual bool BeginSourceFileAction(CompilerInstance &CI) { return true; } @@ -291,7 +290,7 @@ protected: std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &CI, StringRef InFile) override; bool BeginInvocation(CompilerInstance &CI) override; - bool BeginSourceFileAction(CompilerInstance &CI, StringRef Filename) override; + bool BeginSourceFileAction(CompilerInstance &CI) override; void ExecuteAction() override; void EndSourceFileAction() override; Modified: cfe/trunk/include/clang/Frontend/FrontendActions.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/FrontendActions.h?rev=305045&r1=305044&r2=305045&view=diff ============================================================================== --- cfe/trunk/include/clang/Frontend/FrontendActions.h (original) +++ cfe/trunk/include/clang/Frontend/FrontendActions.h Thu Jun 8 20:36:10 2017 @@ -91,7 +91,7 @@ public: ComputeASTConsumerArguments(CompilerInstance &CI, StringRef InFile, std::string &Sysroot, std::string &OutputFile); - bool BeginSourceFileAction(CompilerInstance &CI, StringRef Filename) override; + bool BeginSourceFileAction(CompilerInstance &CI) override; }; class GenerateModuleAction : public ASTFrontendAction { @@ -111,15 +111,13 @@ protected: class GenerateModuleFromModuleMapAction : public GenerateModuleAction { private: - bool BeginSourceFileAction(CompilerInstance &CI, StringRef Filename) override; - std::unique_ptr<raw_pwrite_stream> CreateOutputFile(CompilerInstance &CI, StringRef InFile) override; }; class GenerateModuleInterfaceAction : public GenerateModuleAction { private: - bool BeginSourceFileAction(CompilerInstance &CI, StringRef Filename) override; + bool BeginSourceFileAction(CompilerInstance &CI) override; std::unique_ptr<raw_pwrite_stream> CreateOutputFile(CompilerInstance &CI, StringRef InFile) override; @@ -181,8 +179,7 @@ protected: std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &CI, StringRef InFile) override; - bool BeginSourceFileAction(CompilerInstance &CI, - StringRef Filename) override; + bool BeginSourceFileAction(CompilerInstance &CI) override; void ExecuteAction() override; void EndSourceFileAction() override; Modified: cfe/trunk/include/clang/Rewrite/Frontend/FrontendActions.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Rewrite/Frontend/FrontendActions.h?rev=305045&r1=305044&r2=305045&view=diff ============================================================================== --- cfe/trunk/include/clang/Rewrite/Frontend/FrontendActions.h (original) +++ cfe/trunk/include/clang/Rewrite/Frontend/FrontendActions.h Thu Jun 8 20:36:10 2017 @@ -34,8 +34,7 @@ protected: std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &CI, StringRef InFile) override; - bool BeginSourceFileAction(CompilerInstance &CI, - StringRef Filename) override; + bool BeginSourceFileAction(CompilerInstance &CI) override; void EndSourceFileAction() override; Modified: cfe/trunk/include/clang/Tooling/Tooling.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Tooling/Tooling.h?rev=305045&r1=305044&r2=305045&view=diff ============================================================================== --- cfe/trunk/include/clang/Tooling/Tooling.h (original) +++ cfe/trunk/include/clang/Tooling/Tooling.h Thu Jun 8 20:36:10 2017 @@ -116,7 +116,7 @@ public: /// \brief Called before a source file is processed by a FrontEndAction. /// \see clang::FrontendAction::BeginSourceFileAction - virtual bool handleBeginSource(CompilerInstance &CI, StringRef Filename) { + virtual bool handleBeginSource(CompilerInstance &CI) { return true; } @@ -388,12 +388,11 @@ inline std::unique_ptr<FrontendActionFac } protected: - bool BeginSourceFileAction(CompilerInstance &CI, - StringRef Filename) override { - if (!clang::ASTFrontendAction::BeginSourceFileAction(CI, Filename)) + bool BeginSourceFileAction(CompilerInstance &CI) override { + if (!clang::ASTFrontendAction::BeginSourceFileAction(CI)) return false; if (Callbacks) - return Callbacks->handleBeginSource(CI, Filename); + return Callbacks->handleBeginSource(CI); return true; } void EndSourceFileAction() override { Modified: cfe/trunk/lib/Frontend/ASTMerge.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/ASTMerge.cpp?rev=305045&r1=305044&r2=305045&view=diff ============================================================================== --- cfe/trunk/lib/Frontend/ASTMerge.cpp (original) +++ cfe/trunk/lib/Frontend/ASTMerge.cpp Thu Jun 8 20:36:10 2017 @@ -21,14 +21,13 @@ ASTMergeAction::CreateASTConsumer(Compil return AdaptedAction->CreateASTConsumer(CI, InFile); } -bool ASTMergeAction::BeginSourceFileAction(CompilerInstance &CI, - StringRef Filename) { +bool ASTMergeAction::BeginSourceFileAction(CompilerInstance &CI) { // FIXME: This is a hack. We need a better way to communicate the // AST file, compiler instance, and file name than member variables // of FrontendAction. AdaptedAction->setCurrentInput(getCurrentInput(), takeCurrentASTUnit()); AdaptedAction->setCompilerInstance(&CI); - return AdaptedAction->BeginSourceFileAction(CI, Filename); + return AdaptedAction->BeginSourceFileAction(CI); } void ASTMergeAction::ExecuteAction() { Modified: cfe/trunk/lib/Frontend/FrontendAction.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/FrontendAction.cpp?rev=305045&r1=305044&r2=305045&view=diff ============================================================================== --- cfe/trunk/lib/Frontend/FrontendAction.cpp (original) +++ cfe/trunk/lib/Frontend/FrontendAction.cpp Thu Jun 8 20:36:10 2017 @@ -614,7 +614,7 @@ bool FrontendAction::BeginSourceFile(Com setCurrentInput(Input, std::move(AST)); // Initialize the action. - if (!BeginSourceFileAction(CI, InputFile)) + if (!BeginSourceFileAction(CI)) goto failure; // Create the AST consumer. @@ -661,7 +661,7 @@ bool FrontendAction::BeginSourceFile(Com HasBegunSourceFile = true; // Initialize the action. - if (!BeginSourceFileAction(CI, InputFile)) + if (!BeginSourceFileAction(CI)) goto failure; // Initialize the main file entry. @@ -754,7 +754,7 @@ bool FrontendAction::BeginSourceFile(Com } // Initialize the action. - if (!BeginSourceFileAction(CI, InputFile)) + if (!BeginSourceFileAction(CI)) goto failure; // Create the AST context and consumer unless this is a preprocessor only @@ -1012,11 +1012,10 @@ WrapperFrontendAction::CreateASTConsumer bool WrapperFrontendAction::BeginInvocation(CompilerInstance &CI) { return WrappedAction->BeginInvocation(CI); } -bool WrapperFrontendAction::BeginSourceFileAction(CompilerInstance &CI, - StringRef Filename) { +bool WrapperFrontendAction::BeginSourceFileAction(CompilerInstance &CI) { WrappedAction->setCurrentInput(getCurrentInput()); WrappedAction->setCompilerInstance(&CI); - auto Ret = WrappedAction->BeginSourceFileAction(CI, Filename); + auto Ret = WrappedAction->BeginSourceFileAction(CI); // BeginSourceFileAction may change CurrentInput, e.g. during module builds. setCurrentInput(WrappedAction->getCurrentInput()); return Ret; Modified: cfe/trunk/lib/Frontend/FrontendActions.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/FrontendActions.cpp?rev=305045&r1=305044&r2=305045&view=diff ============================================================================== --- cfe/trunk/lib/Frontend/FrontendActions.cpp (original) +++ cfe/trunk/lib/Frontend/FrontendActions.cpp Thu Jun 8 20:36:10 2017 @@ -134,8 +134,7 @@ bool GeneratePCHAction::shouldEraseOutpu return ASTFrontendAction::shouldEraseOutputFiles(); } -bool GeneratePCHAction::BeginSourceFileAction(CompilerInstance &CI, - StringRef Filename) { +bool GeneratePCHAction::BeginSourceFileAction(CompilerInstance &CI) { CI.getLangOpts().CompilingPCH = true; return true; } @@ -164,11 +163,6 @@ GenerateModuleAction::CreateASTConsumer( return llvm::make_unique<MultiplexConsumer>(std::move(Consumers)); } -bool GenerateModuleFromModuleMapAction::BeginSourceFileAction( - CompilerInstance &CI, StringRef Filename) { - return GenerateModuleAction::BeginSourceFileAction(CI, Filename); -} - std::unique_ptr<raw_pwrite_stream> GenerateModuleFromModuleMapAction::CreateOutputFile(CompilerInstance &CI, StringRef InFile) { @@ -194,8 +188,8 @@ GenerateModuleFromModuleMapAction::Creat /*CreateMissingDirectories=*/true); } -bool GenerateModuleInterfaceAction::BeginSourceFileAction(CompilerInstance &CI, - StringRef Filename) { +bool GenerateModuleInterfaceAction::BeginSourceFileAction( + CompilerInstance &CI) { if (!CI.getLangOpts().ModulesTS) { CI.getDiagnostics().Report(diag::err_module_interface_requires_modules_ts); return false; @@ -203,7 +197,7 @@ bool GenerateModuleInterfaceAction::Begi CI.getLangOpts().setCompilingModule(LangOptions::CMK_ModuleInterface); - return GenerateModuleAction::BeginSourceFileAction(CI, Filename); + return GenerateModuleAction::BeginSourceFileAction(CI); } std::unique_ptr<raw_pwrite_stream> Modified: cfe/trunk/lib/Frontend/Rewrite/FrontendActions.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/Rewrite/FrontendActions.cpp?rev=305045&r1=305044&r2=305045&view=diff ============================================================================== --- cfe/trunk/lib/Frontend/Rewrite/FrontendActions.cpp (original) +++ cfe/trunk/lib/Frontend/Rewrite/FrontendActions.cpp Thu Jun 8 20:36:10 2017 @@ -86,8 +86,7 @@ public: }; } // end anonymous namespace -bool FixItAction::BeginSourceFileAction(CompilerInstance &CI, - StringRef Filename) { +bool FixItAction::BeginSourceFileAction(CompilerInstance &CI) { const FrontendOptions &FEOpts = getCompilerInstance().getFrontendOpts(); if (!FEOpts.FixItSuffix.empty()) { FixItOpts.reset(new FixItActionSuffixInserter(FEOpts.FixItSuffix, Modified: cfe/trunk/tools/clang-check/ClangCheck.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-check/ClangCheck.cpp?rev=305045&r1=305044&r2=305045&view=diff ============================================================================== --- cfe/trunk/tools/clang-check/ClangCheck.cpp (original) +++ cfe/trunk/tools/clang-check/ClangCheck.cpp Thu Jun 8 20:36:10 2017 @@ -124,8 +124,7 @@ public: /// \c FixItRewriter. class FixItAction : public clang::FixItAction { public: - bool BeginSourceFileAction(clang::CompilerInstance& CI, - StringRef Filename) override { + bool BeginSourceFileAction(clang::CompilerInstance& CI) override { FixItOpts.reset(new FixItOptions); Rewriter.reset(new FixItRewriter(CI.getDiagnostics(), CI.getSourceManager(), CI.getLangOpts(), FixItOpts.get())); Modified: cfe/trunk/unittests/Frontend/FrontendActionTest.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Frontend/FrontendActionTest.cpp?rev=305045&r1=305044&r2=305045&view=diff ============================================================================== --- cfe/trunk/unittests/Frontend/FrontendActionTest.cpp (original) +++ cfe/trunk/unittests/Frontend/FrontendActionTest.cpp Thu Jun 8 20:36:10 2017 @@ -37,12 +37,11 @@ public: bool ActOnEndOfTranslationUnit; std::vector<std::string> decl_names; - bool BeginSourceFileAction(CompilerInstance &ci, - StringRef filename) override { + bool BeginSourceFileAction(CompilerInstance &ci) override { if (EnableIncrementalProcessing) ci.getPreprocessor().enableIncrementalProcessing(); - return ASTFrontendAction::BeginSourceFileAction(ci, filename); + return ASTFrontendAction::BeginSourceFileAction(ci); } std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &CI, Modified: cfe/trunk/unittests/Tooling/CommentHandlerTest.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Tooling/CommentHandlerTest.cpp?rev=305045&r1=305044&r2=305045&view=diff ============================================================================== --- cfe/trunk/unittests/Tooling/CommentHandlerTest.cpp (original) +++ cfe/trunk/unittests/Tooling/CommentHandlerTest.cpp Thu Jun 8 20:36:10 2017 @@ -70,8 +70,7 @@ private: CommentHandlerAction(CommentHandlerVisitor *Visitor) : TestAction(Visitor) { } - bool BeginSourceFileAction(CompilerInstance &CI, - StringRef FileName) override { + bool BeginSourceFileAction(CompilerInstance &CI) override { CommentHandlerVisitor *V = static_cast<CommentHandlerVisitor*>(this->Visitor); V->PP = &CI.getPreprocessor(); Modified: cfe/trunk/unittests/Tooling/ToolingTest.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Tooling/ToolingTest.cpp?rev=305045&r1=305044&r2=305045&view=diff ============================================================================== --- cfe/trunk/unittests/Tooling/ToolingTest.cpp (original) +++ cfe/trunk/unittests/Tooling/ToolingTest.cpp Thu Jun 8 20:36:10 2017 @@ -203,7 +203,7 @@ TEST(ToolInvocation, TestVirtualModulesC struct VerifyEndCallback : public SourceFileCallbacks { VerifyEndCallback() : BeginCalled(0), EndCalled(0), Matched(false) {} - bool handleBeginSource(CompilerInstance &CI, StringRef Filename) override { + bool handleBeginSource(CompilerInstance &CI) override { ++BeginCalled; return true; } _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits