[clang] [clang][modules] Include `-fmodule-map-file=` in context hash (PR #227776)

Cyndy Ishida via cfe-commits cfe-commits at lists.llvm.org
Wed Sep 30 09:53:53 PDT 2026


================
@@ -0,0 +1,41 @@
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+
+// Build A without knowing about the module map for B.
+//
+// This means "b.h" is included textually and embedded into the PCM for module A
+// with B_VALUE set to 1.
+//
+// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t/cache \
+// RUN:   -fmodules-strict-context-hash -I %t/a -I %t/b %t/tu.c -E -o -
+
+// Load A with module map for B being known.
+// 
+// This should make it so that module A turns the header inclusion into a module
+// import of B, which gets built with clean preprocessor state, resulting in the
+// macro B_VALUE set to 2.
+//
+// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t/cache \
+// RUN:   -fmodules-strict-context-hash -I %t/a -I %t/b %t/tu.c -E -o - \
+// RUN:   -fmodule-map-file=%t/b/b.modulemap | FileCheck %s
----------------
cyndyishida wrote:

nit: my preference is to also explicitly or directly check the hashes no longer match between the 2 invocations or that the earlier PCM is not reused.

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


More information about the cfe-commits mailing list