[clang][modules] Don't prevent translation of FW_Private includes when explicitly...
[llvm-project.git] / clang / test / ClangScanDeps / modules-pch-common-via-submodule.c
blob93aa22891d2a2d8d197b051ef7045dbaf332663c
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
18 // CHECK-PCH: {
19 // CHECK-PCH-NEXT: "modules": [
20 // CHECK-PCH-NEXT: {
21 // CHECK-PCH-NEXT: "clang-module-deps": [],
22 // CHECK-PCH-NEXT: "clang-modulemap-file": "[[PREFIX]]/module.modulemap",
23 // CHECK-PCH-NEXT: "command-line": [
24 // CHECK-PCH: ],
25 // CHECK-PCH-NEXT: "context-hash": "[[HASH_MOD_COMMON:.*]]",
26 // CHECK-PCH-NEXT: "file-deps": [
27 // CHECK-PCH-NEXT: "[[PREFIX]]/mod_common.h",
28 // CHECK-PCH-NEXT: "[[PREFIX]]/module.modulemap"
29 // CHECK-PCH-NEXT: ],
30 // CHECK-PCH-NEXT: "name": "ModCommon"
31 // CHECK-PCH-NEXT: }
32 // CHECK-PCH-NEXT: ],
33 // CHECK-PCH-NEXT: "translation-units": [
34 // CHECK-PCH-NEXT: {
35 // CHECK-PCH: "clang-context-hash": "[[HASH_PCH:.*]]",
36 // CHECK-PCH-NEXT: "clang-module-deps": [
37 // CHECK-PCH-NEXT: {
38 // CHECK-PCH-NEXT: "context-hash": "[[HASH_MOD_COMMON]]",
39 // CHECK-PCH-NEXT: "module-name": "ModCommon"
40 // CHECK-PCH-NEXT: }
41 // CHECK-PCH-NEXT: ],
42 // CHECK-PCH-NEXT: "command-line": [
43 // CHECK-PCH: ],
44 // CHECK-PCH: "file-deps": [
45 // CHECK-PCH-NEXT: "[[PREFIX]]/pch.h"
46 // CHECK-PCH-NEXT: ],
47 // CHECK-PCH-NEXT: "input-file": "[[PREFIX]]/pch.h"
48 // CHECK-PCH-NEXT: }
50 // Explicitly build the PCH:
52 // RUN: %deps-to-rsp %t/result_pch.json --module-name=ModCommon > %t/mod_common.cc1.rsp
53 // RUN: %deps-to-rsp %t/result_pch.json --tu-index=0 > %t/pch.rsp
55 // RUN: %clang @%t/mod_common.cc1.rsp
56 // RUN: %clang @%t/pch.rsp
58 // Scan dependencies of the TU:
60 // RUN: sed "s|DIR|%/t|g" %S/Inputs/modules-pch-common-via-submodule/cdb_tu.json > %t/cdb.json
61 // RUN: clang-scan-deps -compilation-database %t/cdb.json -format experimental-full \
62 // RUN: -module-files-dir %t/build > %t/result_tu.json
63 // RUN: cat %t/result_tu.json | sed 's:\\\\\?:/:g' | FileCheck %s -DPREFIX=%/t -check-prefix=CHECK-TU
65 // CHECK-TU: {
66 // CHECK-TU-NEXT: "modules": [
67 // CHECK-TU-NEXT: {
68 // CHECK-TU-NEXT: "clang-module-deps": [],
69 // CHECK-TU-NEXT: "clang-modulemap-file": "[[PREFIX]]/module.modulemap",
70 // CHECK-TU-NEXT: "command-line": [
71 // CHECK-TU: ],
72 // CHECK-TU-NEXT: "context-hash": "[[HASH_MOD_TU:.*]]",
73 // CHECK-TU-NEXT: "file-deps": [
74 // CHECK-TU-NEXT: "[[PREFIX]]/mod_tu.h",
75 // CHECK-TU-NEXT: "[[PREFIX]]/mod_tu_sub.h",
76 // CHECK-TU-NEXT: "[[PREFIX]]/module.modulemap"
77 // CHECK-TU-NEXT: ],
78 // CHECK-TU-NEXT: "name": "ModTU"
79 // CHECK-TU-NEXT: }
80 // CHECK-TU-NEXT: ],
81 // CHECK-TU-NEXT: "translation-units": [
82 // CHECK-TU-NEXT: {
83 // CHECK-TU: "clang-context-hash": "[[HASH_TU:.*]]",
84 // CHECK-TU-NEXT: "clang-module-deps": [
85 // CHECK-TU-NEXT: {
86 // CHECK-TU-NEXT: "context-hash": "[[HASH_MOD_TU]]"
87 // CHECK-TU-NEXT: "module-name": "ModTU"
88 // CHECK-TU-NEXT: }
89 // CHECK-TU-NEXT: ],
90 // CHECK-TU-NEXT: "command-line": [
91 // CHECK-TU: ],
92 // CHECK-TU: "file-deps": [
93 // CHECK-TU-NEXT: "[[PREFIX]]/tu.c",
94 // CHECK-TU-NEXT: "[[PREFIX]]/pch.h.pch"
95 // CHECK-TU-NEXT: ],
96 // CHECK-TU-NEXT: "input-file": "[[PREFIX]]/tu.c"
97 // CHECK-TU-NEXT: }
99 // Explicitly build the TU:
101 // RUN: %deps-to-rsp %t/result_tu.json --module-name=ModTU > %t/mod_tu.cc1.rsp
102 // RUN: %deps-to-rsp %t/result_tu.json --tu-index=0 > %t/tu.rsp
104 // RUN: %clang @%t/mod_tu.cc1.rsp
105 // RUN: %clang @%t/tu.rsp