[clang] [clang][Modules] Diagnosing Module Redefinition Across ModuleMaps (PR #190085)
Naveen Seth Hanig via cfe-commits
cfe-commits at lists.llvm.org
Tue Apr 7 10:20:39 PDT 2026
================
@@ -0,0 +1,73 @@
+// Test duplicating module decls discovered during by-name module scanning with
+// a shared compiler instance.
+// This tests covers the case where the current modulemap we are loading
+// contains a module decl that satisfies two conditions:
+// 1. The compiler has seen the module decl during previous lookups.
+// 2. The previous decl comes from a different modulemap.
+// In this case, an error is produced with no dependency information returned.
+
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+// RUN: sed "s|DIR|%/t|g" %t/cdb.json.template > %t/cdb.json
+
+// Scenario setup:
+// - "A" is a framework module whose modulemap also declares an empty "B".
+// - A separate include path has its own B/module.modulemap that declares "B"
+// with a header depending on module "Dep"
+// We scan B first, and during A's scan, the compiler should report an error.
+
+// RUN: not clang-scan-deps -compilation-database %t/cdb.json -format \
+// RUN: experimental-full -module-names=B,A > %t/result_ab.json 2> %t/err.txt
+// RUN: cat %t/result_ab.json | sed 's:\\\\\?:/:g' | FileCheck -DPREFIX=%/t %s
+// RUN: cat %t/err.txt | sed 's:\\\\\?:/:g' | FileCheck -DPREFIX=%/t \
----------------
naveen-seth wrote:
I just built this locally while trying to review and it seems like the module graph is printed out for this error (, even though it usually doesn't print the graph).
https://github.com/llvm/llvm-project/pull/190085
More information about the cfe-commits
mailing list