diff options
author | Vassil Vassilev <v.g.vassilev@gmail.com> | 2024-05-21 20:21:32 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-21 20:21:32 +0300 |
commit | 253c28fa829cee0104c2fc59ed1a958980b5138c (patch) | |
tree | 8c541029dd0542e925c614e42ffd541a6329120d /clang/lib/Sema/SemaDecl.cpp | |
parent | 98f105a1304e8d3fd0a0234d1d488ed513833df8 (diff) | |
download | llvm-253c28fa829cee0104c2fc59ed1a958980b5138c.zip llvm-253c28fa829cee0104c2fc59ed1a958980b5138c.tar.gz llvm-253c28fa829cee0104c2fc59ed1a958980b5138c.tar.bz2 |
[clang-repl] Extend the C support. (#89804)
The IdResolver chain is the main way for C to implement lookup rules.
Every new partial translation unit caused clang to exit the top-most
scope which in turn cleaned up the IdResolver chain. That was not an
issue for C++ because its lookup is implemented on the level of
declaration contexts.
This patch keeps the IdResolver chain across partial translation units
maintaining proper C-style lookup infrastructure.
Diffstat (limited to 'clang/lib/Sema/SemaDecl.cpp')
-rw-r--r-- | clang/lib/Sema/SemaDecl.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index 6764a97..7f6921e 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -2282,9 +2282,13 @@ void Sema::ActOnPopScope(SourceLocation Loc, Scope *S) { if (LabelDecl *LD = dyn_cast<LabelDecl>(D)) CheckPoppedLabel(LD, *this, addDiag); - // Remove this name from our lexical scope, and warn on it if we haven't - // already. - IdResolver.RemoveDecl(D); + // Partial translation units that are created in incremental processing must + // not clean up the IdResolver because PTUs should take into account the + // declarations that came from previous PTUs. + if (!PP.isIncrementalProcessingEnabled()) + IdResolver.RemoveDecl(D); + + // Warn on it if we are shadowing a declaration. auto ShadowI = ShadowingDecls.find(D); if (ShadowI != ShadowingDecls.end()) { if (const auto *FD = dyn_cast<FieldDecl>(ShadowI->second)) { |