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/module.modulemap",
46 // CHECK-NEXT: "[[PREFIX]]/modules/dependency.h"
48 // CHECK-NEXT: "link-libraries": [],
49 // CHECK-NEXT: "name": "Dependency"
52 // CHECK-NEXT: "clang-module-deps": [
54 // CHECK-NEXT: "context-hash": "{{.*}}",
55 // CHECK-NEXT: "module-name": "FW_Private"
58 // CHECK-NEXT: "clang-modulemap-file": "[[PREFIX]]/frameworks/FW.framework/Modules/module.modulemap",
59 // CHECK-NEXT: "command-line": [
61 // CHECK-NEXT: "context-hash": "{{.*}}",
62 // CHECK-NEXT: "file-deps": [
63 // CHECK-NEXT: "[[PREFIX]]/frameworks/FW.framework/Modules/module.modulemap",
64 // CHECK-NEXT: "[[PREFIX]]/frameworks/FW.framework/Modules/module.private.modulemap",
65 // CHECK-NEXT: "[[PREFIX]]/frameworks/FW.framework/Headers/FW.h"
67 // CHECK-NEXT: "link-libraries": [
69 // CHECK-NEXT: "isFramework": true,
70 // CHECK-NEXT: "link-name": "FW"
73 // CHECK-NEXT: "name": "FW"
76 // CHECK-NEXT: "clang-module-deps": [
78 // CHECK-NEXT: "context-hash": "{{.*}}",
79 // CHECK-NEXT: "module-name": "Dependency"
82 // CHECK-NEXT: "clang-modulemap-file": "[[PREFIX]]/frameworks/FW.framework/Modules/module.private.modulemap",
83 // CHECK-NEXT: "command-line": [
85 // CHECK-NEXT: "context-hash": "{{.*}}",
86 // CHECK-NEXT: "file-deps": [
87 // CHECK-NEXT: "[[PREFIX]]/frameworks/FW.framework/Modules/module.private.modulemap",
88 // CHECK-NEXT: "[[PREFIX]]/frameworks/FW.framework/PrivateHeaders/FW_Private.h",
89 // CHECK-NEXT: "[[PREFIX]]/modules/module.modulemap"
91 // CHECK-NEXT: "link-libraries": [
93 // CHECK-NEXT: "isFramework": true,
94 // CHECK-NEXT: "link-name": "FW"
97 // CHECK-NEXT: "name": "FW_Private"
100 // CHECK-NEXT: "translation-units": [
102 // CHECK-NEXT: "commands": [
104 // CHECK-NEXT: "clang-context-hash": "{{.*}}",
105 // CHECK-NEXT: "clang-module-deps": [
107 // CHECK-NEXT: "context-hash": "{{.*}}",
108 // CHECK-NEXT: "module-name": "FW"
111 // CHECK-NEXT: "command-line": [
113 // CHECK: "file-deps": [
114 // CHECK-NEXT: "[[PREFIX]]/tu.m"
116 // CHECK-NEXT: "input-file": "[[PREFIX]]/tu.m"
123 // Check that building FW succeeds. If FW_Private was to be treated textually,
124 // building FW would fail due to Dependency not being present on the command line.
125 // RUN: %deps-to-rsp %t/deps.json --module-name=Dependency > %t/Dependency.cc1.rsp
126 // RUN: %deps-to-rsp %t/deps.json --module-name=FW_Private > %t/FW_Private.cc1.rsp
127 // RUN: %deps-to-rsp %t/deps.json --module-name=FW > %t/FW.cc1.rsp
128 // RUN: %deps-to-rsp %t/deps.json --tu-index=0 > %t/tu.rsp
130 // RUN: %clang @%t/Dependency.cc1.rsp
131 // RUN: %clang @%t/FW_Private.cc1.rsp
132 // RUN: %clang @%t/FW.cc1.rsp
133 // RUN: %clang @%t/tu.rsp