113 lines · plain
1// Test that a change related to an ADL can be propagated correctly.2//3// RUN: rm -rf %t4// RUN: split-file %s %t5//6// RUN: %clang_cc1 -std=c++20 %t/Common.cppm -emit-reduced-module-interface -o %t/Common.pcm7//8// RUN: %clang_cc1 -std=c++20 %t/m-partA.cppm -emit-reduced-module-interface -o %t/m-partA.pcm \9// RUN: -fmodule-file=Common=%t/Common.pcm10// RUN: %clang_cc1 -std=c++20 %t/m-partA.v1.cppm -emit-reduced-module-interface -o \11// RUN: %t/m-partA.v1.pcm -fmodule-file=Common=%t/Common.pcm12// RUN: %clang_cc1 -std=c++20 %t/m-partB.cppm -emit-reduced-module-interface -o %t/m-partB.pcm13// RUN: %clang_cc1 -std=c++20 %t/m.cppm -emit-reduced-module-interface -o %t/m.pcm \14// RUN: -fmodule-file=m:partA=%t/m-partA.pcm -fmodule-file=m:partB=%t/m-partB.pcm \15// RUN: -fmodule-file=Common=%t/Common.pcm16// RUN: %clang_cc1 -std=c++20 %t/m.cppm -emit-reduced-module-interface -o %t/m.v1.pcm \17// RUN: -fmodule-file=m:partA=%t/m-partA.v1.pcm -fmodule-file=m:partB=%t/m-partB.pcm \18// RUN: -fmodule-file=Common=%t/Common.pcm19//20// Produce B.pcm and B.v1.pcm21// RUN: %clang_cc1 -std=c++20 %t/B.cppm -emit-reduced-module-interface -o %t/B.pcm \22// RUN: -fmodule-file=m=%t/m.pcm -fmodule-file=m:partA=%t/m-partA.pcm \23// RUN: -fmodule-file=m:partB=%t/m-partB.pcm -fmodule-file=Common=%t/Common.pcm24// RUN: %clang_cc1 -std=c++20 %t/B.cppm -emit-reduced-module-interface -o %t/B.v1.pcm \25// RUN: -fmodule-file=m=%t/m.v1.pcm -fmodule-file=m:partA=%t/m-partA.v1.pcm \26// RUN: -fmodule-file=m:partB=%t/m-partB.pcm -fmodule-file=Common=%t/Common.pcm27//28// Verify that both B.pcm and B.v1.pcm can work as expected.29// RUN: %clang_cc1 -std=c++20 %t/use.cpp -fsyntax-only -verify -fmodule-file=m=%t/m.pcm \30// RUN: -fmodule-file=m:partA=%t/m-partA.pcm -fmodule-file=m:partB=%t/m-partB.pcm \31// RUN: -fmodule-file=B=%t/B.pcm -fmodule-file=Common=%t/Common.pcm \32// RUN: -DEXPECTED_VALUE=false33// RUN: %clang_cc1 -std=c++20 %t/use.cpp -fsyntax-only -verify -fmodule-file=m=%t/m.v1.pcm \34// RUN: -fmodule-file=m:partA=%t/m-partA.v1.pcm -fmodule-file=m:partB=%t/m-partB.pcm \35// RUN: -fmodule-file=B=%t/B.v1.pcm -fmodule-file=Common=%t/Common.pcm \36// RUN: -DEXPECTED_VALUE=true37//38// Since we add new ADL function in m-partA.v1.cppm, B.v1.pcm is expected to not be the same with39// B.pcm.40// RUN: not diff %t/B.pcm %t/B.v1.pcm &> /dev/null41 42// Test that BMI won't differ if it doesn't refer adl.43// RUN: %clang_cc1 -std=c++20 %t/C.cppm -emit-reduced-module-interface -o %t/C.pcm \44// RUN: -fmodule-file=m=%t/m.pcm -fmodule-file=m:partA=%t/m-partA.pcm \45// RUN: -fmodule-file=m:partB=%t/m-partB.pcm -fmodule-file=Common=%t/Common.pcm46// RUN: %clang_cc1 -std=c++20 %t/C.cppm -emit-reduced-module-interface -o %t/C.v1.pcm \47// RUN: -fmodule-file=m=%t/m.v1.pcm -fmodule-file=m:partA=%t/m-partA.v1.pcm \48// RUN: -fmodule-file=m:partB=%t/m-partB.pcm -fmodule-file=Common=%t/Common.pcm49// RUN: diff %t/C.pcm %t/C.v1.pcm &> /dev/null50 51//--- Common.cppm52export module Common;53 54export namespace N {55 struct A {56 constexpr operator int() {57 return 43;58 }59 };60}61 62//--- m-partA.cppm63export module m:partA;64import Common;65 66export namespace N {}67 68//--- m-partA.v1.cppm69export module m:partA;70import Common;71 72export namespace N {73constexpr bool adl(A) { return true; }74}75 76//--- m-partB.cppm77export module m:partB;78 79export constexpr bool adl(int) { return false; }80 81//--- m.cppm82export module m;83export import :partA;84export import :partB;85 86//--- B.cppm87export module B;88import m;89 90export template <class C>91constexpr bool test_adl(C c) {92 return adl(c);93}94 95//--- use.cpp96// expected-no-diagnostics97import B;98import Common;99 100void test() {101 N::A a;102 static_assert(test_adl(a) == EXPECTED_VALUE);103}104 105//--- C.cppm106export module B;107import m;108 109export template <class C>110constexpr bool not_test_adl(C c) {111 return false;112}113