52 lines · cpp
1// RUN: rm -rf %t2// RUN: mkdir %t3// RUN: split-file %s %t4 5// RUN: %clang_cc1 -std=c++20 -emit-module-interface -triple %itanium_abi_triple %t/parta.cppm -o %t/mod-parta.pcm6// RUN: %clang_cc1 -std=c++20 -emit-module-interface -triple %itanium_abi_triple %t/partb.cppm -o %t/mod-partb.pcm7// RUN: %clang_cc1 -std=c++20 -emit-module-interface -triple %itanium_abi_triple %t/mod.cppm \8// RUN: -fprebuilt-module-path=%t -o %t/mod.pcm9// RUN: %clang_cc1 -std=c++20 -triple %itanium_abi_triple %t/mod.pcm -emit-llvm -disable-llvm-passes -o - \10// RUN: -fprebuilt-module-path=%t | FileCheck %t/mod.cppm11// RUN: %clang_cc1 -std=c++20 -O2 -emit-module-interface -triple %itanium_abi_triple \12// RUN: -fprebuilt-module-path=%t %t/mod.cppm -o %t/mod.pcm13// RUN: %clang_cc1 -std=c++20 -O2 -triple %itanium_abi_triple %t/mod.pcm -emit-llvm \14// RUN: -fprebuilt-module-path=%t -disable-llvm-passes -o - | FileCheck %t/mod.cppm -check-prefix=CHECK-OPT15 16//--- parta.cppm17export module mod:parta;18 19export int a = 43;20 21export int foo() {22 return 3 + a;23}24 25//--- partb.cppm26module mod:partb;27 28int b = 43;29 30int bar() {31 return 43 + b;32}33 34//--- mod.cppm35export module mod;36import :parta;37import :partb;38export int use() {39 return foo() + bar() + a + b;40}41 42// FIXME: The definition of the variables shouldn't be exported too.43// CHECK: @_ZW3mod1a = external global44// CHECK: @_ZW3mod1b = external global45// CHECK: declare{{.*}} i32 @_ZW3mod3foov46// CHECK: declare{{.*}} i32 @_ZW3mod3barv47 48// CHECK-OPT: @_ZW3mod1a = external global49// CHECK-OPT: @_ZW3mod1b = external global50// CHECK-OPT: declare{{.*}} i32 @_ZW3mod3foov51// CHECK-OPT: declare{{.*}} i32 @_ZW3mod3barv52