[clang-repl] Recover the lookup tables of the primary context.

Before this patch, there was re-declaration error if error was encountered in
the same line. The recovery support acted only if this type of error was
encountered in the first line of the program and not in subsequent lines.

For example:

```
clang-repl> int i=9;
clang-repl> int j=9; err;
input_line_3:1:5: error: redefinition of 'j'
int j = 9;
```

Differential revision: https://reviews.llvm.org/D123674
This commit is contained in:
Purva-Chaudhari 2022-05-29 04:55:10 +00:00 committed by Vassil Vassilev
parent 41a054ef78
commit 5ff27fe1ff
2 changed files with 2 additions and 1 deletions

View File

@ -188,7 +188,7 @@ IncrementalParser::ParseOrWrapTopLevelDecl() {
S.TUScope->setEntity(PreviousTU);
// Clean up the lookup table
if (StoredDeclsMap *Map = PreviousTU->getLookupPtr()) {
if (StoredDeclsMap *Map = PreviousTU->getPrimaryContext()->getLookupPtr()) {
for (auto I = Map->begin(); I != Map->end(); ++I) {
StoredDeclsList &List = I->second;
DeclContextLookupResult R = List.getLookupResult();

View File

@ -1,3 +1,4 @@
// RUN: clang-repl "int x = 10;" "int y=7; err;" "int y = 10;"
// RUN: clang-repl "int i = 10;" 'extern "C" int printf(const char*,...);' \
// RUN: 'auto r1 = printf("i = %d\n", i);' | FileCheck --check-prefix=CHECK-DRIVER %s
// REQUIRES: host-supports-jit