[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
Tue Feb 10 06:14:02 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:

Can you point me to the code where the declaration is being added in the `ExternCContext` context?

https://github.com/llvm/llvm-project/pull/178648


More information about the cfe-commits mailing list