86 lines · cpp
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 source3// location space. This optimization is important for using module maps in4// large codebases to avoid running out of source location space.5 6// RUN: rm -rf %t && mkdir %t7// RUN: split-file %s %t8 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.pcm10// 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.pcm14// 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.pcm18// 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.pcm22// 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.pcm26// 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.cc27 28//--- base.map29module base { header "vector.h" }30//--- mod1.map31module mod1 { header "mod1.h" }32//--- mod2.map33module mod2 { header "mod2.h" }34//--- mod3.map35module mod3 { header "mod3.h" }36//--- mod4.map37module mod4 { header "mod4.h" }38//--- check_slocs.cc39#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// 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}}52 53 54//--- vector.h55#ifndef VECTOR_H56#define VECTOR_H57#endif58 59//--- mod1.h60#ifndef MOD161#define MOD162#include "vector.h"63int mod1();64#endif65//--- mod2.h66#ifndef MOD267#define MOD268#include "vector.h"69#include "mod1.h"70int mod2();71#endif72//--- mod3.h73#ifndef MOD374#define MOD375#include "vector.h"76#include "mod2.h"77int mod3();78#endif79//--- mod4.h80#ifndef MOD481#define MOD482#include "vector.h"83#include "mod3.h"84int mod4();85#endif86