================
@@ -2376,6 +2376,12 @@ NamedDecl *Sema::LazilyCreateBuiltin(IdentifierInfo *II, 
unsigned ID,
   FunctionDecl *New = CreateBuiltin(II, R, ID, Loc);
   RegisterLocallyScopedExternCDecl(New, S);
 
+  // Builtin functions shouldn't be owned by any module.
+  if (New->hasOwningModule()) {
+    New->setLocalOwningModule(nullptr);
----------------
ChuanqiXu9 wrote:

I don't think we need to handle the eagerly created implicit declarations as we 
did in the current patch. Since they actually work fine now.

> As Corentin suggested, I'd rather change the context around when we lazily 
> create the builtin, than not having to forget to change it later.

But the modules owner ship are attached immediately when we new the builtin 
declarations. If we want to do that in the first place, we can only clear the 
modules ownership for the TU before the new operation and reset it for the TU 
again after the new operation. It looks pretty odd. Or do I misunderstand your 
point?

https://github.com/llvm/llvm-project/pull/102115
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to