1// Testing that changing a type in an unused module file won't change 2// the BMI of the current module file. 3// 4// RUN: rm -rf %t 5// RUN: split-file %s %t 6// 7// RUN: %clang_cc1 -std=c++20 %t/m-partA.cppm -emit-reduced-module-interface -o %t/m-partA.pcm 8// RUN: %clang_cc1 -std=c++20 %t/m-partA.v1.cppm -emit-reduced-module-interface -o \ 9// RUN: %t/m-partA.v1.pcm 10// RUN: %clang_cc1 -std=c++20 %t/m-partB.cppm -emit-reduced-module-interface -o %t/m-partB.pcm 11// 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.pcm 13// 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.pcm 15// 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.pcm 19// 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.pcm 22// Since useBOnly only uses partB from module M, the change in partA shouldn't affect 23// useBOnly. 24// RUN: diff %t/useBOnly.pcm %t/useBOnly.v1.pcm &> /dev/null 25// 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.pcm 29// 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.pcm 32// Since useAOnly uses partA from module M, the change in partA should affect useAOnly. 33// RUN: not diff %t/useAOnly.pcm %t/useAOnly.v1.pcm &> /dev/null 34 35//--- m-partA.cppm 36export module m:partA; 37 38export int getValueFromA() { return 43; } 39 40//--- m-partA.v1.cppm 41export module m:partA; 42 43export int getValueFromA() { return 43; } 44 45namespace NS { 46 class A { 47 public: 48 int getValue() { 49 return 43; 50 } 51 }; 52} 53 54//--- m-partB.cppm 55export module m:partB; 56 57export inline int getB() { 58 return 430; 59} 60 61//--- m.cppm 62export module m; 63export import :partA; 64export import :partB; 65 66//--- useBOnly.cppm 67export module useBOnly; 68import m; 69 70export inline int get() { 71 return getB(); 72} 73 74//--- useAOnly.cppm 75export module useAOnly; 76import m; 77 78export inline int get() { 79 return getValueFromA(); 80} 81