1 // Unsupported on AIX because we don't support the requisite "__clangast"
2 // section in XCOFF yet.
3 // UNSUPPORTED: target={{.*}}-aix{{.*}}
5 // Check that when depending on a precompiled module, we depend on the
6 // **top-level** module. Submodules don't have some information present (for
7 // example the path to the modulemap file) and depending on them might cause
8 // problems in the dependency scanner (e.g. generating empty `-fmodule-map-file=`
11 // RUN: rm -rf %t && mkdir %t
12 // RUN: cp %S/Inputs/modules-pch-common-submodule/* %t
14 // Scan dependencies of the PCH:
16 // RUN: sed "s|DIR|%/t|g" %S/Inputs/modules-pch-common-submodule/cdb_pch.json > %t/cdb.json
17 // RUN: clang-scan-deps -compilation-database %t/cdb.json -format experimental-full \
18 // RUN: -module-files-dir %t/build > %t/result_pch.json
19 // RUN: cat %t/result_pch.json | sed 's:\\\\\?:/:g' | FileCheck %s -DPREFIX=%/t -check-prefix=CHECK-PCH
22 // CHECK-PCH-NEXT: "modules": [
24 // CHECK-PCH-NEXT: "clang-module-deps": [],
25 // CHECK-PCH-NEXT: "clang-modulemap-file": "[[PREFIX]]/module.modulemap",
26 // CHECK-PCH-NEXT: "command-line": [
28 // CHECK-PCH-NEXT: "context-hash": "[[HASH_MOD_COMMON:.*]]",
29 // CHECK-PCH-NEXT: "file-deps": [
30 // CHECK-PCH-NEXT: "[[PREFIX]]/module.modulemap",
31 // CHECK-PCH-NEXT: "[[PREFIX]]/mod_common.h",
32 // CHECK-PCH-NEXT: "[[PREFIX]]/mod_common_sub.h"
34 // CHECK-PCH-NEXT: "link-libraries": [],
35 // CHECK-PCH-NEXT: "name": "ModCommon"
38 // CHECK-PCH-NEXT: "translation-units": [
40 // CHECK-PCH: "clang-context-hash": "[[HASH_PCH:.*]]",
41 // CHECK-PCH-NEXT: "clang-module-deps": [
43 // CHECK-PCH-NEXT: "context-hash": "[[HASH_MOD_COMMON]]",
44 // CHECK-PCH-NEXT: "module-name": "ModCommon"
47 // CHECK-PCH-NEXT: "command-line": [
49 // CHECK-PCH: "file-deps": [
50 // CHECK-PCH-NEXT: "[[PREFIX]]/pch.h"
52 // CHECK-PCH-NEXT: "input-file": "[[PREFIX]]/pch.h"
55 // Explicitly build the PCH:
57 // RUN: %deps-to-rsp %t/result_pch.json --module-name=ModCommon > %t/mod_common.cc1.rsp
58 // RUN: %deps-to-rsp %t/result_pch.json --tu-index=0 > %t/pch.rsp
60 // RUN: %clang @%t/mod_common.cc1.rsp
61 // RUN: %clang @%t/pch.rsp
63 // Scan dependencies of the TU:
65 // RUN: sed "s|DIR|%/t|g" %S/Inputs/modules-pch-common-submodule/cdb_tu.json > %t/cdb.json
66 // RUN: clang-scan-deps -compilation-database %t/cdb.json -format experimental-full \
67 // RUN: -module-files-dir %t/build > %t/result_tu.json
68 // RUN: cat %t/result_tu.json | sed 's:\\\\\?:/:g' | FileCheck %s -DPREFIX=%/t -check-prefix=CHECK-TU
71 // CHECK-TU-NEXT: "modules": [
73 // CHECK-TU-NEXT: "clang-module-deps": [],
74 // CHECK-TU-NEXT: "clang-modulemap-file": "[[PREFIX]]/module.modulemap",
75 // CHECK-TU-NEXT: "command-line": [
77 // CHECK-TU-NEXT: "context-hash": "[[HASH_MOD_TU:.*]]",
78 // CHECK-TU-NEXT: "file-deps": [
79 // CHECK-TU-NEXT: "[[PREFIX]]/module.modulemap",
80 // CHECK-TU-NEXT: "[[PREFIX]]/mod_tu.h"
82 // CHECK-TU-NEXT: "link-libraries": [],
83 // CHECK-TU-NEXT: "name": "ModTU"
86 // CHECK-TU-NEXT: "translation-units": [
88 // CHECK-TU: "clang-context-hash": "[[HASH_TU:.*]]",
89 // CHECK-TU-NEXT: "clang-module-deps": [
91 // CHECK-TU-NEXT: "context-hash": "[[HASH_MOD_TU]]"
92 // CHECK-TU-NEXT: "module-name": "ModTU"
95 // CHECK-TU-NEXT: "command-line": [
97 // CHECK-TU: "file-deps": [
98 // CHECK-TU-NEXT: "[[PREFIX]]/tu.c",
99 // CHECK-TU-NEXT: "[[PREFIX]]/pch.h.pch"
101 // CHECK-TU-NEXT: "input-file": "[[PREFIX]]/tu.c"
104 // Explicitly build the TU:
106 // RUN: %deps-to-rsp %t/result_tu.json --module-name=ModTU > %t/mod_tu.cc1.rsp
107 // RUN: %deps-to-rsp %t/result_tu.json --tu-index=0 > %t/tu.rsp
109 // RUN: %clang @%t/mod_tu.cc1.rsp
110 // RUN: %clang @%t/tu.rsp