1 // Test the module map path is consistent between clang invocations when using VFS overlays.
4 // RUN: split-file %s %t
6 // Pre-populate the module cache with the modules that don't use VFS overlays.
7 // RUN: %clang_cc1 -fsyntax-only -F%t/Frameworks -I%t/include %t/prepopulate_module_cache.m \
8 // RUN: -fmodules -fimplicit-module-maps -fmodules-cache-path=%t/modules.cache
10 // Execute a compilation with VFS overlay. .pcm file path looks like <hash1>/ModuleName-<hash2>.pcm.
11 // <hash1> corresponds to the compilation settings like language options.
12 // <hash2> corresponds to the module map path. So if any of those change, we should use a different module.
13 // But for VFS overlay we make an exception that it's not a part of <hash1> to reduce the number of built .pcm files.
14 // Test that paths in overlays don't leak into <hash2> and don't cause using 2 .pcm files for the same module.
15 // DEFINE: %{command} = %clang_cc1 -fsyntax-only -verify -F%t/Frameworks -I%t/include %t/test.m \
16 // DEFINE: -fmodules -fimplicit-module-maps -fmodules-cache-path=%t/modules.cache
17 // RUN: sed -e "s@TMP_DIR@%{/t:regex_replacement}@g" -e "s@USE_EXTERNAL_NAMES_OPTION@@g" %t/overlay.yaml.template > %t/external-names-default.yaml
18 // RUN: %{command} -ivfsoverlay %t/external-names-default.yaml
20 // RUN: sed -e "s@TMP_DIR@%{/t:regex_replacement}@g" -e "s@USE_EXTERNAL_NAMES_OPTION@'use-external-names': true,@g" %t/overlay.yaml.template > %t/external-names-true.yaml
21 // RUN: %{command} -ivfsoverlay %t/external-names-true.yaml
23 // RUN: sed -e "s@TMP_DIR@%{/t:regex_replacement}@g" -e "s@USE_EXTERNAL_NAMES_OPTION@'use-external-names': false,@g" %t/overlay.yaml.template > %t/external-names-false.yaml
24 // RUN: %{command} -ivfsoverlay %t/external-names-false.yaml
26 //--- prepopulate_module_cache.m
27 #import <Redirecting/Redirecting.h>
30 // At first import multi-path modules directly, so clang decides which .pcm file they should belong to.
31 #import <MultiPath/MultiPath.h>
32 #import <MultiPathHeader.h>
34 // Then import a module from the module cache and all its transitive dependencies.
35 // Make sure the .pcm files loaded directly are the same as 'Redirecting' is referencing.
36 #import <Redirecting/Redirecting.h>
37 // expected-no-diagnostics
40 //--- Frameworks/MultiPath.framework/Headers/MultiPath.h
41 void multiPathFramework(void);
43 //--- Frameworks/MultiPath.framework/Modules/module.modulemap
44 framework module MultiPath {
50 //--- include/MultiPathHeader.h
51 void multiPathHeader(void);
53 //--- include/module.modulemap
54 module MultiPathHeader {
55 header "MultiPathHeader.h"
60 //--- Frameworks/Redirecting.framework/Headers/Redirecting.h
61 #import <MultiPath/MultiPath.h>
62 #import <MultiPathHeader.h>
64 //--- Frameworks/Redirecting.framework/Modules/module.modulemap
65 framework module Redirecting {
66 header "Redirecting.h"
71 //--- BuildTemporaries/MultiPath.h
72 void multiPathFramework(void);
73 //--- BuildTemporaries/framework.modulemap
74 framework module MultiPath {
78 //--- BuildTemporaries/header.h
79 void multiPathHeader(void);
80 //--- BuildTemporaries/include.modulemap
81 module MultiPathHeader {
82 header "MultiPathHeader.h"
86 //--- overlay.yaml.template
89 USE_EXTERNAL_NAMES_OPTION
91 { 'name': 'TMP_DIR/Frameworks/MultiPath.framework/Headers', 'type': 'directory',
93 { 'name': 'MultiPath.h', 'type': 'file',
94 'external-contents': 'TMP_DIR/BuildTemporaries/MultiPath.h'}
96 { 'name': 'TMP_DIR/Frameworks/MultiPath.framework/Modules', 'type': 'directory',
98 { 'name': 'module.modulemap', 'type': 'file',
99 'external-contents': 'TMP_DIR/BuildTemporaries/framework.modulemap'}
101 { 'name': 'TMP_DIR/include', 'type': 'directory',
103 { 'name': 'MultiPathHeader.h', 'type': 'file',
104 'external-contents': 'TMP_DIR/BuildTemporaries/header.h'},
105 { 'name': 'module.modulemap', 'type': 'file',
106 'external-contents': 'TMP_DIR/BuildTemporaries/include.modulemap'}