================
@@ -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:

> This is somewhat coincidence. We would create the builtin TypedefDecls in 
> `Sema::Initialize()`. But we haven't assign a module for the TU that time. So 
> it works more or less surprisingly. The difference between the builtin 
> typedef declaration and the current builtin function decl is that, the 
> builtin typedef declaration are created eagerly and the builtin function 
> decls is created lazily.

I see. This eagerness of creating these TypedefDecls is something that annoys 
me a little as well.
I think whatever outcome we end up with, should be the same for both.


> BTW, another idea may be, attach the builtin function decl to the global 
> module. But now, the implementation may only create the global module (in 
> implementation, it is actually the global module fragment in the 
> specification) conditionally, in another word, we will only create the global 
> module fragment after we see `module;`. So the idea may be more complex.

Yeah, attaching these things to the global module seems like a clean approach 
as well, I like that :)
What are the difficulties involved in always creating the GMF in this case?


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