[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / ClangScanDeps / modules-dep-args.c
blob19f915923b84cf0968f3f52b8d1a1167f9e76663
1 // This test exercises the different ways explicit modular dependencies are
2 // provided on the command-line.
4 // RUN: rm -rf %t
5 // RUN: split-file %s %t
7 //--- cdb.json.template
8 [{
9 "file": "DIR/tu.c",
10 "directory": "DIR",
11 "command": "clang DIR/tu.c -fmodules -fmodules-cache-path=DIR/cache -o DIR/tu.o"
14 //--- module.modulemap
15 module Transitive { header "transitive.h" }
16 module Direct { header "direct.h" }
17 //--- transitive.h
18 //--- direct.h
19 #include "transitive.h"
20 //--- tu.c
21 #include "direct.h"
23 // RUN: sed -e "s|DIR|%/t|g" %t/cdb.json.template > %t/cdb.json
25 // Check that the PCM path defaults to the modules cache from implicit build.
26 // RUN: clang-scan-deps -compilation-database %t/cdb.json -format experimental-full > %t/result_cache.json
27 // RUN: cat %t/result_cache.json | sed 's:\\\\\?:/:g' | FileCheck %s -DPREFIX=%/t --check-prefixes=CHECK,CHECK_CACHE
29 // Check that the PCM path can be customized.
30 // RUN: clang-scan-deps -compilation-database %t/cdb.json -format experimental-full -module-files-dir %t/build > %t/result_build.json
31 // RUN: cat %t/result_build.json | sed 's:\\\\\?:/:g' | FileCheck %s -DPREFIX=%/t --check-prefixes=CHECK,CHECK_BUILD
33 // Check that the PCM file is loaded lazily by default.
34 // RUN: clang-scan-deps -compilation-database %t/cdb.json -format experimental-full > %t/result_lazy.json
35 // RUN: cat %t/result_lazy.json | sed 's:\\\\\?:/:g' | FileCheck %s -DPREFIX=%/t --check-prefixes=CHECK,CHECK_LAZY
37 // Check that the PCM file can be loaded eagerly.
38 // RUN: clang-scan-deps -compilation-database %t/cdb.json -format experimental-full -eager-load-pcm > %t/result_eager.json
39 // RUN: cat %t/result_eager.json | sed 's:\\\\\?:/:g' | FileCheck %s -DPREFIX=%/t --check-prefixes=CHECK,CHECK_EAGER
41 // CHECK: {
42 // CHECK-NEXT: "modules": [
43 // CHECK-NEXT: {
44 // CHECK-NEXT: "clang-module-deps": [
45 // CHECK-NEXT: {
46 // CHECK-NEXT: "context-hash": "{{.*}}",
47 // CHECK-NEXT: "module-name": "Transitive"
48 // CHECK-NEXT: }
49 // CHECK-NEXT: ],
50 // CHECK-NEXT: "clang-modulemap-file": "[[PREFIX]]/module.modulemap",
51 // CHECK-NEXT: "command-line": [
52 // CHECK_CACHE: "-fmodule-file={{.*}}/cache/{{.*}}/Transitive-{{.*}}.pcm"
53 // CHECK_BUILD: "-fmodule-file={{.*}}/build/{{.*}}/Transitive-{{.*}}.pcm"
54 // CHECK_LAZY: "-fmodule-map-file=[[PREFIX]]/module.modulemap"
55 // CHECK_LAZY: "-fmodule-file=Transitive=[[PREFIX]]/{{.*}}/Transitive-{{.*}}.pcm"
56 // CHECK_EAGER-NOT: "-fmodule-map-file={{.*}}"
57 // CHECK_EAGER: "-fmodule-file=[[PREFIX]]/{{.*}}/Transitive-{{.*}}.pcm"
58 // CHECK: ],
59 // CHECK-NEXT: "context-hash": "{{.*}}",
60 // CHECK-NEXT: "file-deps": [
61 // CHECK-NEXT: "[[PREFIX]]/module.modulemap",
62 // CHECK-NEXT: "[[PREFIX]]/direct.h"
63 // CHECK-NEXT: ],
64 // CHECK-NEXT: "link-libraries": [],
65 // CHECK-NEXT: "name": "Direct"
66 // CHECK-NEXT: },
67 // CHECK-NEXT: {
68 // CHECK-NEXT: "clang-module-deps": [],
69 // CHECK-NEXT: "clang-modulemap-file": "[[PREFIX]]/module.modulemap",
70 // CHECK-NEXT: "command-line": [
71 // CHECK: ],
72 // CHECK-NEXT: "context-hash": "{{.*}}",
73 // CHECK-NEXT: "file-deps": [
74 // CHECK-NEXT: "[[PREFIX]]/module.modulemap",
75 // CHECK-NEXT: "[[PREFIX]]/transitive.h"
76 // CHECK-NEXT: ],
77 // CHECK-NEXT: "link-libraries": [],
78 // CHECK-NEXT: "name": "Transitive"
79 // CHECK-NEXT: }
80 // CHECK-NEXT: ],
81 // CHECK-NEXT: "translation-units": [
82 // CHECK-NEXT: {
83 // CHECK: "clang-context-hash": "{{.*}}",
84 // CHECK-NEXT: "clang-module-deps": [
85 // CHECK-NEXT: {
86 // CHECK-NEXT: "context-hash": "{{.*}}",
87 // CHECK-NEXT: "module-name": "Direct"
88 // CHECK-NEXT: }
89 // CHECK-NEXT: ],
90 // CHECK-NEXT: "command-line": [
91 // CHECK_CACHE: "-fmodule-file={{.*}}/cache/{{.*}}/Direct-{{.*}}.pcm"
92 // CHECK_BUILD: "-fmodule-file={{.*}}/build/{{.*}}/Direct-{{.*}}.pcm"
93 // CHECK_LAZY: "-fmodule-map-file=[[PREFIX]]/module.modulemap"
94 // CHECK_LAZY: "-fmodule-file=Direct=[[PREFIX]]/{{.*}}/Direct-{{.*}}.pcm"
95 // CHECK_EAGER-NOT: "-fmodule-map-file={{.*}}"
96 // CHECK_EAGER: "-fmodule-file=[[PREFIX]]/{{.*}}/Direct-{{.*}}.pcm"
97 // CHECK: ],
98 // CHECK: "file-deps": [
99 // CHECK-NEXT: "[[PREFIX]]/tu.c"
100 // CHECK-NEXT: ],
101 // CHECK-NEXT: "input-file": "[[PREFIX]]/tu.c"
102 // CHECK-NEXT: }