[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
Tue Aug 6 20:16:33 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:

The bug report is unclear to me.

Are you saying this is a bug, or are you just saying the AST representation is not clean from a user understanding point of view?

The "external C++" linkage affects the VarDecl, but not the builtin FunctionDecl, so again this is unclear.

Also, would this really only apply to builtin functions?
What about builtin TypedefDecls?

It's also strange that they would belong to the TU, and the TU would belong to the module, but the builtin itself would not.
Can this situation currently arise for anything else?

If this is a cleanliness issue, can we instead create a builtin module, add all those builtin declarations to a TU belonging to that module, and then implicitly import it in every module?
Is that idea workable?


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


More information about the cfe-commits mailing list