1 // This test checks that importing private headers from the public headers of
2 // a framework is consistent between the dependency scanner and the explicit build.
5 // RUN: split-file %s %t
7 //--- frameworks/FW.framework/Modules/module.modulemap
8 framework module FW { header "FW.h" }
9 //--- frameworks/FW.framework/Modules/module.private.modulemap
10 framework module FW_Private { header "FW_Private.h"}
11 //--- frameworks/FW.framework/Headers/FW.h
12 #include <FW/FW_Private.h>
13 //--- frameworks/FW.framework/PrivateHeaders/FW_Private.h
16 //--- modules/module.modulemap
17 module Dependency { header "dependency.h" }
18 //--- modules/dependency.h
28 "command": "clang -fmodules -fmodules-cache-path=DIR/cache -fimplicit-module-maps -I DIR/modules -F DIR/frameworks -Wno-framework-include-private-from-public -Wno-atimport-in-framework-header -c DIR/tu.m -o DIR/tu.o"
31 // RUN: sed -e "s|DIR|%/t|g" %t/cdb.json.in > %t/cdb.json
32 // RUN: clang-scan-deps -compilation-database %t/cdb.json -format experimental-full > %t/deps.json
34 // Check that FW is reported to depend on FW_Private.
35 // RUN: cat %t/deps.json | sed 's:\\\\\?:/:g' | FileCheck %s -DPREFIX=%/t
37 // CHECK-NEXT: "modules": [
39 // CHECK-NEXT: "clang-module-deps": [],
40 // CHECK-NEXT: "clang-modulemap-file": "[[PREFIX]]/modules/module.modulemap",
41 // CHECK-NEXT: "command-line": [
43 // CHECK-NEXT: "context-hash": "{{.*}}",
44 // CHECK-NEXT: "file-deps": [
45 // CHECK-NEXT: "[[PREFIX]]/modules/dependency.h",
46 // CHECK-NEXT: "[[PREFIX]]/modules/module.modulemap"
48 // CHECK-NEXT: "name": "Dependency"
51 // CHECK-NEXT: "clang-module-deps": [
53 // CHECK-NEXT: "context-hash": "{{.*}}",
54 // CHECK-NEXT: "module-name": "FW_Private"
57 // CHECK-NEXT: "clang-modulemap-file": "[[PREFIX]]/frameworks/FW.framework/Modules/module.modulemap",
58 // CHECK-NEXT: "command-line": [
60 // CHECK-NEXT: "context-hash": "{{.*}}",
61 // CHECK-NEXT: "file-deps": [
62 // CHECK-NEXT: "[[PREFIX]]/frameworks/FW.framework/Headers/FW.h",
63 // CHECK-NEXT: "[[PREFIX]]/frameworks/FW.framework/Modules/module.modulemap",
64 // CHECK-NEXT: "[[PREFIX]]/frameworks/FW.framework/Modules/module.private.modulemap"
66 // CHECK-NEXT: "name": "FW"
69 // CHECK-NEXT: "clang-module-deps": [
71 // CHECK-NEXT: "context-hash": "{{.*}}",
72 // CHECK-NEXT: "module-name": "Dependency"
75 // CHECK-NEXT: "clang-modulemap-file": "[[PREFIX]]/frameworks/FW.framework/Modules/module.private.modulemap",
76 // CHECK-NEXT: "command-line": [
78 // CHECK-NEXT: "context-hash": "{{.*}}",
79 // CHECK-NEXT: "file-deps": [
80 // CHECK-NEXT: "[[PREFIX]]/frameworks/FW.framework/Modules/module.private.modulemap",
81 // CHECK-NEXT: "[[PREFIX]]/frameworks/FW.framework/PrivateHeaders/FW_Private.h",
82 // CHECK-NEXT: "[[PREFIX]]/modules/module.modulemap"
84 // CHECK-NEXT: "name": "FW_Private"
87 // CHECK-NEXT: "translation-units": [
89 // CHECK-NEXT: "commands": [
91 // CHECK-NEXT: "clang-context-hash": "{{.*}}",
92 // CHECK-NEXT: "clang-module-deps": [
94 // CHECK-NEXT: "context-hash": "{{.*}}",
95 // CHECK-NEXT: "module-name": "FW"
98 // CHECK-NEXT: "command-line": [
100 // CHECK-NEXT: "executable": "clang",
101 // CHECK-NEXT: "file-deps": [
102 // CHECK-NEXT: "[[PREFIX]]/tu.m"
104 // CHECK-NEXT: "input-file": "[[PREFIX]]/tu.m"
111 // Check that building FW succeeds. If FW_Private was to be treated textually,
112 // building FW would fail due to Dependency not being present on the command line.
113 // RUN: %deps-to-rsp %t/deps.json --module-name=Dependency > %t/Dependency.cc1.rsp
114 // RUN: %deps-to-rsp %t/deps.json --module-name=FW_Private > %t/FW_Private.cc1.rsp
115 // RUN: %deps-to-rsp %t/deps.json --module-name=FW > %t/FW.cc1.rsp
116 // RUN: %deps-to-rsp %t/deps.json --tu-index=0 > %t/tu.rsp
118 // RUN: %clang @%t/Dependency.cc1.rsp
119 // RUN: %clang @%t/FW_Private.cc1.rsp
120 // RUN: %clang @%t/FW.cc1.rsp
121 // RUN: %clang @%t/tu.rsp