[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / ClangScanDeps / modules-pch-common-via-submodule.c
bloba12492c0bec7078e9ca16772b29104d2b69838d0
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]]/module.modulemap",
28 // CHECK-PCH-NEXT: "[[PREFIX]]/mod_common.h"
29 // CHECK-PCH-NEXT: ],
30 // CHECK-PCH-NEXT: "link-libraries": [],
31 // CHECK-PCH-NEXT: "name": "ModCommon"
32 // CHECK-PCH-NEXT: }
33 // CHECK-PCH-NEXT: ],
34 // CHECK-PCH-NEXT: "translation-units": [
35 // CHECK-PCH-NEXT: {
36 // CHECK-PCH: "clang-context-hash": "[[HASH_PCH:.*]]",
37 // CHECK-PCH-NEXT: "clang-module-deps": [
38 // CHECK-PCH-NEXT: {
39 // CHECK-PCH-NEXT: "context-hash": "[[HASH_MOD_COMMON]]",
40 // CHECK-PCH-NEXT: "module-name": "ModCommon"
41 // CHECK-PCH-NEXT: }
42 // CHECK-PCH-NEXT: ],
43 // CHECK-PCH-NEXT: "command-line": [
44 // CHECK-PCH: ],
45 // CHECK-PCH: "file-deps": [
46 // CHECK-PCH-NEXT: "[[PREFIX]]/pch.h"
47 // CHECK-PCH-NEXT: ],
48 // CHECK-PCH-NEXT: "input-file": "[[PREFIX]]/pch.h"
49 // CHECK-PCH-NEXT: }
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
66 // CHECK-TU: {
67 // CHECK-TU-NEXT: "modules": [
68 // CHECK-TU-NEXT: {
69 // CHECK-TU-NEXT: "clang-module-deps": [],
70 // CHECK-TU-NEXT: "clang-modulemap-file": "[[PREFIX]]/module.modulemap",
71 // CHECK-TU-NEXT: "command-line": [
72 // CHECK-TU: ],
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"
78 // CHECK-TU-NEXT: ],
79 // CHECK-TU-NEXT: "link-libraries": [],
80 // CHECK-TU-NEXT: "name": "ModTU"
81 // CHECK-TU-NEXT: }
82 // CHECK-TU-NEXT: ],
83 // CHECK-TU-NEXT: "translation-units": [
84 // CHECK-TU-NEXT: {
85 // CHECK-TU: "clang-context-hash": "[[HASH_TU:.*]]",
86 // CHECK-TU-NEXT: "clang-module-deps": [
87 // CHECK-TU-NEXT: {
88 // CHECK-TU-NEXT: "context-hash": "[[HASH_MOD_TU]]"
89 // CHECK-TU-NEXT: "module-name": "ModTU"
90 // CHECK-TU-NEXT: }
91 // CHECK-TU-NEXT: ],
92 // CHECK-TU-NEXT: "command-line": [
93 // CHECK-TU: ],
94 // CHECK-TU: "file-deps": [
95 // CHECK-TU-NEXT: "[[PREFIX]]/tu.c",
96 // CHECK-TU-NEXT: "[[PREFIX]]/pch.h.pch"
97 // CHECK-TU-NEXT: ],
98 // CHECK-TU-NEXT: "input-file": "[[PREFIX]]/tu.c"
99 // CHECK-TU-NEXT: }
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