|
6 | 6 | // RUN: split-file %s %t |
7 | 7 | // RUN: sed -e "s|DIR|%/t|g" %t/cdb0.json.in > %t/cdb0.json |
8 | 8 | // RUN: sed -e "s|DIR|%/t|g" %t/cdb1.json.in > %t/cdb1.json |
9 | | -// RUN: sed -e "s|DIR|%/t|g" %t/cdb2.json.in > %t/cdb2.json |
| 9 | +// RUN: sed -e "s|DIR|%/t|g" %t/cdb3.json.in > %t/cdb3.json |
| 10 | +// RUN: sed -e "s|DIR|%/t|g" %t/cdb4.json.in > %t/cdb4.json |
10 | 11 | // RUN: clang-scan-deps -compilation-database %t/cdb0.json -format experimental-full > %t/result0.json |
11 | 12 | // RUN: clang-scan-deps -compilation-database %t/cdb1.json -format experimental-full > %t/result1.json |
12 | | -// RUN: clang-scan-deps -compilation-database %t/cdb2.json -format experimental-full -optimize-args=header-search,system-warnings,vfs,canonicalize-macros > %t/result2.json |
| 13 | +// It is not a typo to use cdb1.json for result2. We intend to use the same |
| 14 | +// compilation database, but different clang-scan-deps optimize-args options. |
| 15 | +// RUN: clang-scan-deps -compilation-database %t/cdb1.json -format experimental-full -optimize-args=header-search,system-warnings,vfs,canonicalize-macros > %t/result2.json |
| 16 | +// RUN: clang-scan-deps -compilation-database %t/cdb3.json -format experimental-full > %t/result3.json |
| 17 | +// RUN: clang-scan-deps -compilation-database %t/cdb4.json -format experimental-full > %t/result4.json |
13 | 18 | // RUN: cat %t/result0.json %t/result1.json | FileCheck %s |
14 | 19 | // RUN: cat %t/result0.json %t/result2.json | FileCheck %s -check-prefix=SKIPOPT |
| 20 | +// RUN: cat %t/result3.json %t/result4.json | FileCheck %s -check-prefix=RELPATH |
15 | 21 |
|
16 | 22 | //--- cdb0.json.in |
17 | 23 | [{ |
|
27 | 33 | "file": "DIR/tu.c" |
28 | 34 | }] |
29 | 35 |
|
30 | | -//--- cdb2.json.in |
| 36 | +// cdb2 is skipped because we reuse cdb1. |
| 37 | + |
| 38 | +//--- cdb3.json.in |
31 | 39 | [{ |
32 | | - "directory": "DIR/a/", |
33 | | - "command": "clang -c DIR/tu.c -fmodules -fmodules-cache-path=DIR/cache -IDIR/include/ -o DIR/tu.o", |
| 40 | + "directory": "DIR", |
| 41 | + "command": "clang -c DIR/tu.c -fmodules -fmodules-cache-path=DIR/cache -fprebuilt-module-path=.././module -IDIR/include/ -o DIR/tu.o ", |
34 | 42 | "file": "DIR/tu.c" |
35 | 43 | }] |
36 | 44 |
|
| 45 | +//--- cdb4.json.in |
| 46 | +[{ |
| 47 | + "directory": "DIR/a/", |
| 48 | + "command": "clang -c DIR/tu.c -fmodules -fmodules-cache-path=DIR/cache -fprebuilt-module-path=.././module -IDIR/include/ -o DIR/tu.o ", |
| 49 | + "file": "DIR/tu.c" |
| 50 | +}] |
37 | 51 | //--- include/module.modulemap |
38 | 52 | module mod { |
39 | 53 | header "mod.h" |
@@ -121,3 +135,43 @@ module mod { |
121 | 135 | // SKIPOPT: } |
122 | 136 | // SKIPOPT: ], |
123 | 137 |
|
| 138 | +// Check that result3 and result4 contain different hashes because |
| 139 | +// both have a same relative path as a command line input, and |
| 140 | +// they are produced using different compiler working directories. |
| 141 | +// RELPATH: { |
| 142 | +// RELPATH-NEXT: "modules": [ |
| 143 | +// RELPATH-NEXT: { |
| 144 | +// RELPATH-NEXT: "clang-module-deps": [], |
| 145 | +// RELPATH: "context-hash": "[[HASH3:.*]]", |
| 146 | +// RELPATH: } |
| 147 | +// RELPATH: "translation-units": [ |
| 148 | +// RELPATH: { |
| 149 | +// RELPATH: "commands": [ |
| 150 | +// RELPATH: { |
| 151 | +// RELPATH-NEXT: "clang-context-hash": "{{.*}}", |
| 152 | +// RELPATH-NEXT: "clang-module-deps": [ |
| 153 | +// RELPATH-NEXT: { |
| 154 | +// RELPATH-NEXT: "context-hash": "[[HASH3]]", |
| 155 | +// RELPATH-NEXT: "module-name": "mod" |
| 156 | +// RELPATH: } |
| 157 | +// RELPATH: ], |
| 158 | +// RELPATH: { |
| 159 | +// RELPATH-NEXT: "modules": [ |
| 160 | +// RELPATH-NEXT: { |
| 161 | +// RELPATH-NEXT: "clang-module-deps": [], |
| 162 | +// RELPATH-NOT: "context-hash": "[[HASH3]]", |
| 163 | +// RELPATH: "context-hash": "[[HASH4:.*]]", |
| 164 | +// RELPATH: } |
| 165 | +// RELPATH: "translation-units": [ |
| 166 | +// RELPATH: { |
| 167 | +// RELPATH: "commands": [ |
| 168 | +// RELPATH: { |
| 169 | +// RELPATH-NEXT: "clang-context-hash": "{{.*}}", |
| 170 | +// RELPATH-NEXT: "clang-module-deps": [ |
| 171 | +// RELPATH-NEXT: { |
| 172 | +// RELPATH-NOT: "context-hash": "[[HASH3]]", |
| 173 | +// RELPATH-NEXT: "context-hash": "[[HASH4]]" |
| 174 | +// RELPATH-NEXT: "module-name": "mod" |
| 175 | +// RELPATH: } |
| 176 | +// RELPATH: ], |
| 177 | + |
0 commit comments