109 lines · plain
1// Testing that adding an new identifier in an unused module file won't change 2// the BMI of the current module file.3//4// RUN: rm -rf %t5// RUN: split-file %s %t6//7// RUN: %clang_cc1 -std=c++20 %t/m-partA.cppm -emit-reduced-module-interface -o %t/m-partA.pcm8// RUN: %clang_cc1 -std=c++20 %t/m-partA.v1.cppm -emit-reduced-module-interface -o \9// RUN: %t/m-partA.v1.pcm10// RUN: %clang_cc1 -std=c++20 %t/m-partB.cppm -emit-reduced-module-interface -o %t/m-partB.pcm11// RUN: %clang_cc1 -std=c++20 %t/m.cppm -emit-reduced-module-interface -o %t/m.pcm \12// RUN: -fmodule-file=m:partA=%t/m-partA.pcm -fmodule-file=m:partB=%t/m-partB.pcm13// RUN: %clang_cc1 -std=c++20 %t/m.cppm -emit-reduced-module-interface -o %t/m.v1.pcm \14// RUN: -fmodule-file=m:partA=%t/m-partA.v1.pcm -fmodule-file=m:partB=%t/m-partB.pcm15//16// RUN: %clang_cc1 -std=c++20 %t/useBOnly.cppm -emit-reduced-module-interface -o %t/useBOnly.pcm \17// RUN: -fmodule-file=m=%t/m.pcm -fmodule-file=m:partA=%t/m-partA.pcm \18// RUN: -fmodule-file=m:partB=%t/m-partB.pcm19// RUN: %clang_cc1 -std=c++20 %t/useBOnly.cppm -emit-reduced-module-interface -o %t/useBOnly.v1.pcm \20// RUN: -fmodule-file=m=%t/m.v1.pcm -fmodule-file=m:partA=%t/m-partA.v1.pcm \21// RUN: -fmodule-file=m:partB=%t/m-partB.pcm22// Since useBOnly only uses partB from module M, the change in partA shouldn't affect23// useBOnly.24// RUN: diff %t/useBOnly.pcm %t/useBOnly.v1.pcm &> /dev/null25//26// RUN: %clang_cc1 -std=c++20 %t/useAOnly.cppm -emit-reduced-module-interface -o %t/useAOnly.pcm \27// RUN: -fmodule-file=m=%t/m.pcm -fmodule-file=m:partA=%t/m-partA.pcm \28// RUN: -fmodule-file=m:partB=%t/m-partB.pcm29// RUN: %clang_cc1 -std=c++20 %t/useAOnly.cppm -emit-reduced-module-interface -o %t/useAOnly.v1.pcm \30// RUN: -fmodule-file=m=%t/m.v1.pcm -fmodule-file=m:partA=%t/m-partA.v1.pcm \31// RUN: -fmodule-file=m:partB=%t/m-partB.pcm32// useAOnly should differ33// RUN: not diff %t/useAOnly.pcm %t/useAOnly.v1.pcm &> /dev/null34 35//--- m-partA.cppm36export module m:partA;37 38export inline int getA() {39 return 43;40}41 42export class A {43public:44 int getMem();45};46 47export template <typename T>48class ATempl {49public:50 T getT();51};52 53//--- m-partA.v1.cppm54export module m:partA;55 56export inline int getA() {57 return 43;58}59 60// The consuming module which didn't use m:partA completely is expected to be61// not changed.62export inline int getA2() {63 return 88;64}65 66export class A {67public:68 int getMem();69 70 // The consuming module which didn't use m:partA completely is expected to be71 // not changed.72 int getMem2();73};74 75export template <typename T>76class ATempl {77public:78 T getT();79 T getT2();80};81 82//--- m-partB.cppm83export module m:partB;84 85export inline int getB() {86 return 430;87}88 89//--- m.cppm90export module m;91export import :partA;92export import :partB;93 94//--- useBOnly.cppm95export module useBOnly;96import m;97 98export inline int get() {99 return getB();100}101 102//--- useAOnly.cppm103export module useAOnly;104import m;105 106export inline int get() {107 return getA();108}109