Author: Chuanqi Xu Date: 2025-02-27T18:51:39+08:00 New Revision: e3f52690c796baca241a6771d897adc6670a1ed8
URL: https://github.com/llvm/llvm-project/commit/e3f52690c796baca241a6771d897adc6670a1ed8 DIFF: https://github.com/llvm/llvm-project/commit/e3f52690c796baca241a6771d897adc6670a1ed8.diff LOG: [NFC] [C++20] [Modules] Add a test for no transitive changes Added: clang/test/Modules/no-transitive-source-location-change-2.cppm Modified: Removed: ################################################################################ diff --git a/clang/test/Modules/no-transitive-source-location-change-2.cppm b/clang/test/Modules/no-transitive-source-location-change-2.cppm new file mode 100644 index 0000000000000..f16b945a04d69 --- /dev/null +++ b/clang/test/Modules/no-transitive-source-location-change-2.cppm @@ -0,0 +1,66 @@ +// Testing that adding a new line in a module interface unit won't cause the BMI +// of consuming module unit changes. +// +// RUN: rm -rf %t +// RUN: split-file %s %t +// +// RUN: %clang_cc1 -std=c++20 %t/A.part.cppm -emit-reduced-module-interface -o %t/A-part.pcm +// +// RUN: %clang_cc1 -std=c++20 %t/A.cppm -emit-reduced-module-interface -o %t/A.v0.pcm \ +// RUN: -fprebuilt-module-path=%t +// RUN: %clang_cc1 -std=c++20 %t/A.v1.cppm -emit-reduced-module-interface -o %t/A.v1.pcm \ +// RUN: -fprebuilt-module-path=%t +// +// The BMI may not be the same since the source location diff ers. +// RUN: not diff %t/A.pcm %t/A.v1.pcm &> /dev/null +// +// The BMI of B shouldn't change since all the locations remain the same. +// RUN: %clang_cc1 -std=c++20 %t/B.cppm -emit-reduced-module-interface -fmodule-file=A=%t/A.v0.pcm \ +// RUN: -o %t/B.pcm -fprebuilt-module-path=%t +// RUN: %clang_cc1 -std=c++20 %t/B.cppm -emit-reduced-module-interface -fmodule-file=A=%t/A.v1.pcm \ +// RUN: -o %t/B.v1.pcm -fprebuilt-module-path=%t +// RUN: diff %t/B.v1.pcm %t/B.pcm &> /dev/null +// +// The BMI of C may change since the locations for instantiations changes. +// RUN: %clang_cc1 -std=c++20 %t/C.cppm -emit-reduced-module-interface -fmodule-file=A=%t/A.v0.pcm \ +// RUN: -o %t/C.pcm -fprebuilt-module-path=%t +// RUN: %clang_cc1 -std=c++20 %t/C.cppm -emit-reduced-module-interface -fmodule-file=A=%t/A.v1.pcm \ +// RUN: -o %t/C.v1.pcm -fprebuilt-module-path=%t +// RUN: diff %t/C.v1.pcm %t/C.pcm &> /dev/null + +//--- A.part.cppm +export module A:part; +export template <class T> +struct C { + T func() { + return T(43); + } +}; +export int funcA() { + return 43; +} + +//--- A.cppm +export module A; +export import :part; + +//--- A.v1.cppm +export module A; + +export import :part; + +//--- B.cppm +export module B; +import A; + +export int funcB() { + return funcA(); +} + +//--- C.cppm +export module C; +import A; +export inline void testD() { + C<int> c; + c.func(); +} _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits