|
| 1 | +// REQUIRES: ondisk_cas |
| 2 | + |
| 3 | +// RUN: rm -rf %t |
| 4 | +// RUN: split-file %s %t |
| 5 | +// RUN: sed "s|DIR|%/t|g" %t/cdb.json.template > %t/cdb.json |
| 6 | + |
| 7 | +// RUN: clang-scan-deps -compilation-database %t/cdb.json \ |
| 8 | +// RUN: -cas-path %t/cas -module-files-dir %t/outputs \ |
| 9 | +// RUN: -format experimental-include-tree-full -mode preprocess-dependency-directives \ |
| 10 | +// RUN: > %t/deps.json |
| 11 | + |
| 12 | +// RUN: FileCheck %s -input-file %t/deps.json -check-prefix=NO_MODULES |
| 13 | +// NO_MODULES: "modules": [] |
| 14 | + |
| 15 | +// RUN: %deps-to-rsp %t/deps.json --tu-index 0 > %t/tu.rsp |
| 16 | +// RUN: cat %t/tu.rsp | sed -E 's|.*"-fcas-include-tree" "(llvmcas://[[:xdigit:]]+)".*|\1|' > %t/tu.casid |
| 17 | +// RUN: clang-cas-test -cas %t/cas -print-include-tree @%t/tu.casid | FileCheck %s -DPREFIX=%/t |
| 18 | +// RUN: %clang @%t/tu.rsp |
| 19 | + |
| 20 | +// CHECK: [[PREFIX]]/tu.c llvmcas://{{[[:xdigit:]]+}} |
| 21 | +// CHECK: 1:1 <built-in> llvmcas://{{[[:xdigit:]]+}} |
| 22 | + |
| 23 | +// Note: this is surprising, but correct: when building the implementation files |
| 24 | +// of a module, the first include is textual but still uses the submodule |
| 25 | +// machinery. The second include is treated as a module import (unless in a PCH) |
| 26 | +// but will not actually import the module only trigger visibility changes. |
| 27 | + |
| 28 | +// CHECK: 2:1 [[PREFIX]]/Mod.h llvmcas://{{[[:xdigit:]]+}} |
| 29 | +// CHECK: Submodule: Mod |
| 30 | +// CHECK: 3:1 (Module) Mod |
| 31 | + |
| 32 | +// CHECK: Files: |
| 33 | +// CHECK: [[PREFIX]]/tu.c llvmcas://{{[[:xdigit:]]+}} |
| 34 | +// CHECK: [[PREFIX]]/Mod.h llvmcas://{{[[:xdigit:]]+}} |
| 35 | + |
| 36 | +// Despite not importing the module, we need its modulemap for submodule info. |
| 37 | +// CHECK: [[PREFIX]]/module.modulemap llvmcas://{{[[:xdigit:]]+}} |
| 38 | + |
| 39 | +//--- cdb.json.template |
| 40 | +[{ |
| 41 | + "file": "DIR/tu.c", |
| 42 | + "directory": "DIR", |
| 43 | + "command": "clang -fsyntax-only DIR/tu.c -I DIR -fmodule-name=Mod -fmodules -fimplicit-modules -fimplicit-module-maps -fmodules-cache-path=DIR/module-cache" |
| 44 | +}] |
| 45 | + |
| 46 | +//--- module.modulemap |
| 47 | +module Mod { header "Mod.h" } |
| 48 | + |
| 49 | +//--- Mod.h |
| 50 | +#pragma once |
| 51 | +void top(void); |
| 52 | + |
| 53 | +//--- tu.c |
| 54 | +#include "Mod.h" |
| 55 | +#include "Mod.h" |
| 56 | +void tu(void) { |
| 57 | + top(); |
| 58 | +} |
0 commit comments