1999500a2SRichard Smith// RUN: cd %S
238c1e6d3SRichard Smith// RUN: rm -rf %t
338c1e6d3SRichard Smith//
4216a3bd7SRichard Smith// RUN: %clang_cc1 -I. -x c++ -fmodule-name=test -fmodules -emit-module -fno-validate-pch -fmodules-strict-decluse %s -dependency-file - -MT implicit.pcm -o %t/implicit.pcm -fmodules-cache-path=%t -fmodule-map-file-home-is-cwd -fmodule-map-file=%S/Inputs/dependency-gen-base.modulemap | FileCheck %s --check-prefix=IMPLICIT
538c1e6d3SRichard Smith//
6216a3bd7SRichard Smith// RUN: %clang_cc1 -I. -x c++ -fmodule-name=test-base -fmodules -emit-module -fno-validate-pch -fmodules-strict-decluse Inputs/dependency-gen-base.modulemap -o %t/base.pcm -fmodule-map-file-home-is-cwd -fmodule-map-file=%S/Inputs/dependency-gen-base.modulemap
70f99d6a4SRichard Smith// RUN: %clang_cc1 -I. -x c++ -fmodule-name=test -fmodules -emit-module -fno-validate-pch -fmodules-strict-decluse -fmodule-file=%t/base.pcm %s -dependency-file - -MT explicit.pcm -o %t/explicit.pcm -fmodules-cache-path=%t -fmodule-map-file-home-is-cwd | FileCheck %s --check-prefix=EXPLICIT
8*be9b6c75SRichard Smith//
9*be9b6c75SRichard Smith// RUN: %clang_cc1 -I. -x c++ -fmodules -include Inputs/dependency-gen.h -x c++ /dev/null -fmodule-file=%t/explicit.pcm -MT main.o -fsyntax-only -dependency-file - | FileCheck %s --check-prefix=EXPLICIT-USE
10999500a2SRichard Smithmodule "test" {
11999500a2SRichard Smith  export *
12999500a2SRichard Smith  header "Inputs/dependency-gen.h"
13999500a2SRichard Smith  use "test-base"
14999500a2SRichard Smith  use "test-base2"
15999500a2SRichard Smith}
16999500a2SRichard Smith
170f99d6a4SRichard Smith// For implicit use of a module via the module cache, the input files
180f99d6a4SRichard Smith// referenced by the .pcm are also dependencies of this build.
190f99d6a4SRichard Smith//
200f99d6a4SRichard Smith// IMPLICIT-DAG: {{[/\\]}}dependency-gen.modulemap
210f99d6a4SRichard Smith// IMPLICIT-DAG: {{ |\.[/\\]}}Inputs{{[/\\]}}dependency-gen-base.modulemap
220f99d6a4SRichard Smith// IMPLICIT-DAG: {{ |\.[/\\]}}Inputs{{[/\\]}}dependency-gen-base2.modulemap
230f99d6a4SRichard Smith// IMPLICIT-DAG: {{ |\.[/\\]}}Inputs{{[/\\]}}dependency-gen.h
240f99d6a4SRichard Smith// IMPLICIT-DAG: {{ |\.[/\\]}}Inputs{{[/\\]}}dependency-gen-included.h
250f99d6a4SRichard Smith// IMPLICIT-DAG: {{ |\.[/\\]}}Inputs{{[/\\]}}dependency-gen-included2.h
262a6edb30SRichard Smith
270f99d6a4SRichard Smith// For an explicit use of a module via -fmodule-file=, the other module maps
280f99d6a4SRichard Smith// and included headers are not dependencies of this target (they are instead
290f99d6a4SRichard Smith// dependencies of the explicitly-specified .pcm input).
300f99d6a4SRichard Smith//
310f99d6a4SRichard Smith// EXPLICIT: {{^}}explicit.pcm:
32216a3bd7SRichard Smith// EXPLICIT-NOT: dependency-gen-
334b811648SNAKAMURA Takumi// EXPLICIT: {{.*[/\\]}}dependency-gen.modulemap
34216a3bd7SRichard Smith// EXPLICIT-NOT: dependency-gen-
351dbb9515SRichard Smith// EXPLICIT: base.pcm
361dbb9515SRichard Smith// EXPLICIT-NOT: dependency-gen-
370f99d6a4SRichard Smith// EXPLICIT: {{ |\.[/\\]}}Inputs{{[/\\]}}dependency-gen.h
38216a3bd7SRichard Smith// EXPLICIT-NOT: dependency-gen-
39*be9b6c75SRichard Smith
40*be9b6c75SRichard Smith// EXPLICIT-USE: main.o:
41*be9b6c75SRichard Smith// EXPLICIT-USE-NOT: base.pcm
42*be9b6c75SRichard Smith// EXPLICIT-USE: explicit.pcm
43*be9b6c75SRichard Smith// EXPLICIT-USE-NOT: base.pcm
44