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

Matheus Izvekov via cfe-commits cfe-commits at lists.llvm.org
Wed Aug 7 11:34:17 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);
----------------
mizvekov wrote:

Since as you pointed out we already have this oddness for eagerly created implicit declarations, it seems like it would be an incremental improvement to have the same non-ideal outcome for both.

But I think the means to achieve it as implemented in the current patch looks fragile.

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.

https://github.com/llvm/llvm-project/pull/102115


More information about the cfe-commits mailing list