================ @@ -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); ---------------- mizvekov 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. That's what I mean, both the eager and lazy situations are odd, but at least the eager one works now, so if we handle the lazy ones the same way, then we are also being more consistent and less wrong at the same time, which might justify this as incremental improvement :) > 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? I was hoping there would be a clean way to do this, even if it meant rewriting this bit about how we set module ownership from the new operator. I'll take a look at the implementation tomorrow and see if I can come up with any concrete suggestions. 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