[clang] [C++20] [Modules] Don't set modules owner ship information for builtin declarations (PR #102115)

Chuanqi Xu via cfe-commits cfe-commits at lists.llvm.org
Wed Aug 7 19:32:26 PDT 2024


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


More information about the cfe-commits mailing list