xref: /llvm-project/clang/test/Modules/modules-reduced-bmi.cppm (revision 7c1d9b15eee3a34678addab2bab66f3020ac0753)
1// RUN: rm -rf %t
2// RUN: mkdir -p %t
3// RUN: split-file %s %t
4//
5// RUN: %clang_cc1 -std=c++20 %t/a.cppm -emit-reduced-module-interface -o %t/a.reduced.pcm
6// RUN: %clang_cc1 -std=c++20 %t/a.cppm -fexperimental-modules-reduced-bmi -fmodule-output=%t/a.pcm \
7// RUN:     -emit-llvm -o %t/a.ll
8//
9// Test that the generated BMI from `-fexperimental-modules-reduced-bmi -fmodule-output=` is same with
10// `-emit-reduced-module-interface`.
11// RUN: diff %t/a.reduced.pcm %t/a.pcm
12//
13// Test that we can consume the produced BMI correctly.
14// RUN: %clang_cc1 -std=c++20 %t/b.cppm -fmodule-file=a=%t/a.pcm -fsyntax-only -verify
15//
16// RUN: rm -f %t/a.pcm
17// RUN: %clang_cc1 -std=c++20 %t/a.cppm -fexperimental-modules-reduced-bmi -fmodule-output=%t/a.pcm \
18// RUN:     -emit-module-interface -o %t/a.full.pcm
19// RUN: diff %t/a.reduced.pcm %t/a.pcm
20// RUN: not diff %t/a.pcm %t/a.full.pcm
21//
22// RUN: %clang_cc1 -std=c++20 %t/b.cppm -fmodule-file=a=%t/a.pcm -fsyntax-only -verify
23// RUN: %clang_cc1 -std=c++20 %t/b.cppm -fmodule-file=a=%t/a.full.pcm -fsyntax-only -verify
24
25//--- a.cppm
26export module a;
27export int a() {
28    return 43;
29}
30
31//--- b.cppm
32// Test that we can consume the produced BMI correctly as a smocking test.
33// expected-no-diagnostics
34export module b;
35import a;
36export int b() { return a(); }
37