[clang] [clang][Modules] Diagnosing Module Redefinition Across ModuleMaps (PR #190085)
Qiongsi Wu via cfe-commits
cfe-commits at lists.llvm.org
Wed Apr 8 10:08:38 PDT 2026
================
@@ -0,0 +1,65 @@
+// 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.
+// Specifically, we have the following 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: rm -rf %t
+// RUN: split-file %s %t
+// RUN: sed "s|DIR|%/t|g" %t/cdb.json.template > %t/cdb.json
+
+// RUN: not clang-scan-deps -compilation-database %t/cdb.json -format \
+// RUN: experimental-full -module-names=B,A 2>&1 | \
+// RUN: sed 's:\\\\\?:/:g' | FileCheck -DPREFIX=%/t %s
----------------
qiongsiwu wrote:
This is to handle file path separators on Windows. I want to check that we are diagnosing across different ModuleMaps correctly, so I am checking against a longer path. The sed replaces `\\` on Windows with `/` so the check lines below match on Windows as well.
https://github.com/llvm/llvm-project/pull/190085
More information about the cfe-commits
mailing list