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
|
// Test importing a private module whose public module was previously imported
// via a PCH.
// 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
// 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
// RUN: %deps-to-rsp %t/deps_pch.json --module-name Mod > %t/Mod.rsp
// RUN: %deps-to-rsp %t/deps_pch.json --module-name Indirect1 > %t/Indirect1.rsp
// RUN: %deps-to-rsp %t/deps_pch.json --tu-index 0 > %t/pch.rsp
// RUN: %clang @%t/Mod.rsp
// RUN: %clang @%t/Indirect1.rsp
// RUN: %clang @%t/pch.rsp
// 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
// RUN: %deps-to-rsp %t/deps.json --module-name Mod_Private > %t/Mod_Private.rsp
// RUN: %deps-to-rsp %t/deps.json --module-name Indirect2 > %t/Indirect2.rsp
// RUN: %deps-to-rsp %t/deps.json --tu-index 0 > %t/tu.rsp
// RUN: %clang @%t/Mod_Private.rsp
// RUN: %clang @%t/Indirect2.rsp
// RUN: %clang @%t/tu.rsp
// Extract include-tree casids
// RUN: cat %t/Indirect2.rsp | sed -E 's|.*"-fcas-include-tree" "(llvmcas://[[:xdigit:]]+)".*|\1|' > %t/Indirect.casid
// RUN: cat %t/tu.rsp | sed -E 's|.*"-fcas-include-tree" "(llvmcas://[[:xdigit:]]+)".*|\1|' > %t/tu.casid
// RUN: echo "MODULE Indirect2" > %t/result.txt
// RUN: clang-cas-test -cas %t/cas -print-include-tree @%t/Indirect.casid >> %t/result.txt
// RUN: echo "TRANSLATION UNIT" >> %t/result.txt
// RUN: clang-cas-test -cas %t/cas -print-include-tree @%t/tu.casid >> %t/result.txt
// Explicitly check that Mod_Private is imported as a module and not a header.
// RUN: FileCheck %s -DPREFIX=%/t -input-file %t/result.txt
// CHECK-LABEL: MODULE Indirect2
// CHECK: <module-includes> llvmcas://
// CHECK: 1:1 <built-in> llvmcas://
// CHECK: 2:1 [[PREFIX]]/indirect2.h llvmcas://
// CHECK: Submodule: Indirect2
// CHECK: 2:1 (Module) Indirect1
// CHECK: 3:1 (Module) Mod_Private
// CHECK-LABEL: TRANSLATION UNIT
// CHECK: (PCH) <PCH> llvmcas://
// CHECK: [[PREFIX]]/tu.m llvmcas://
// CHECK: 1:1 <built-in> llvmcas://
// CHECK: 2:1 (Module) Mod_Private
// CHECK: 3:1 (Module) Indirect2
//--- cdb.json.template
[{
"file": "DIR/tu.m",
"directory": "DIR",
"command": "clang -fsyntax-only DIR/tu.m -include prefix.h -F DIR -fmodules -fimplicit-modules -fimplicit-module-maps -fmodules-cache-path=DIR/module-cache"
}]
//--- cdb_pch.json.template
[{
"file": "DIR/prefix.h",
"directory": "DIR",
"command": "clang -x objective-c-header DIR/prefix.h -o DIR/prefix.h.pch -F DIR -fmodules -fimplicit-modules -fimplicit-module-maps -fmodules-cache-path=DIR/module-cache"
}]
//--- Mod.framework/Modules/module.modulemap
framework module Mod { header "Mod.h" }
//--- Mod.framework/Modules/module.private.modulemap
framework module Mod_Private { header "Priv.h" }
//--- Mod.framework/Headers/Mod.h
void pub(void);
//--- Mod.framework/PrivateHeaders/Priv.h
void priv(void);
//--- module.modulemap
module Indirect1 {
header "indirect1.h"
export *
}
module Indirect2 {
header "indirect2.h"
export *
}
//--- indirect1.h
#import <Mod/Mod.h>
//--- indirect2.h
#import "indirect1.h"
#import <Mod/Priv.h>
static inline void indirect(void) {
pub();
priv();
}
//--- prefix.h
#import <Mod/Mod.h>
#import "indirect1.h"
//--- tu.m
#import <Mod/Priv.h>
#import "indirect2.h"
void tu(void) {
pub();
priv();
indirect();
}
|