| 1 |
// Check that the same module map file passed to -fmodule-map-file *and* |
| 2 |
// available from one of the `-fmodule-file` does not allocate extra source |
| 3 |
// location space. This optimization is important for using module maps in |
| 4 |
// large codebases to avoid running out of source location space. |
| 5 |
|
| 6 |
// RUN: rm -rf %t && mkdir %t |
| 7 |
// RUN: split-file %s %t |
| 8 |
|
| 9 |
// RUN: %clang_cc1 -xc++ -fmodules -fno-implicit-modules -fmodule-map-file=%t/base.map -fmodule-name=base -emit-module %t/base.map -o %t/base.pcm |
| 10 |
// RUN: %clang_cc1 -xc++ -fmodules -fno-implicit-modules \ |
| 11 |
// RUN: -fmodule-map-file=%t/base.map -fmodule-map-file=%t/mod1.map \ |
| 12 |
// RUN: -fmodule-file=%t/base.pcm \ |
| 13 |
// RUN: -fmodule-name=mod1 -emit-module %t/mod1.map -o %t/mod1.pcm |
| 14 |
// RUN: %clang_cc1 -xc++ -fmodules -fno-implicit-modules \ |
| 15 |
// RUN: -fmodule-map-file=%t/base.map -fmodule-map-file=%t/mod1.map -fmodule-map-file=%t/mod2.map \ |
| 16 |
// RUN: -fmodule-file=%t/mod1.pcm \ |
| 17 |
// RUN: -fmodule-name=mod2 -emit-module %t/mod2.map -o %t/mod2.pcm |
| 18 |
// RUN: %clang_cc1 -xc++ -fmodules -fno-implicit-modules \ |
| 19 |
// RUN: -fmodule-map-file=%t/base.map -fmodule-map-file=%t/mod2.map -fmodule-map-file=%t/mod3.map \ |
| 20 |
// RUN: -fmodule-file=%t/mod2.pcm \ |
| 21 |
// RUN: -fmodule-name=mod3 -emit-module %t/mod3.map -o %t/mod3.pcm |
| 22 |
// RUN: %clang_cc1 -xc++ -fmodules -fno-implicit-modules \ |
| 23 |
// RUN: -fmodule-map-file=%t/base.map -fmodule-map-file=%t/mod3.map -fmodule-map-file=%t/mod4.map \ |
| 24 |
// RUN: -fmodule-file=%t/mod3.pcm \ |
| 25 |
// RUN: -fmodule-name=mod4 -emit-module %t/mod4.map -o %t/mod4.pcm |
| 26 |
// RUN: %clang_cc1 -xc++ -fmodules -fno-implicit-modules -fmodule-map-file=%t/base.map -fmodule-map-file=%t/mod4.map -fmodule-file=%t/mod4.pcm -fsyntax-only -verify %t/check_slocs.cc |
| 27 |
|
| 28 |
//--- base.map |
| 29 |
module base { header "vector.h" } |
| 30 |
//--- mod1.map |
| 31 |
module mod1 { header "mod1.h" } |
| 32 |
//--- mod2.map |
| 33 |
module mod2 { header "mod2.h" } |
| 34 |
//--- mod3.map |
| 35 |
module mod3 { header "mod3.h" } |
| 36 |
//--- mod4.map |
| 37 |
module mod4 { header "mod4.h" } |
| 38 |
//--- check_slocs.cc |
| 39 |
#include "mod4.h" |
| 40 |
#pragma clang __debug sloc_usage // expected-remark {{source manager location address space usage}} |
| 41 |
// expected-note@* {{% of available space}} |
| 42 |
|
| 43 |
// Module map files files that were specified on the command line are entered twice (once when parsing command-line, once loaded from the .pcm) |
| 44 |
// Those that not specified on the command line must be entered once. |
| 45 |
|
| 46 |
// [email protected]:1 {{file entered 2 times}} |
| 47 |
// [email protected]:1 {{file entered 2 times}} |
| 48 |
// [email protected]:1 {{file entered 1 time}} |
| 49 |
// [email protected]:1 {{file entered 1 time}} |
| 50 |
// [email protected]:1 {{file entered 1 time}} |
| 51 |
// expected-note@* + {{file entered}} |
| 52 |
|
| 53 |
|
| 54 |
//--- vector.h |
| 55 |
#ifndef VECTOR_H |
| 56 |
#define VECTOR_H |
| 57 |
#endif |
| 58 |
|
| 59 |
//--- mod1.h |
| 60 |
#ifndef MOD1 |
| 61 |
#define MOD1 |
| 62 |
#include "vector.h" |
| 63 |
int mod1(); |
| 64 |
#endif |
| 65 |
//--- mod2.h |
| 66 |
#ifndef MOD2 |
| 67 |
#define MOD2 |
| 68 |
#include "vector.h" |
| 69 |
#include "mod1.h" |
| 70 |
int mod2(); |
| 71 |
#endif |
| 72 |
//--- mod3.h |
| 73 |
#ifndef MOD3 |
| 74 |
#define MOD3 |
| 75 |
#include "vector.h" |
| 76 |
#include "mod2.h" |
| 77 |
int mod3(); |
| 78 |
#endif |
| 79 |
//--- mod4.h |
| 80 |
#ifndef MOD4 |
| 81 |
#define MOD4 |
| 82 |
#include "vector.h" |
| 83 |
#include "mod3.h" |
| 84 |
int mod4(); |
| 85 |
#endif |