[clang-repl] Put CompilerInstance from IncrementalAction to use for non-assert/assert builds#155400
Merged
anutosh491 merged 4 commits intollvm:mainfrom Aug 27, 2025
Merged
[clang-repl] Put CompilerInstance from IncrementalAction to use for non-assert/assert builds#155400anutosh491 merged 4 commits intollvm:mainfrom
anutosh491 merged 4 commits intollvm:mainfrom
Conversation
Member
|
@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);
|
Member
Author
|
This way
|
Member
Author
|
Thanks @mikaelholmen for the report. |
|
✅ With the latest revision this PR passed the C/C++ code formatter. |
Member
Author
|
The failing test seems unrelated |
Member
Author
|
Thanks for the review. Merging ! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
ExecuteActiononActSo 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
CreateASTConsumertoo as all of these are referring to the same CI