Skip to content

Commit c8f6fda

Browse files
anutosh491DavidSpickett
authored andcommitted
[clan-reply] Backport PTU error recovery to 20.x
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.
1 parent b8e10ca commit c8f6fda

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

clang/lib/Interpreter/IncrementalParser.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ void IncrementalParser::CleanUpPTU(TranslationUnitDecl *MostRecentTU) {
175175
// FIXME: We should de-allocate MostRecentTU
176176
for (Decl *D : MostRecentTU->decls()) {
177177
auto *ND = dyn_cast<NamedDecl>(D);
178-
if (!ND)
178+
if (!ND || ND->getDeclName().isEmpty())
179179
continue;
180180
// Check if we need to clean up the IdResolver chain.
181181
if (ND->getDeclName().getFETokenInfo() && !D->getLangOpts().ObjC &&

clang/test/Interpreter/lambda.cpp

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
// REQUIRES: host-supports-jit
22
// UNSUPPORTED: system-aix
3+
// At -O2, somehow "x = 42" appears first when piped into FileCheck,
4+
// see https://github.com/llvm/llvm-project/issues/143547.
5+
// UNSUPPORTED: system-windows
36
// RUN: cat %s | clang-repl | FileCheck %s
4-
// RUN: cat %s | clang-repl -Xcc -O2 | FileCheck %s
7+
// RUN: cat %s | clang-repl -Xcc -Xclang -Xcc -verify -Xcc -O2 | FileCheck %s
8+
59
extern "C" int printf(const char *, ...);
610

711
auto l1 = []() { printf("ONE\n"); return 42; };
@@ -14,4 +18,14 @@ auto r2 = l2();
1418
auto r3 = l2();
1519
// CHECK: TWO
1620

17-
%quit
21+
// Verify non-local lambda capture error is correctly reported
22+
int x = 42;
23+
24+
// expected-error {{non-local lambda expression cannot have a capture-default}}
25+
auto capture = [&]() { return x * 2; };
26+
27+
// Ensure interpreter continues and x is still valid
28+
printf("x = %d\n", x);
29+
// CHECK: x = 42
30+
31+
%quit

0 commit comments

Comments
 (0)