[clang] [clang][ModulesDriver] Add support for Clang modules to -fmodules-driver (PR #187606)

Naveen Seth Hanig via cfe-commits cfe-commits at lists.llvm.org
Wed Apr 1 18:19:18 PDT 2026


================
@@ -0,0 +1,75 @@
+// Checks that -fmodules-driver correctly handles compilations using Clang modules.
+
+// RUN: split-file %s %t
+// RUN: rm -rf %t/modules-cache
+// RUN: %clang -std=c++23 \
+// RUN: -fmodules-driver -Rmodules-driver \
+// RUN: -fmodules -Rmodule-import \
+// RUN: -fmodule-map-file=%t/module.modulemap \
+// RUN: -fmodules-cache-path=%t/modules-cache \
+// RUN: -fsyntax-only %t/main.cpp 2>&1 \
+// RUN: | sed 's:\\\\\?:/:g' \
+// RUN: | FileCheck -DPREFIX=%/t %s
+
+// The scan itself will also produce [-Rmodule-import] remarks.
+// Let's skip past them, we only care about the final -cc1 commands.
+// CHECK:       clang: remark: printing module dependency graph [-Rmodules-driver]
+// CHECK-NEXT:  digraph "Module Dependency Graph" {
+// CHECK:       }
+
+// CHECK:      [[PREFIX]]/main.cpp:1:2: remark: importing module 'root' from
+// CHECK:      [[PREFIX]]/main.cpp:1:2: remark: importing module 'direct1' into 'root'
+// CHECK:      [[PREFIX]]/main.cpp:1:2: remark: importing module 'transitive1' into 'direct1'
+// CHECK:      [[PREFIX]]/main.cpp:1:2: remark: importing module 'transitive2' into 'direct1'
+// CHECK:      [[PREFIX]]/main.cpp:1:2: remark: importing module 'direct2' into 'root'
+// CHECK:      [[PREFIX]]/main.cpp:1:2: remark: importing module 'transitive2' into 'direct2'
----------------
naveen-seth wrote:

Those were missing. Added!

Both of these tests kept passing without the changes introduced in this PR, because I forgot to install the command-lines for jobs which are not Clang module precompile jobs.
For this test, an implicit module build is performed instead then...

The updated test guards against this now.

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


More information about the cfe-commits mailing list