1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156
|
// REQUIRES: ondisk_cas
// RUN: rm -rf %t
// RUN: split-file %s %t
// RUN: sed "s|DIR|%/t|g" %t/cdb.json.template > %t/cdb.json
// RUN: sed "s|DIR|%/t|g" %t/cdb_pch.json.template > %t/cdb_pch.json
// Scan PCH
// RUN: clang-scan-deps -compilation-database %t/cdb_pch.json \
// RUN: -cas-path %t/cas -module-files-dir %t/outputs \
// RUN: -format experimental-include-tree-full -mode preprocess-dependency-directives \
// RUN: > %t/deps_pch.json
// Build PCH
// RUN: %deps-to-rsp %t/deps_pch.json --module-name Top > %t/Top.rsp
// RUN: %deps-to-rsp %t/deps_pch.json --module-name Left > %t/Left.rsp
// RUN: %deps-to-rsp %t/deps_pch.json --tu-index 0 > %t/pch.rsp
// RUN: %clang @%t/Top.rsp
// RUN: %clang @%t/Left.rsp
// RUN: rm -rf %t/outputs
// RUN: %clang @%t/pch.rsp
// RUN: rm -rf %t/outputs
// Scan TU with PCH
// RUN: clang-scan-deps -compilation-database %t/cdb.json \
// RUN: -cas-path %t/cas -module-files-dir %t/outputs \
// RUN: -format experimental-include-tree-full -mode preprocess-dependency-directives \
// RUN: > %t/deps.json
// Build TU
// RUN: %deps-to-rsp %t/deps.json --module-name Right > %t/Right.rsp
// RUN: %deps-to-rsp %t/deps.json --tu-index 0 > %t/tu.rsp
// RUN: %clang @%t/Right.rsp
// RUN: rm -rf %t/outputs
// RUN: %clang @%t/tu.rsp
// RUN: FileCheck %s -input-file %t/deps.json -DPREFIX=%/t
// CHECK: {
// CHECK-NEXT: "modules": [
// CHECK-NEXT: {
// CHECK: "clang-module-deps": []
// CHECK: "clang-modulemap-file": "[[PREFIX]]/module.modulemap"
// CHECK: "command-line": [
// CHECK-NEXT: "-cc1"
// CHECK: "-fcas-path"
// CHECK-NEXT: "[[PREFIX]]/cas"
// CHECK: "-o"
// CHECK-NEXT: "[[PREFIX]]/outputs/{{.*}}/Right-{{.*}}.pcm"
// CHECK: "-disable-free"
// CHECK: "-fno-pch-timestamp"
// CHECK: "-fcas-include-tree"
// CHECK-NEXT: "[[RIGHT_TREE:llvmcas://[[:xdigit:]]+]]"
// CHECK: "-fcache-compile-job"
// CHECK: "-emit-module"
// CHECK: "-fmodule-file=[[PREFIX]]/outputs/{{.*}}/Top-{{.*}}.pcm"
// CHECK: "-fmodule-file-cache-key"
// CHECK-NEXT: "[[PREFIX]]/{{.*}}/Top-{{.*}}.pcm"
// CHECK-NEXT: "llvmcas://{{[[:xdigit:]]+}}"
// CHECK: "-x"
// CHECK-NEXT: "c"
// CHECK: "-fmodules"
// CHECK: "-fmodule-name=Right"
// CHECK: "-fno-implicit-modules"
// CHECK: ]
// CHECK: "file-deps": [
// CHECK-NEXT: "[[PREFIX]]/Right.h"
// CHECK-NEXT: "[[PREFIX]]/module.modulemap"
// CHECK-NEXT: ]
// CHECK: "name": "Right"
// CHECK: }
// CHECK-NOT: "clang-modulemap-file"
// CHECK: ]
// CHECK-NEXT: "translation-units": [
// CHECK-NEXT: {
// CHECK-NEXT: "commands": [
// CHECK-NEXT: {
// CHECK: "clang-module-deps": [
// CHECK-NEXT: {
// CHECK: "module-name": "Right"
// CHECK: }
// CHECK-NEXT: ]
// CHECK: "command-line": [
// CHECK-NEXT: "-cc1"
// CHECK: "-fcas-path"
// CHECK-NEXT: "[[PREFIX]]/cas"
// CHECK-NOT: -fmodule-map-file=
// CHECK: "-disable-free"
// CHECK: "-fcas-include-tree"
// CHECK-NEXT: "llvmcas://{{[[:xdigit:]]+}}"
// CHECK: "-fcache-compile-job"
// CHECK: "-fsyntax-only"
// CHECK: "-fmodule-file-cache-key"
// CHECK-NEXT: "[[PREFIX]]/outputs/{{.*}}/Right-{{.*}}.pcm"
// CHECK-NEXT: "llvmcas://{{[[:xdigit:]]+}}"
// CHECK: "-x"
// CHECK-NEXT: "c"
// CHECK: "-fmodule-file=Right=[[PREFIX]]/outputs/{{.*}}/Right-{{.*}}.pcm"
// CHECK: "-fmodules"
// CHECK: "-fno-implicit-modules"
// CHECK: ]
// CHECK: "file-deps": [
// CHECK-NEXT: "[[PREFIX]]/tu.c"
// CHECK-NEXT: "[[PREFIX]]/prefix.h.pch"
// CHECK-NEXT: ]
// CHECK: "input-file": "[[PREFIX]]/tu.c"
// CHECK: }
// CHECK-NEXT: ]
// CHECK-NEXT: }
// CHECK-NEXT: ]
// CHECK-NEXT: }
//--- cdb_pch.json.template
[{
"file": "DIR/prefix.h",
"directory": "DIR",
"command": "clang -x c-header DIR/prefix.h -o DIR/prefix.h.pch -fmodules -fimplicit-modules -fimplicit-module-maps -fmodules-cache-path=DIR/module-cache"
}]
//--- cdb.json.template
[{
"file": "DIR/tu.c",
"directory": "DIR",
"command": "clang -fsyntax-only DIR/tu.c -include DIR/prefix.h -fmodules -fimplicit-modules -fimplicit-module-maps -fmodules-cache-path=DIR/module-cache"
}]
//--- module.modulemap
module Top { header "Top.h" export *}
module Left { header "Left.h" export *}
module Right { header "Right.h" export *}
//--- Top.h
#pragma once
struct Top { int x; };
//--- Left.h
#pragma once
#include "Top.h"
struct Left { struct Top top; };
//--- Right.h
#pragma once
#include "Top.h"
struct Right { struct Top top; };
//--- prefix.h
#include "Left.h"
//--- tu.c
#include "Right.h"
void tu(void) {
struct Left _left;
struct Right _right;
struct Top _top;
}
|