summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2017-06-09 01:36:10 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2017-06-09 01:36:10 +0000
commit772553c418344b6943a468b79e043180840eb255 (patch)
treef02a6f512479eac317c00697d16335e7d10a5439
parent4ed69c25ab95ef923b9917a3c3599665ca7bbda7 (diff)
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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@305045 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/clang/Frontend/FrontendAction.h5
-rw-r--r--include/clang/Frontend/FrontendActions.h9
-rw-r--r--include/clang/Rewrite/Frontend/FrontendActions.h3
-rw-r--r--include/clang/Tooling/Tooling.h9
-rw-r--r--lib/Frontend/ASTMerge.cpp5
-rw-r--r--lib/Frontend/FrontendAction.cpp11
-rw-r--r--lib/Frontend/FrontendActions.cpp14
-rw-r--r--lib/Frontend/Rewrite/FrontendActions.cpp3
-rw-r--r--tools/clang-check/ClangCheck.cpp3
-rw-r--r--unittests/Frontend/FrontendActionTest.cpp5
-rw-r--r--unittests/Tooling/CommentHandlerTest.cpp3
-rw-r--r--unittests/Tooling/ToolingTest.cpp2
12 files changed, 27 insertions, 45 deletions
diff --git a/include/clang/Frontend/FrontendAction.h b/include/clang/Frontend/FrontendAction.h
index 07dfa5e6b7..7ae6173512 100644
--- a/include/clang/Frontend/FrontendAction.h
+++ b/include/clang/Frontend/FrontendAction.h
@@ -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;
diff --git a/include/clang/Frontend/FrontendActions.h b/include/clang/Frontend/FrontendActions.h
index cb44985149..84db293c46 100644
--- a/include/clang/Frontend/FrontendActions.h
+++ b/include/clang/Frontend/FrontendActions.h
@@ -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;
diff --git a/include/clang/Rewrite/Frontend/FrontendActions.h b/include/clang/Rewrite/Frontend/FrontendActions.h
index 27976eac4e..9a8330fefa 100644
--- a/include/clang/Rewrite/Frontend/FrontendActions.h
+++ b/include/clang/Rewrite/Frontend/FrontendActions.h
@@ -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;
diff --git a/include/clang/Tooling/Tooling.h b/include/clang/Tooling/Tooling.h
index 10e26ac25d..1c974f9988 100644
--- a/include/clang/Tooling/Tooling.h
+++ b/include/clang/Tooling/Tooling.h
@@ -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<FrontendActionFactory> newFrontendActionFactory(
}
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 {
diff --git a/lib/Frontend/ASTMerge.cpp b/lib/Frontend/ASTMerge.cpp
index 51064da270..986f98ae59 100644
--- a/lib/Frontend/ASTMerge.cpp
+++ b/lib/Frontend/ASTMerge.cpp
@@ -21,14 +21,13 @@ ASTMergeAction::CreateASTConsumer(CompilerInstance &CI, StringRef InFile) {
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() {
diff --git a/lib/Frontend/FrontendAction.cpp b/lib/Frontend/FrontendAction.cpp
index 15c2bec93c..7c0b854648 100644
--- a/lib/Frontend/FrontendAction.cpp
+++ b/lib/Frontend/FrontendAction.cpp
@@ -614,7 +614,7 @@ bool FrontendAction::BeginSourceFile(CompilerInstance &CI,
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(CompilerInstance &CI,
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(CompilerInstance &CI,
}
// 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(CompilerInstance &CI,
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;
diff --git a/lib/Frontend/FrontendActions.cpp b/lib/Frontend/FrontendActions.cpp
index 89ac385ca4..c5567a0963 100644
--- a/lib/Frontend/FrontendActions.cpp
+++ b/lib/Frontend/FrontendActions.cpp
@@ -134,8 +134,7 @@ bool GeneratePCHAction::shouldEraseOutputFiles() {
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(CompilerInstance &CI,
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::CreateOutputFile(CompilerInstance &CI,
/*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::BeginSourceFileAction(CompilerInstance &CI,
CI.getLangOpts().setCompilingModule(LangOptions::CMK_ModuleInterface);
- return GenerateModuleAction::BeginSourceFileAction(CI, Filename);
+ return GenerateModuleAction::BeginSourceFileAction(CI);
}
std::unique_ptr<raw_pwrite_stream>
diff --git a/lib/Frontend/Rewrite/FrontendActions.cpp b/lib/Frontend/Rewrite/FrontendActions.cpp
index b2dfd29411..76eb07e981 100644
--- a/lib/Frontend/Rewrite/FrontendActions.cpp
+++ b/lib/Frontend/Rewrite/FrontendActions.cpp
@@ -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,
diff --git a/tools/clang-check/ClangCheck.cpp b/tools/clang-check/ClangCheck.cpp
index dac11ff077..e190c0721a 100644
--- a/tools/clang-check/ClangCheck.cpp
+++ b/tools/clang-check/ClangCheck.cpp
@@ -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()));
diff --git a/unittests/Frontend/FrontendActionTest.cpp b/unittests/Frontend/FrontendActionTest.cpp
index 68181c705c..ce0144538d 100644
--- a/unittests/Frontend/FrontendActionTest.cpp
+++ b/unittests/Frontend/FrontendActionTest.cpp
@@ -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,
diff --git a/unittests/Tooling/CommentHandlerTest.cpp b/unittests/Tooling/CommentHandlerTest.cpp
index b42b28b9c9..9c3abdc4b1 100644
--- a/unittests/Tooling/CommentHandlerTest.cpp
+++ b/unittests/Tooling/CommentHandlerTest.cpp
@@ -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();
diff --git a/unittests/Tooling/ToolingTest.cpp b/unittests/Tooling/ToolingTest.cpp
index 68b5ed2105..b179f033d3 100644
--- a/unittests/Tooling/ToolingTest.cpp
+++ b/unittests/Tooling/ToolingTest.cpp
@@ -203,7 +203,7 @@ TEST(ToolInvocation, TestVirtualModulesCompilation) {
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;
}