[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 01:31:28 PST 2026
================
@@ -192,6 +201,32 @@ void IncrementalParser::CleanUpPTU(TranslationUnitDecl *MostRecentTU) {
!D->getLangOpts().CPlusPlus)
S.IdResolver.RemoveDecl(ND);
}
+
+ // In C, implicit function declarations are not lexically attached to the
+ // current PTU, so they cannot be found in
+ // MostRecentTU->getPrimaryContext()->getLookupPtr(). We must traverse the
+ // entire IdentifierTable to locate them.
+ // FIXME: Is there a more lightweight solution?
+ llvm::SmallVector<NamedDecl *, 2> NamedDeclsToRemove;
+ if (!S.getLangOpts().CPlusPlus) {
+ for (auto &Entry : S.getASTContext().Idents) {
----------------
vgvassilev wrote:
We should not loop over all of the identifiers. We should do the opposite: given a named declaration we should check if the name is on the identifier resolver chain and remove it. What happens when the implicit decl is created? Does it end up in the same PTU?
https://github.com/llvm/llvm-project/pull/178648
More information about the cfe-commits
mailing list