1 // Unsupported on AIX because we don't support the requisite "__clangast"
2 // section in XCOFF yet.
3 // UNSUPPORTED: target={{.*}}-aix{{.*}}
5 // Check that we discover dependency on a precompiled module when it's imported
6 // by a **submodule** instead of a top-level module.
8 // RUN: rm -rf %t && mkdir %t
9 // RUN: cp %S/Inputs/modules-pch-common-via-submodule/* %t
11 // Scan dependencies of the PCH:
13 // RUN: sed "s|DIR|%/t|g" %S/Inputs/modules-pch-common-via-submodule/cdb_pch.json > %t/cdb.json
14 // RUN: clang-scan-deps -compilation-database %t/cdb.json -format experimental-full \
15 // RUN: -module-files-dir %t/build > %t/result_pch.json
16 // RUN: cat %t/result_pch.json | sed 's:\\\\\?:/:g' | FileCheck %s -DPREFIX=%/t -check-prefix=CHECK-PCH
19 // CHECK-PCH-NEXT: "modules": [
21 // CHECK-PCH-NEXT: "clang-module-deps": [],
22 // CHECK-PCH-NEXT: "clang-modulemap-file": "[[PREFIX]]/module.modulemap",
23 // CHECK-PCH-NEXT: "command-line": [
25 // CHECK-PCH-NEXT: "context-hash": "[[HASH_MOD_COMMON:.*]]",
26 // CHECK-PCH-NEXT: "file-deps": [
27 // CHECK-PCH-NEXT: "[[PREFIX]]/module.modulemap",
28 // CHECK-PCH-NEXT: "[[PREFIX]]/mod_common.h"
30 // CHECK-PCH-NEXT: "link-libraries": [],
31 // CHECK-PCH-NEXT: "name": "ModCommon"
34 // CHECK-PCH-NEXT: "translation-units": [
36 // CHECK-PCH: "clang-context-hash": "[[HASH_PCH:.*]]",
37 // CHECK-PCH-NEXT: "clang-module-deps": [
39 // CHECK-PCH-NEXT: "context-hash": "[[HASH_MOD_COMMON]]",
40 // CHECK-PCH-NEXT: "module-name": "ModCommon"
43 // CHECK-PCH-NEXT: "command-line": [
45 // CHECK-PCH: "file-deps": [
46 // CHECK-PCH-NEXT: "[[PREFIX]]/pch.h"
48 // CHECK-PCH-NEXT: "input-file": "[[PREFIX]]/pch.h"
51 // Explicitly build the PCH:
53 // RUN: %deps-to-rsp %t/result_pch.json --module-name=ModCommon > %t/mod_common.cc1.rsp
54 // RUN: %deps-to-rsp %t/result_pch.json --tu-index=0 > %t/pch.rsp
56 // RUN: %clang @%t/mod_common.cc1.rsp
57 // RUN: %clang @%t/pch.rsp
59 // Scan dependencies of the TU:
61 // RUN: sed "s|DIR|%/t|g" %S/Inputs/modules-pch-common-via-submodule/cdb_tu.json > %t/cdb.json
62 // RUN: clang-scan-deps -compilation-database %t/cdb.json -format experimental-full \
63 // RUN: -module-files-dir %t/build > %t/result_tu.json
64 // RUN: cat %t/result_tu.json | sed 's:\\\\\?:/:g' | FileCheck %s -DPREFIX=%/t -check-prefix=CHECK-TU
67 // CHECK-TU-NEXT: "modules": [
69 // CHECK-TU-NEXT: "clang-module-deps": [],
70 // CHECK-TU-NEXT: "clang-modulemap-file": "[[PREFIX]]/module.modulemap",
71 // CHECK-TU-NEXT: "command-line": [
73 // CHECK-TU-NEXT: "context-hash": "[[HASH_MOD_TU:.*]]",
74 // CHECK-TU-NEXT: "file-deps": [
75 // CHECK-TU-NEXT: "[[PREFIX]]/module.modulemap",
76 // CHECK-TU-NEXT: "[[PREFIX]]/mod_tu.h",
77 // CHECK-TU-NEXT: "[[PREFIX]]/mod_tu_sub.h"
79 // CHECK-TU-NEXT: "link-libraries": [],
80 // CHECK-TU-NEXT: "name": "ModTU"
83 // CHECK-TU-NEXT: "translation-units": [
85 // CHECK-TU: "clang-context-hash": "[[HASH_TU:.*]]",
86 // CHECK-TU-NEXT: "clang-module-deps": [
88 // CHECK-TU-NEXT: "context-hash": "[[HASH_MOD_TU]]"
89 // CHECK-TU-NEXT: "module-name": "ModTU"
92 // CHECK-TU-NEXT: "command-line": [
94 // CHECK-TU: "file-deps": [
95 // CHECK-TU-NEXT: "[[PREFIX]]/tu.c",
96 // CHECK-TU-NEXT: "[[PREFIX]]/pch.h.pch"
98 // CHECK-TU-NEXT: "input-file": "[[PREFIX]]/tu.c"
101 // Explicitly build the TU:
103 // RUN: %deps-to-rsp %t/result_tu.json --module-name=ModTU > %t/mod_tu.cc1.rsp
104 // RUN: %deps-to-rsp %t/result_tu.json --tu-index=0 > %t/tu.rsp
106 // RUN: %clang @%t/mod_tu.cc1.rsp
107 // RUN: %clang @%t/tu.rsp