[clan-reply] Backport PTU error recovery to 20.x · llvm/llvm-project@9ba132b (original) (raw)

2 files changed

lines changed

Original file line number Diff line number Diff line change
@@ -175,7 +175,7 @@ void IncrementalParser::CleanUpPTU(TranslationUnitDecl *MostRecentTU) {
175 175 // FIXME: We should de-allocate MostRecentTU
176 176 for (Decl *D : MostRecentTU->decls()) {
177 177 auto *ND = dyn_cast(D);
178 -if (!ND)
178 +if (!ND |
179 179 continue;
180 180 // Check if we need to clean up the IdResolver chain.
181 181 if (ND->getDeclName().getFETokenInfo() && !D->getLangOpts().ObjC &&
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
1 1 // REQUIRES: host-supports-jit
2 2 // 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
3 6 // 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 +
5 9 extern "C" int printf(const char *, ...);
6 10
7 11 auto l1 = []() { printf("ONE\n"); return 42; };
@@ -14,4 +18,14 @@ auto r2 = l2();
14 18 auto r3 = l2();
15 19 // CHECK: TWO
16 20
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