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