Skip to content

[clan-reply] Backport PTU error recovery to 20.x #143893

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

Merged
merged 1 commit into from
Jun 13, 2025

Conversation

DavidSpickett
Copy link
Collaborator

@DavidSpickett DavidSpickett commented Jun 12, 2025

This cherry-picks 3b4c51b and beffd15 to 20.x.

Which are:
[clang-repl] Fix error recovery while PTU cleanup (#127467)
[clang][Interpreter] Disable part of lambda test on Windows

The latter commit avoids a test failure seen in Windows builds. On main, I turned off one of the RUN lines for Windows, but reviewers on the cherry-pick preferred UNSUPPORTED to disable the whole test.

So I have used UNSUPPORTED in this version for 20.x.

@DavidSpickett DavidSpickett added this to the LLVM 20.X Release milestone Jun 12, 2025
@github-project-automation github-project-automation bot moved this to Needs Triage in LLVM Release Status Jun 12, 2025
@llvmbot llvmbot added clang Clang issues not falling into any other category clang:frontend Language frontend issues, e.g. anything involving "Sema" labels Jun 12, 2025
@llvmbot
Copy link
Member

llvmbot commented Jun 12, 2025

@llvm/pr-subscribers-clang

Author: David Spickett (DavidSpickett)

Changes

This cherry-picks 3b4c51b and beffd15 to 20.x.

Which are:
[clang-repl] Fix error recovery while PTU cleanup (#127467) [clang][Interpreter] Disable part of lambda test on Windows

The latter commit avoids a test failure seen in Windows builds. On main, I turned off one of the RUN lines for Windows, but reviewers on the cherry-pick preferred UNSUPPORTED to disable the whole test.

So I have used UNSUPPORTED in this version for 20.x.


Full diff: https://github.com/llvm/llvm-project/pull/143893.diff

2 Files Affected:

  • (modified) clang/lib/Interpreter/IncrementalParser.cpp (+1-1)
  • (modified) clang/test/Interpreter/lambda.cpp (+16-2)
diff --git a/clang/lib/Interpreter/IncrementalParser.cpp b/clang/lib/Interpreter/IncrementalParser.cpp
index e43cea1baf43a..1d223e230669c 100644
--- a/clang/lib/Interpreter/IncrementalParser.cpp
+++ b/clang/lib/Interpreter/IncrementalParser.cpp
@@ -175,7 +175,7 @@ void IncrementalParser::CleanUpPTU(TranslationUnitDecl *MostRecentTU) {
   // FIXME: We should de-allocate MostRecentTU
   for (Decl *D : MostRecentTU->decls()) {
     auto *ND = dyn_cast<NamedDecl>(D);
-    if (!ND)
+    if (!ND || ND->getDeclName().isEmpty())
       continue;
     // Check if we need to clean up the IdResolver chain.
     if (ND->getDeclName().getFETokenInfo() && !D->getLangOpts().ObjC &&
diff --git a/clang/test/Interpreter/lambda.cpp b/clang/test/Interpreter/lambda.cpp
index df75274a050b2..fee6c73bf95cb 100644
--- a/clang/test/Interpreter/lambda.cpp
+++ b/clang/test/Interpreter/lambda.cpp
@@ -1,7 +1,11 @@
 // REQUIRES: host-supports-jit
 // UNSUPPORTED: system-aix
+// At -O2, somehow "x = 42" appears first when piped into FileCheck,
+// see https://github.com/llvm/llvm-project/issues/143547.
+// UNSUPPORTED: system-windows
 // RUN: cat %s | clang-repl | FileCheck %s
-// RUN: cat %s | clang-repl -Xcc -O2 | FileCheck %s
+// RUN: cat %s | clang-repl -Xcc -Xclang -Xcc -verify -Xcc -O2 | FileCheck %s
+
 extern "C" int printf(const char *, ...);
 
 auto l1 = []() { printf("ONE\n"); return 42; };
@@ -14,4 +18,14 @@ auto r2 = l2();
 auto r3 = l2();
 // CHECK: TWO
 
-%quit
+// Verify non-local lambda capture error is correctly reported
+int x = 42;
+
+// expected-error {{non-local lambda expression cannot have a capture-default}}
+auto capture = [&]() { return x * 2; };
+
+// Ensure interpreter continues and x is still valid
+printf("x = %d\n", x);
+// CHECK: x = 42
+
+%quit
\ No newline at end of file

@github-project-automation github-project-automation bot moved this from Needs Triage to Needs Merge in LLVM Release Status Jun 12, 2025
Copy link
Contributor

@vgvassilev vgvassilev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

This cherry-picks 3b4c51b and
beffd15 to 20.x.

Which are:
[clang-repl] Fix error recovery while PTU cleanup (llvm#127467)
[clang][Interpreter] Disable part of lambda test on Windows

The latter commit avoids a test failure seen in Windows builds.
On main, I turned off one of the RUN lines for Windows, but reviewers
on the cherry-pick preferred UNSUPPORTED to disable the whole test.

So I have used UNSUPPORTED in this version for 20.x.
@tstellar tstellar merged commit 9ba132b into llvm:release/20.x Jun 13, 2025
7 of 8 checks passed
@github-project-automation github-project-automation bot moved this from Needs Merge to Done in LLVM Release Status Jun 13, 2025
Copy link

@DavidSpickett (or anyone else). If you would like to add a note about this fix in the release notes (completely optional). Please reply to this comment with a one or two sentence description of the fix. When you are done, please add the release:note label to this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:frontend Language frontend issues, e.g. anything involving "Sema" clang Clang issues not falling into any other category
Projects
Development

Successfully merging this pull request may close these issues.

5 participants