================
@@ -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
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to