[clang] [clang][Modules] Diagnosing Module Redefinition Across ModuleMaps (PR #190085)

Qiongsi Wu via cfe-commits cfe-commits at lists.llvm.org
Tue Apr 7 15:54:22 PDT 2026


================
@@ -1756,9 +1756,24 @@ void ModuleMapLoader::handleModuleDecl(const modulemap::ModuleDecl &MD) {
   if (Module *Existing = Map.lookupModuleQualified(ModuleName, ActiveModule)) {
     // We might see a (re)definition of a module that we already have a
     // definition for in four cases:
-    //  - If we loaded one definition from an AST file and we've just found a
-    //    corresponding definition in a module map file, or
+    //  - If we loaded one definition from an AST file and we've just found the
+    //    corresponding definition in the same module map file, or
     bool LoadedFromASTFile = Existing->IsFromModuleFile;
+    if (LoadedFromASTFile) {
----------------
qiongsiwu wrote:

We handle the case of duplicating decl in a same modulemap as a different check below [here](https://github.com/llvm/llvm-project/pull/190085/changes#diff-d94525ab4a88e7d89af25aefc58749191bd3482aecb157c8d13c7efde65e61e1R1800). 

I added to test cases to explicitly test duplicating module decls in the same modulemap. The test cases pass without this patch (meaning that existing check already covers them). 

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


More information about the cfe-commits mailing list