| 1 |
// RUN: rm -rf %t |
| 2 |
// RUN: mkdir %t |
| 3 |
// RUN: split-file %s %t |
| 4 |
|
| 5 |
// RUN: %clang_cc1 -std=c++20 -emit-module-interface -triple %itanium_abi_triple %t/parta.cppm -o %t/mod-parta.pcm |
| 6 |
// RUN: %clang_cc1 -std=c++20 -emit-module-interface -triple %itanium_abi_triple %t/partb.cppm -o %t/mod-partb.pcm |
| 7 |
// 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.pcm |
| 9 |
// 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.cppm |
| 11 |
// 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.pcm |
| 13 |
// 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-OPT |
| 15 |
|
| 16 |
//--- parta.cppm |
| 17 |
export module mod:parta; |
| 18 |
|
| 19 |
export int a = 43; |
| 20 |
|
| 21 |
export int foo() { |
| 22 |
return 3 + a; |
| 23 |
} |
| 24 |
|
| 25 |
//--- partb.cppm |
| 26 |
module mod:partb; |
| 27 |
|
| 28 |
int b = 43; |
| 29 |
|
| 30 |
int bar() { |
| 31 |
return 43 + b; |
| 32 |
} |
| 33 |
|
| 34 |
//--- mod.cppm |
| 35 |
export module mod; |
| 36 |
import :parta; |
| 37 |
import :partb; |
| 38 |
export 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 global |
| 44 |
// CHECK: @_ZW3mod1b = external global |
| 45 |
// CHECK: declare{{.*}} i32 @_ZW3mod3foov |
| 46 |
// CHECK: declare{{.*}} i32 @_ZW3mod3barv |
| 47 |
|
| 48 |
// CHECK-OPT: @_ZW3mod1a = external global |
| 49 |
// CHECK-OPT: @_ZW3mod1b = external global |
| 50 |
// CHECK-OPT: declare{{.*}} i32 @_ZW3mod3foov |
| 51 |
// CHECK-OPT: declare{{.*}} i32 @_ZW3mod3barv |