|
| 1 | +// Test path prefix-mapping when using a cas-fs with clang-scan-deps in |
| 2 | +// tree, full-tree, and full dependencies modes. |
| 3 | + |
| 4 | +// RUN: rm -rf %t |
| 5 | +// RUN: split-file %s %t |
| 6 | +// RUN: sed -e "s|DIR|%t|g" -e "s|CLANG|%clang|g" -e "s|SDK|%S/Inputs/SDK|g" %t/cdb.json.template > %t/cdb.json |
| 7 | + |
| 8 | +// == Tree |
| 9 | +// Ensure the filesystem has the mapped paths. |
| 10 | + |
| 11 | +// RUN: clang-scan-deps -compilation-database %t/cdb.json -format experimental-tree -cas-path %t/cas \ |
| 12 | +// RUN: -prefix-map=%t=/^src -prefix-map-sdk=/^sdk -prefix-map-toolchain=/^tc \ |
| 13 | +// RUN: | sed -E 's/tree ([^ ]+) for.*/\1/' > %t/tree_id.txt |
| 14 | +// RUN: llvm-cas -cas %t/cas -ls-tree-recursive @%t/tree_id.txt > %t/tree_result.txt |
| 15 | +// RUN: FileCheck %s -input-file %t/tree_result.txt -check-prefix=FILES |
| 16 | + |
| 17 | +// FILES: file llvmcas://{{.*}} /^sdk/usr/include/stdlib.h |
| 18 | +// FILES: file llvmcas://{{.*}} /^src/t.c |
| 19 | +// FILES: file llvmcas://{{.*}} /^src/top.h |
| 20 | +// FILES: file llvmcas://{{.*}} /^tc/lib/clang/{{.*}}/include/stdarg.h |
| 21 | + |
| 22 | +// == Full Tree |
| 23 | +// This should have the same filesystem as above, and we also check the command- |
| 24 | +// line. |
| 25 | + |
| 26 | +// RUN: cat %t/tree_id.txt > %t/full_tree_result.txt |
| 27 | +// RUN: clang-scan-deps -compilation-database %t/cdb.json -format experimental-tree-full -cas-path %t/cas \ |
| 28 | +// RUN: -prefix-map=%t=/^src -prefix-map-sdk=/^sdk -prefix-map-toolchain=/^tc \ |
| 29 | +// RUN: >> %t/full_tree_result.txt |
| 30 | +// RUN: FileCheck %s -input-file %t/full_tree_result.txt -DPREFIX=%t -DSDK_PREFIX=%S/Inputs/SDK |
| 31 | + |
| 32 | +// == Full |
| 33 | +// Same as full tree. |
| 34 | + |
| 35 | +// RUN: cat %t/tree_id.txt > %t/full_result.txt |
| 36 | +// RUN: clang-scan-deps -compilation-database %t/cdb.json -format experimental-full -cas-path %t/cas \ |
| 37 | +// RUN: -prefix-map=%t=/^src -prefix-map-sdk=/^sdk -prefix-map-toolchain=/^tc \ |
| 38 | +// RUN: >> %t/full_result.txt |
| 39 | +// RUN: FileCheck %s -input-file %t/full_result.txt -DPREFIX=%t -DSDK_PREFIX=%S/Inputs/SDK |
| 40 | + |
| 41 | +// CHECK: [[MAPPED_FS_ID:llvmcas://[[:xdigit:]]+]] |
| 42 | +// CHECK: "modules": [] |
| 43 | +// CHECK: "translation-units": [ |
| 44 | +// CHECK: { |
| 45 | +// CHECK: "commands": [ |
| 46 | +// CHECK: { |
| 47 | +// CHECK: "casfs-root-id": "[[MAPPED_FS_ID]]" |
| 48 | +// CHECK: "clang-module-deps": [] |
| 49 | +// CHECK: "command-line": [ |
| 50 | +// CHECK: "-fcas-path" |
| 51 | +// CHECK-NEXT: "[[PREFIX]]/cas" |
| 52 | +// CHECK: "-fcas-fs" |
| 53 | +// CHECK-NEXT: "[[MAPPED_FS_ID]]" |
| 54 | +// CHECK: "-fcas-fs-working-directory" |
| 55 | +// CHECK-NEXT: "/^src" |
| 56 | +// CHECK: "-x" |
| 57 | +// CHECK-NEXT: "c" |
| 58 | +// CHECK-NEXT: "/^src/t.c" |
| 59 | +// CHECK: "-isysroot" |
| 60 | +// CHECK-NEXT: "/^sdk" |
| 61 | +// CHECK: "-resource-dir" |
| 62 | +// CHECK-NEXT: "/^tc/lib/clang/{{.*}}" |
| 63 | +// CHECK: "-isystem" |
| 64 | +// CHECK-NEXT: "/^sdk/usr/local/include |
| 65 | +// CHECK: "-isystem" |
| 66 | +// CHECK-NEXT: "/^tc/lib/clang/{{.*}}/include" |
| 67 | +// CHECK: "-internal-externc-isystem" |
| 68 | +// CHECK-NEXT: "/^sdk/usr/include" |
| 69 | +// CHECK: "-fdebug-compilation-dir=/^src" |
| 70 | +// CHECK: "-fcoverage-compilation-dir=/^src" |
| 71 | +// CHECK-NOT: [[PREFIX]] |
| 72 | +// CHECK-NOT: [[SDK_PREFIX]] |
| 73 | +// CHECK: ] |
| 74 | +// CHECK: "file-deps": [ |
| 75 | +// CHECK: "[[PREFIX]]/t.c" |
| 76 | +// CHECK: "[[PREFIX]]/top.h" |
| 77 | +// CHECK: "{{.*}}include/stdarg.h" |
| 78 | +// CHECK: "[[SDK_PREFIX]]/usr/include/stdlib.h" |
| 79 | +// CHECK: ] |
| 80 | +// CHECK: "input-file": "[[PREFIX]]/t.c" |
| 81 | + |
| 82 | +//--- cdb.json.template |
| 83 | +[ |
| 84 | + { |
| 85 | + "directory": "DIR", |
| 86 | + "command": "CLANG -fsyntax-only DIR/t.c -target x86_64-apple-macos11 -isysroot SDK", |
| 87 | + "file": "DIR/t.c" |
| 88 | + } |
| 89 | +] |
| 90 | + |
| 91 | +//--- t.c |
| 92 | +#include "top.h" |
| 93 | + |
| 94 | +//--- top.h |
| 95 | +#include <stdarg.h> |
| 96 | +#include <stdlib.h> |
0 commit comments