105 lines · cpp
1// Same as prune-non-affecting-module-map-repeated.cpp, but check that textual-only2// inclusions do not cause duplication of the module map files they are defined in.3 4// RUN: rm -rf %t && mkdir %t5// RUN: split-file %s %t6 7// RUN: %clang_cc1 -xc++ -fmodules -fno-implicit-modules \8// RUN: -fmodule-map-file=%t/base.map -fmodule-map-file=%t/mixed.map\9// RUN: -fmodule-map-file=%t/mod1.map \10// RUN: -fmodule-name=mod1 -emit-module %t/mod1.map -o %t/mod1.pcm11// RUN: %clang_cc1 -xc++ -fmodules -fno-implicit-modules \12// RUN: -fmodule-map-file=%t/mixed.map\13// RUN: -fmodule-name=mixed -emit-module %t/mixed.map -o %t/mixed.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 -fmodule-file=%t/mixed.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 -fmodule-file=%t/mixed.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 { textual header "vector.h" }30//--- mixed.map31module mixed { textual header "mixed_text.h" header "mixed_mod.h"}32//--- mod1.map33module mod1 { header "mod1.h" }34//--- mod2.map35module mod2 { header "mod2.h" }36//--- mod3.map37module mod3 { header "mod3.h" }38//--- mod4.map39module mod4 { header "mod4.h" }40//--- check_slocs.cc41#include "mod4.h"42#include "vector.h"43#pragma clang __debug sloc_usage // expected-remark {{source manager location address space usage}}44// expected-note@* {{% of available space}}45 46// base.map must only be present once, despite being used in each module.47// Because its location in every module compile should be non-affecting.48 49// expected-note@base.map:1 {{file entered 1 time}}50 51// different modules use either only textual header from mixed.map or both textual and modular52// headers. Either combination must lead to only 1 use at the end, because the module is ultimately53// in the import chain and any textual uses should not change that.54 55// expected-note@mixed.map:1 {{file entered 1 time}}56 57// expected-note@* + {{file entered}}58 59 60//--- vector.h61#ifndef VECTOR_H62#define VECTOR_H63#endif64 65//--- mixed_text.h66#ifndef MIXED_TEXT_H67#define MIXED_TEXT_H68#endif69//--- mixed_mod.h70#ifndef MIXED_MOD_H71#define MIXED_MOD_H72#endif73 74//--- mod1.h75#ifndef MOD176#define MOD177#include "vector.h"78#include "mixed_text.h"79int mod1();80#endif81//--- mod2.h82#ifndef MOD283#define MOD284#include "vector.h"85#include "mod1.h"86#include "mixed_mod.h"87int mod2();88#endif89//--- mod3.h90#ifndef MOD391#define MOD392#include "vector.h"93#include "mod2.h"94#include "mixed_text.h"95#include "mixed_mod.h"96int mod3();97#endif98//--- mod4.h99#ifndef MOD4100#define MOD4101#include "vector.h"102#include "mod3.h"103int mod4();104#endif105