[clang] [C++20] [Modules] Warn for importing implementation partition unit in interface units (PR #108493)

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Fri Sep 13 06:57:13 PDT 2024


================
@@ -650,6 +650,14 @@ DeclResult Sema::ActOnModuleImport(SourceLocation StartLoc,
   else
     VisibleModules.setVisible(Mod, ImportLoc);
 
+  assert((!Mod->isModulePartitionImplementation() || getCurrentModule()) &&
+         "We can only import a partition unit in a named module.");
+  if (Mod->isModulePartitionImplementation() &&
+      getCurrentModule()->isModuleInterfaceUnit())
+    Diag(ImportLoc,
+         diag::warn_import_implementation_partition_unit_in_interface_unit)
+        << Mod->Name;
----------------
AaronBallman wrote:

Not for this PR, but at some point it might make sense to have an overload for `operator<<` so we can pass a `const Module *` directly and it automatically quotes the name, similar to how `NamedDecl` works.

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


More information about the cfe-commits mailing list