aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen/ModuleBuilder.cpp
diff options
context:
space:
mode:
authorJeaye Wilkerson <contact@jeaye.com>2025-09-30 03:58:57 -0700
committerGitHub <noreply@github.com>2025-09-30 13:58:57 +0300
commit065cd64af3166da430bd03067514f9c9ac09e8e1 (patch)
tree1a3acc89ae0620f2dbd4c165daf496bf7890f5cd /clang/lib/CodeGen/ModuleBuilder.cpp
parent709a74dfb3b5e965479760af8bd29a84c89e1d2e (diff)
downloadllvm-065cd64af3166da430bd03067514f9c9ac09e8e1.zip
llvm-065cd64af3166da430bd03067514f9c9ac09e8e1.tar.gz
llvm-065cd64af3166da430bd03067514f9c9ac09e8e1.tar.bz2
[clang-repl] Teach clang-repl how to load PCHs (reprise) (#157359)
This is an updated version of @vgvassilev's PR from last year here: https://github.com/llvm/llvm-project/pull/94166 In short, it includes: 1. The fix for a blocking issue where `clang::Interpreter` (and thus `clang-repl`) cannot resolve symbols defined in a PCH 2. A test to prove this is working 3. A new hidden flag for `clang-repl` so that `llvm-lit` can match the host JIT triple between the PCH and `clang-repl`; previously, they may differ in some cases 4. Everything based on the latest LLVM main Shout out to @kylc for finding a logic issue which had us stumped for a while (and securing the [bounty](https://github.com/jank-lang/jank/issues/446)). --------- Co-authored-by: Vassil Vassilev <v.g.vassilev@gmail.com> Co-authored-by: Kyle Cesare <kcesare@gmail.com>
Diffstat (limited to 'clang/lib/CodeGen/ModuleBuilder.cpp')
-rw-r--r--clang/lib/CodeGen/ModuleBuilder.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/clang/lib/CodeGen/ModuleBuilder.cpp b/clang/lib/CodeGen/ModuleBuilder.cpp
index 8c1fee8..96f3f62 100644
--- a/clang/lib/CodeGen/ModuleBuilder.cpp
+++ b/clang/lib/CodeGen/ModuleBuilder.cpp
@@ -138,6 +138,8 @@ namespace {
assert(!M && "Replacing existing Module?");
M.reset(new llvm::Module(ExpandModuleName(ModuleName, CodeGenOpts), C));
+ IRGenFinished = false;
+
std::unique_ptr<CodeGenModule> OldBuilder = std::move(Builder);
Initialize(*Ctx);
@@ -179,6 +181,10 @@ namespace {
}
bool HandleTopLevelDecl(DeclGroupRef DG) override {
+ // Ignore interesting decls from the AST reader after IRGen is finished.
+ if (IRGenFinished)
+ return true; // We can't CodeGen more but pass to other consumers.
+
// FIXME: Why not return false and abort parsing?
if (Diags.hasUnrecoverableErrorOccurred())
return true;
@@ -292,8 +298,9 @@ namespace {
if (Builder)
Builder->clear();
M.reset();
- return;
}
+
+ IRGenFinished = true;
}
void AssignInheritanceModel(CXXRecordDecl *RD) override {