[clang] [clang][modules] giving the __stddef_ headers their own modules can cause redeclaration errors with -fbuiltin-headers-in-system-modules (PR #84127)

Ian Anderson via cfe-commits cfe-commits at lists.llvm.org
Mon Mar 11 20:47:06 PDT 2024


================
@@ -2498,9 +2498,12 @@ void ModuleMapParser::parseHeaderDecl(MMToken::TokenKind LeadingToken,
   }
 
   bool NeedsFramework = false;
-  // Don't add the top level headers to the builtin modules if the builtin headers
-  // belong to the system modules.
-  if (!Map.LangOpts.BuiltinHeadersInSystemModules || ActiveModule->isSubModule() || !isBuiltInModuleName(ActiveModule->Name))
+  // Don't add headers to the builtin modules if the builtin headers belong to
+  // the system modules, with the exception of __stddef_max_align_t.h which
+  // always had its own module.
+  if (!Map.LangOpts.BuiltinHeadersInSystemModules ||
+      !isBuiltInModuleName(ActiveModule->getTopLevelModuleName()) ||
+      ActiveModule->fullModuleNameIs({"_Builtin_stddef", "max_align_t"}))
----------------
ian-twilightcoder wrote:

I don't really know the right answer, __stddef_wint_t.h is a weird one. Strictly speaking it wasn't modular so anyone could import it previously. But then it's not really supposed to be part of stddef.h, and you have to specifically opt into seeing it., i.e. if you just include stddef.h you never got __stddef_wint_t.h. So maybe it's ok that it's unconditionally in its own module. Or maybe it needs to be added to `isBuiltInModuleName`.

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


More information about the cfe-commits mailing list