Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / ClangScanDeps / modules-extern-unrelated.m
blob442ee90aa1836d48dcd112cd5a1c4f59103e538d
1 // RUN: rm -rf %t
2 // RUN: split-file %s %t
4 //--- tu.m
5 @import zeroth;
7 //--- zeroth/module.modulemap
8 module zeroth { header "zeroth.h" }
9 //--- zeroth/zeroth.h
10 @import first;
11 #include "second.h"
13 //--- first/module.modulemap
14 module first {}
15 module first_other { header "first_other.h" }
16 //--- first/first_other.h
18 //--- second/module.modulemap
19 extern module second "second.modulemap"
20 //--- second/second.modulemap
21 module second { header "second.h" }
22 //--- second/second.h
23 #include "first_other.h"
25 //--- cdb.json.template
27   "directory": "DIR",
28   "file": "DIR/tu.m",
29   "command": "clang -fmodules -fmodules-cache-path=DIR/cache -I DIR/zeroth -I DIR/first -I DIR/second -c DIR/tu.m -o DIR/tu.o"
32 // RUN: sed -e "s|DIR|%/t|g" -e "s|INPUTS|%/S/Inputs|g" %t/cdb.json.template > %t/cdb.json
33 // RUN: clang-scan-deps -compilation-database %t/cdb.json -format experimental-full > %t/result.json
34 // RUN: cat %t/result.json | sed 's:\\\\\?:/:g' | FileCheck %s -DPREFIX=%/t
36 // CHECK:      {
37 // CHECK-NEXT:   "modules": [
38 // CHECK-NEXT:     {
39 // CHECK-NEXT:       "clang-module-deps": [],
40 // CHECK-NEXT:       "clang-modulemap-file": "[[PREFIX]]/first/module.modulemap",
41 // CHECK-NEXT:       "command-line": [
42 // CHECK:            ],
43 // CHECK-NEXT:       "context-hash": "{{.*}}",
44 // CHECK-NEXT:       "file-deps": [
45 // CHECK-NEXT:         "[[PREFIX]]/first/module.modulemap"
46 // CHECK-NEXT:       ],
47 // CHECK-NEXT:       "name": "first"
48 // CHECK-NEXT:     },
49 // CHECK-NEXT:     {
50 // CHECK-NEXT:       "clang-module-deps": [],
51 // CHECK-NEXT:       "clang-modulemap-file": "[[PREFIX]]/first/module.modulemap",
52 // CHECK-NEXT:       "command-line": [
53 // CHECK:            ],
54 // CHECK-NEXT:       "context-hash": "{{.*}}",
55 // CHECK-NEXT:       "file-deps": [
56 // CHECK-NEXT:         "[[PREFIX]]/first/first_other.h",
57 // CHECK-NEXT:         "[[PREFIX]]/first/module.modulemap"
58 // CHECK-NEXT:       ],
59 // CHECK-NEXT:       "name": "first_other"
60 // CHECK-NEXT:     },
61 // CHECK-NEXT:     {
62 // CHECK-NEXT:       "clang-module-deps": [
63 // CHECK-NEXT:         {
64 // CHECK-NEXT:           "context-hash": "{{.*}}",
65 // CHECK-NEXT:           "module-name": "first_other"
66 // CHECK-NEXT:         }
67 // CHECK-NEXT:       ],
68 // CHECK-NEXT:       "clang-modulemap-file": "[[PREFIX]]/second/second.modulemap",
69 // CHECK-NEXT:       "command-line": [
70 // CHECK:            ],
71 // CHECK-NEXT:       "context-hash": "{{.*}}",
72 // CHECK-NEXT:       "file-deps": [
73 // CHECK-NEXT:         "[[PREFIX]]/first/module.modulemap",
74 // CHECK-NEXT:         "[[PREFIX]]/second/second.h",
75 // CHECK-NEXT:         "[[PREFIX]]/second/second.modulemap"
76 // CHECK-NEXT:       ],
77 // CHECK-NEXT:       "name": "second"
78 // CHECK-NEXT:     },
79 // CHECK-NEXT:     {
80 // CHECK-NEXT:       "clang-module-deps": [
81 // CHECK-NEXT:         {
82 // CHECK-NEXT:           "context-hash": "{{.*}}",
83 // CHECK-NEXT:           "module-name": "first"
84 // CHECK-NEXT:         },
85 // CHECK-NEXT:         {
86 // CHECK-NEXT:           "context-hash": "{{.*}}",
87 // CHECK-NEXT:           "module-name": "second"
88 // CHECK-NEXT:         }
89 // CHECK-NEXT:       ],
90 // CHECK-NEXT:       "clang-modulemap-file": "[[PREFIX]]/zeroth/module.modulemap",
91 // CHECK-NEXT:       "command-line": [
92 // CHECK:            ],
93 // CHECK-NEXT:       "context-hash": "{{.*}}",
94 // CHECK-NEXT:       "file-deps": [
95 // CHECK-NEXT:         "[[PREFIX]]/first/module.modulemap",
96 // CHECK-NEXT:         "[[PREFIX]]/second/module.modulemap",
97 // CHECK-NEXT:         "[[PREFIX]]/second/second.modulemap",
98 // CHECK-NEXT:         "[[PREFIX]]/zeroth/module.modulemap",
99 // CHECK-NEXT:         "[[PREFIX]]/zeroth/zeroth.h"
100 // CHECK-NEXT:       ],
101 // CHECK-NEXT:       "name": "zeroth"
102 // CHECK-NEXT:     }
103 // CHECK-NEXT:   ],
104 // CHECK-NEXT:   "translation-units": [
105 // CHECK-NEXT:     {
106 // CHECK-NEXT:       "commands": [
107 // CHECK-NEXT:         {
108 // CHECK-NEXT:           "clang-context-hash": "{{.*}}",
109 // CHECK-NEXT:           "clang-module-deps": [
110 // CHECK-NEXT:             {
111 // CHECK-NEXT:               "context-hash": "{{.*}}",
112 // CHECK-NEXT:               "module-name": "zeroth"
113 // CHECK-NEXT:             }
114 // CHECK-NEXT:           ],
115 // CHECK-NEXT:           "command-line": [
116 // CHECK:                ],
117 // CHECK-NEXT:           "executable": "clang",
118 // CHECK-NEXT:           "file-deps": [
119 // CHECK-NEXT:             "[[PREFIX]]/tu.m"
120 // CHECK-NEXT:           ],
121 // CHECK-NEXT:           "input-file": "[[PREFIX]]/tu.m"
122 // CHECK-NEXT:         }
123 // CHECK:            ]
124 // CHECK:          }
125 // CHECK:        ]
126 // CHECK:      }
128 // RUN: %deps-to-rsp --module-name=first %t/result.json > %t/first.cc1.rsp
129 // RUN: %deps-to-rsp --module-name=first_other %t/result.json > %t/first_other.cc1.rsp
130 // RUN: %deps-to-rsp --module-name=second %t/result.json > %t/second.cc1.rsp
131 // RUN: %deps-to-rsp --module-name=zeroth %t/result.json > %t/zeroth.cc1.rsp
132 // RUN: %clang @%t/first.cc1.rsp
133 // RUN: %clang @%t/first_other.cc1.rsp
134 // RUN: %clang @%t/second.cc1.rsp
135 // RUN: %clang @%t/zeroth.cc1.rsp