[clang] [clang-repl] fix CleanUpPTU by removing decl according to C implicitly FuncitonDecl. (PR #178648)
Vassil Vassilev via cfe-commits
cfe-commits at lists.llvm.org
Mon Feb 9 06:44:37 PST 2026
================
@@ -182,6 +183,30 @@ void IncrementalParser::CleanUpPTU(TranslationUnitDecl *MostRecentTU) {
}
}
+ auto *ECCD = S.getASTContext().getExternCContextDecl();
+ if (auto *Map = ECCD->getPrimaryContext()->getLookupPtr()) {
+ for (auto &&[Key, List] : *Map) {
+ DeclContextLookupResult R = List.getLookupResult();
+ std::vector<NamedDecl *> NamedDeclsToRemove;
+ for (NamedDecl *D : R) {
+ // Implicitly generated C decl is not attached to the current TU but
+ // lexically attached to the recent TU, so we need to check the lexical
+ // context.
----------------
vgvassilev wrote:
That part makes me uncomfortable. We try to iterate over the lookup candidates in this case. However, is there a route from the `MostRecentTU` to the declaration that was created. Isn't it part from the DeclContext part of the object? If there is no way to get it, then there is some logical flow in either clang, where the implicit declaration creation does not respect the active TU or something else.
https://github.com/llvm/llvm-project/pull/178648
More information about the cfe-commits
mailing list