================
@@ -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) {
----------------
fogsong233 wrote:

I’ve found another approach. 
Semantically, the extern "C" functions aren't located in the most recent TU, 
but rather in `getExternCContextDecl()`. I’ve updated the logic to traverse 
this declaration instead, checking for entries whose lexical context is the 
most recent TU. This feels much more lightweight.

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