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.
6 // RUN: rm -rf %t && mkdir %t
7 // RUN: split-file %s %t
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
29 module base
{ header
"vector.h" }
31 module mod1
{ header
"mod1.h" }
33 module mod2
{ header
"mod2.h" }
35 module mod3
{ header
"mod3.h" }
37 module mod4
{ header
"mod4.h" }
40 #pragma clang __debug sloc_usage // expected-remark {{source manager location address space usage}}
41 // expected-note@* {{% of available space}}
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.
46 // expected-note@base.map:1 {{file entered 2 times}}
47 // expected-note@mod4.map:1 {{file entered 2 times}}
48 // expected-note@mod1.map:1 {{file entered 1 time}}
49 // expected-note@mod2.map:1 {{file entered 1 time}}
50 // expected-note@mod3.map:1 {{file entered 1 time}}
51 // expected-note@* + {{file entered}}