-
Notifications
You must be signed in to change notification settings - Fork 14.9k
[clang-repl] Put CompilerInstance from IncrementalAction to use for non-assert/assert builds #155400
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@llvm/pr-subscribers-clang Author: Anutosh Bhat (anutosh491) ChangesFull diff: https://github.com/llvm/llvm-project/pull/155400.diff 2 Files Affected:
diff --git a/clang/lib/Interpreter/IncrementalAction.cpp b/clang/lib/Interpreter/IncrementalAction.cpp
index 67313a8cd2a8c..bf804bd24a959 100644
--- a/clang/lib/Interpreter/IncrementalAction.cpp
+++ b/clang/lib/Interpreter/IncrementalAction.cpp
@@ -22,25 +22,25 @@
#include "llvm/Support/ErrorHandling.h"
namespace clang {
-IncrementalAction::IncrementalAction(CompilerInstance &CI,
+IncrementalAction::IncrementalAction(CompilerInstance &Instance,
llvm::LLVMContext &LLVMCtx,
llvm::Error &Err, Interpreter &I,
std::unique_ptr<ASTConsumer> Consumer)
: WrapperFrontendAction([&]() {
llvm::ErrorAsOutParameter EAO(&Err);
std::unique_ptr<FrontendAction> Act;
- switch (CI.getFrontendOpts().ProgramAction) {
+ switch (Instance.getFrontendOpts().ProgramAction) {
default:
Err = llvm::createStringError(
std::errc::state_not_recoverable,
"Driver initialization failed. "
"Incremental mode for action %d is not supported",
- CI.getFrontendOpts().ProgramAction);
+ Instance.getFrontendOpts().ProgramAction);
return Act;
case frontend::ASTDump:
case frontend::ASTPrint:
case frontend::ParseSyntaxOnly:
- Act = CreateFrontendAction(CI);
+ Act = CreateFrontendAction(Instance);
break;
case frontend::PluginAction:
case frontend::EmitAssembly:
@@ -53,12 +53,12 @@ IncrementalAction::IncrementalAction(CompilerInstance &CI,
}
return Act;
}()),
- Interp(I), CI(CI), Consumer(std::move(Consumer)) {}
+ Interp(I), CI(Instance), Consumer(std::move(Consumer)) {}
std::unique_ptr<ASTConsumer>
-IncrementalAction::CreateASTConsumer(CompilerInstance &CI, StringRef InFile) {
+IncrementalAction::CreateASTConsumer(CompilerInstance & /*CI*/, StringRef InFile) {
std::unique_ptr<ASTConsumer> C =
- WrapperFrontendAction::CreateASTConsumer(CI, InFile);
+ WrapperFrontendAction::CreateASTConsumer(this->CI, InFile);
if (Consumer) {
std::vector<std::unique_ptr<ASTConsumer>> Cs;
diff --git a/clang/lib/Interpreter/IncrementalAction.h b/clang/lib/Interpreter/IncrementalAction.h
index 92eabacd40074..83cec24caf274 100644
--- a/clang/lib/Interpreter/IncrementalAction.h
+++ b/clang/lib/Interpreter/IncrementalAction.h
@@ -42,7 +42,7 @@ class IncrementalAction : public WrapperFrontendAction {
std::unique_ptr<llvm::Module> CachedInCodeGenModule;
public:
- IncrementalAction(CompilerInstance &CI, llvm::LLVMContext &LLVMCtx,
+ IncrementalAction(CompilerInstance &Instance, llvm::LLVMContext &LLVMCtx,
llvm::Error &Err, Interpreter &I,
std::unique_ptr<ASTConsumer> Consumer = nullptr);
|
This way
|
Thanks @mikaelholmen for the report. |
✅ With the latest revision this PR passed the C/C++ code formatter. |
The failing test seems unrelated
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Thanks for the review. Merging ! |
See #137458 (comment)
Context: So the CompilerInstance CI being used with the Incremental Action are tightly coupled in any case. Which means
the CI put to use while constructing the IncrementalAction
Is also the CI through which the we call
ExecuteAction
onAct
So we need to use CI as a member variable in IncrementalAction for assert builds for
llvm-project/clang/lib/Interpreter/IncrementalAction.cpp
Lines 97 to 108 in bddac5e
The same can be put to use for
CreateASTConsumer
too as all of these are referring to the same CI