1 // Test scanning when the driver requires multiple jobs. E.g. with -save-temps
2 // there will be separate -E, -emit-llvm-bc, -S, and -cc1as jobs, which should
3 // each result in a "command" in the output.
5 // We use an x86_64-apple-darwin target to avoid host-dependent behaviour in
6 // the driver. Platforms without an integrated assembler have different commands
7 // REQUIRES: x86-registered-target
10 // RUN: split-file %s %t
11 // RUN: sed -e "s|DIR|%/t|g" %t/cdb.json.in > %t/cdb.json
13 // RUN: clang-scan-deps -compilation-database %t/cdb.json -module-files-dir %t/modules \
14 // RUN: -j 1 -format experimental-full -mode preprocess-dependency-directives \
15 // RUN: > %t/deps.json
17 // RUN: cat %t/deps.json | sed 's:\\\\\?:/:g' | FileCheck %s -DPREFIX=%/t
19 // Build the -save-temps + -fmodules case
20 // RUN: %deps-to-rsp %t/deps.json --module-name=Mod > %t/Mod.rsp
21 // RUN: %deps-to-rsp %t/deps.json --tu-index 1 --tu-cmd-index 0 > %t/tu-cpp.rsp
22 // RUN: %deps-to-rsp %t/deps.json --tu-index 1 --tu-cmd-index 1 > %t/tu-emit-ir.rsp
23 // RUN: %deps-to-rsp %t/deps.json --tu-index 1 --tu-cmd-index 2 > %t/tu-emit-asm.rsp
24 // RUN: %deps-to-rsp %t/deps.json --tu-index 1 --tu-cmd-index 3 > %t/tu-cc1as.rsp
25 // RUN: %clang @%t/Mod.rsp
26 // RUN: %clang @%t/tu-cpp.rsp
27 // RUN: ls %t/tu_save_temps_module.i
28 // RUN: %clang @%t/tu-emit-ir.rsp
29 // RUN: ls %t/tu_save_temps_module.bc
30 // RUN: %clang @%t/tu-emit-asm.rsp
31 // RUN: ls %t/tu_save_temps_module.s
32 // RUN: %clang @%t/tu-cc1as.rsp
33 // RUN: ls %t/tu_save_temps_module.o
36 // CHECK: "modules": [
38 // CHECK: "clang-modulemap-file": "[[PREFIX]]{{.}}module.modulemap"
39 // CHECK: "name": "Mod"
42 // CHECK-NEXT: "translation-units": [
44 // CHECK: "commands": [
46 // CHECK-NEXT: "clang-context-hash":
47 // CHECK-NEXT: "clang-module-deps": []
48 // CHECK-NEXT: "command-line": [
51 // CHECK-NEXT: "{{.*}}tu_no_integrated_cpp{{.*}}.i"
54 // CHECK-NEXT: "executable": "clang_tool"
55 // CHECK: "input-file": "[[PREFIX]]{{.}}tu_no_integrated_cpp.c"
58 // CHECK-NEXT: "clang-context-hash":
59 // CHECK-NEXT: "clang-module-deps": []
60 // CHECK-NEXT: "command-line": [
63 // CHECK-NEXT: "{{.*}}tu_no_integrated_cpp.o"
65 // CHECK: "{{.*}}tu_no_integrated_cpp{{.*}}.i"
67 // CHECK-NEXT: "executable": "clang_tool"
68 // CHECK: "input-file": "[[PREFIX]]{{.}}tu_no_integrated_cpp.c"
73 // CHECK-NEXT: "commands": [
75 // CHECK: "clang-module-deps": [
77 // CHECK: "module-name": "Mod"
80 // CHECK-NEXT: "command-line": [
83 // CHECK-NEXT: "{{.*}}tu_save_temps_module.i"
85 // CHECK: "-fmodule-file={{.*}}[[PREFIX]]{{.}}modules{{.*}}Mod-{{.*}}.pcm"
86 // CHECK: "{{.*}}tu_save_temps_module.c"
88 // CHECK-NEXT: "executable": "clang_tool"
89 // CHECK: "input-file": "[[PREFIX]]{{.}}tu_save_temps_module.c"
92 // CHECK: "clang-module-deps": [
94 // CHECK: "module-name": "Mod"
97 // CHECK-NEXT: "command-line": [
100 // CHECK-NEXT: "{{.*}}tu_save_temps_module.bc"
101 // CHECK: "-emit-llvm-bc"
102 // CHECK: "{{.*}}tu_save_temps_module.i"
103 // CHECK: "-fmodule-file={{.*}}[[PREFIX]]{{.}}modules{{.*}}Mod-{{.*}}.pcm"
105 // CHECK-NEXT: "executable": "clang_tool"
106 // CHECK: "input-file": "[[PREFIX]]{{.}}tu_save_temps_module.c"
109 // CHECK: "clang-module-deps": [
111 // CHECK: "module-name": "Mod"
114 // CHECK-NEXT: "command-line": [
115 // CHECK-NEXT: "-cc1"
117 // CHECK-NEXT: "{{.*}}tu_save_temps_module.s"
119 // CHECK: "{{.*}}tu_save_temps_module.bc"
121 // CHECK-NEXT: "executable": "clang_tool"
122 // CHECK: "input-file": "[[PREFIX]]{{.}}tu_save_temps_module.c"
125 // CHECK: "clang-module-deps": [
127 // CHECK: "module-name": "Mod"
130 // CHECK-NEXT: "command-line": [
131 // CHECK-NEXT: "-cc1as"
133 // CHECK-NEXT: "{{.*}}tu_save_temps_module.o"
134 // CHECK: "{{.*}}tu_save_temps_module.s"
136 // CHECK-NEXT: "executable": "clang_tool"
137 // CHECK: "input-file": "[[PREFIX]]{{.}}tu_save_temps_module.c"
148 "command": "clang_tool -target x86_64-apple-darwin -c DIR/tu_no_integrated_cpp.c -no-integrated-cpp -o DIR/tu_no_integrated_cpp.o"
149 "file": "DIR/tu_no_integrated_cpp.c"
153 "command": "clang_tool -target x86_64-apple-darwin -c DIR/tu_save_temps_module.c -save-temps=obj -o DIR/tu_save_temps_module.o -fmodules -fimplicit-modules -fimplicit-module-maps -fmodules-cache-path=DIR/cache"
154 "file": "DIR/tu_save_temps_module.c"
161 //--- module_header.h
164 //--- module.modulemap
165 module Mod
{ header
"module_header.h" }
167 //--- tu_no_integrated_cpp.c
168 #include "plain_header.h"
169 void tu_no_integrated_cpp(void) { foo(); }
171 //--- tu_save_temps_module.c
172 #include "module_header.h"
173 void tu_save_temps(void) { bar(); }