With inferred modules, the dependency scanner takes care to replace the fake "__inferred_module.map" path with the file that allowed the module to be inferred. However, this only worked when such a module was imported directly in the TU. Whenever such module got loaded transitively, the scanner would fail to perform the replacement. This is caused by the fact that PCM files are lossy and drop this information. This patch makes sure that PCMs include this file for each submodule (in the `SUBMODULE_DEFINITION` record), fixes one existing test with an incorrect assertion, and does a little drive-by refactoring of `ModuleMap`.
121 lines
4.2 KiB
C
121 lines
4.2 KiB
C
// RUN: rm -rf %t
|
|
// RUN: mkdir %t
|
|
// RUN: mkdir %t/Inputs
|
|
// RUN: cp -R %S/Inputs/frameworks %t/Inputs/frameworks
|
|
// RUN: split-file %s %t
|
|
|
|
//--- module.modulemap
|
|
module root { header "root.h" }
|
|
module direct { header "direct.h" }
|
|
module transitive {
|
|
header "transitive.h"
|
|
link framework "libTransitive"
|
|
}
|
|
//--- root.h
|
|
#include "direct.h"
|
|
#include "root/textual.h"
|
|
#include "Framework/Framework.h"
|
|
//--- direct.h
|
|
#include "transitive.h"
|
|
//--- transitive.h
|
|
// empty
|
|
|
|
//--- root/textual.h
|
|
// This is here to verify that the "root" directory doesn't clash with name of
|
|
// the "root" module.
|
|
|
|
//--- cdb.json.template
|
|
[{
|
|
"file": "",
|
|
"directory": "DIR",
|
|
"command": "clang -fmodules -fmodules-cache-path=DIR/cache -FDIR/Inputs/frameworks -I DIR -x c"
|
|
}]
|
|
|
|
// RUN: sed "s|DIR|%/t|g" %t/cdb.json.template > %t/cdb.json
|
|
// RUN: clang-scan-deps -compilation-database %t/cdb.json -format experimental-full -module-name=root > %t/result.json
|
|
// RUN: cat %t/result.json | sed 's:\\\\\?:/:g' | FileCheck -DPREFIX=%/t %s
|
|
|
|
// CHECK: {
|
|
// CHECK-NEXT: "modules": [
|
|
// CHECK-NEXT: {
|
|
// CHECK-NEXT: "clang-module-deps": [],
|
|
// CHECK-NEXT: "clang-modulemap-file": "[[PREFIX]]/Inputs/frameworks/module.modulemap",
|
|
// CHECK-NEXT: "command-line": [
|
|
// CHECK: ],
|
|
// CHECK-NEXT: "context-hash": "{{.*}}",
|
|
// CHECK-NEXT: "file-deps": [
|
|
// CHECK-NEXT: "[[PREFIX]]/Inputs/frameworks/Framework.framework/Headers/Framework.h"
|
|
// CHECK-NEXT: "[[PREFIX]]/Inputs/frameworks/module.modulemap"
|
|
// CHECK-NEXT: ],
|
|
// CHECK-NEXT: "link-libraries": [
|
|
// CHECK-NEXT: {
|
|
// CHECK-NEXT: "isFramework": true,
|
|
// CHECK-NEXT: "link-name": "Framework"
|
|
// CHECK-NEXT: }
|
|
// CHECK-NEXT: ],
|
|
// CHECK-NEXT: "name": "Framework"
|
|
// CHECK-NEXT: },
|
|
// CHECK-NEXT: {
|
|
// CHECK-NEXT: "clang-module-deps": [
|
|
// CHECK-NEXT: {
|
|
// CHECK-NEXT: "context-hash": "{{.*}}",
|
|
// CHECK-NEXT: "module-name": "transitive"
|
|
// CHECK-NEXT: }
|
|
// CHECK-NEXT: ],
|
|
// CHECK-NEXT: "clang-modulemap-file": "[[PREFIX]]/module.modulemap",
|
|
// CHECK-NEXT: "command-line": [
|
|
// CHECK: ],
|
|
// CHECK-NEXT: "context-hash": "{{.*}}",
|
|
// CHECK-NEXT: "file-deps": [
|
|
// CHECK-NEXT: "[[PREFIX]]/direct.h"
|
|
// CHECK-NEXT: "[[PREFIX]]/module.modulemap"
|
|
// CHECK-NEXT: ],
|
|
// CHECK-NEXT: "link-libraries": [],
|
|
// CHECK-NEXT: "name": "direct"
|
|
// CHECK-NEXT: },
|
|
// CHECK-NEXT: {
|
|
// CHECK-NEXT: "clang-module-deps": [
|
|
// CHECK-NEXT: {
|
|
// CHECK-NEXT: "context-hash": "{{.*}}",
|
|
// CHECK-NEXT: "module-name": "Framework"
|
|
// CHECK-NEXT: },
|
|
// CHECK-NEXT: {
|
|
// CHECK-NEXT: "context-hash": "{{.*}}",
|
|
// CHECK-NEXT: "module-name": "direct"
|
|
// CHECK-NEXT: }
|
|
// CHECK-NEXT: ],
|
|
// CHECK-NEXT: "clang-modulemap-file": "[[PREFIX]]/module.modulemap",
|
|
// CHECK-NEXT: "command-line": [
|
|
// CHECK: ],
|
|
// CHECK-NEXT: "context-hash": "{{.*}}",
|
|
// CHECK-NEXT: "file-deps": [
|
|
// CHECK-NEXT: "[[PREFIX]]/Inputs/frameworks/module.modulemap"
|
|
// CHECK-NEXT: "[[PREFIX]]/module.modulemap"
|
|
// CHECK-NEXT: "[[PREFIX]]/root.h"
|
|
// CHECK-NEXT: "[[PREFIX]]/root/textual.h"
|
|
// CHECK-NEXT: ],
|
|
// CHECK-NEXT: "link-libraries": [],
|
|
// CHECK-NEXT: "name": "root"
|
|
// CHECK-NEXT: },
|
|
// CHECK-NEXT: {
|
|
// CHECK-NEXT: "clang-module-deps": [],
|
|
// CHECK-NEXT: "clang-modulemap-file": "[[PREFIX]]/module.modulemap",
|
|
// CHECK-NEXT: "command-line": [
|
|
// CHECK: ],
|
|
// CHECK-NEXT: "context-hash": "{{.*}}",
|
|
// CHECK-NEXT: "file-deps": [
|
|
// CHECK-NEXT: "[[PREFIX]]/module.modulemap"
|
|
// CHECK-NEXT: "[[PREFIX]]/transitive.h"
|
|
// CHECK-NEXT: ],
|
|
// CHECK-NEXT: "link-libraries": [
|
|
// CHECK-NEXT: {
|
|
// CHECK-NEXT: "isFramework": true,
|
|
// CHECK-NEXT: "link-name": "libTransitive"
|
|
// CHECK-NEXT: }
|
|
// CHECK-NEXT: ],
|
|
// CHECK-NEXT: "name": "transitive"
|
|
// CHECK-NEXT: }
|
|
// CHECK-NEXT: ],
|
|
// CHECK-NEXT: "translation-units": []
|
|
// CHECK-NEXT: }
|