
Close https://github.com/llvm/llvm-project/issues/71034 See https://discourse.llvm.org/t/rfc-c-20-modules-introduce-thin-bmi-and-decls-hash/74755 This patch introduces reduced BMI, which doesn't contain the definitions of functions and variables if its definitions won't contribute to the ABI. Testing is a big part of the patch. We want to make sure the reduced BMI contains the same behavior with the existing and relatively stable fatBMI. This is pretty helpful for further reduction. The user interfaces part it left to following patches to ease the reviewing.
56 lines
1.2 KiB
C++
56 lines
1.2 KiB
C++
// RUN: rm -rf %t
|
|
// RUN: mkdir -p %t
|
|
// RUN: split-file %s %t
|
|
//
|
|
// RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/lib.cppm -o %t/lib.pcm
|
|
// RUN: %clang_cc1 -std=c++20 %t/main.cpp -fmodule-file=lib=%t/lib.pcm \
|
|
// RUN: -verify -fsyntax-only
|
|
|
|
// Test again with reduced BMI
|
|
// RUN: rm -rf %t
|
|
// RUN: mkdir -p %t
|
|
// RUN: split-file %s %t
|
|
//
|
|
// RUN: %clang_cc1 -std=c++20 -emit-reduced-module-interface %t/lib.cppm -o %t/lib.pcm
|
|
// RUN: %clang_cc1 -std=c++20 %t/main.cpp -fmodule-file=lib=%t/lib.pcm \
|
|
// RUN: -verify -fsyntax-only
|
|
|
|
//--- header.h
|
|
namespace lib::inline __1 {
|
|
template <class>
|
|
inline constexpr bool test = false;
|
|
template <class>
|
|
constexpr bool func() {
|
|
return false;
|
|
}
|
|
inline constexpr bool non_templ = true;
|
|
} // namespace lib
|
|
|
|
//--- lib.cppm
|
|
module;
|
|
#include "header.h"
|
|
export module lib;
|
|
|
|
export namespace lib {
|
|
using lib::test;
|
|
using lib::func;
|
|
using lib::non_templ;
|
|
} // namespace lib
|
|
|
|
//--- main.cpp
|
|
// expected-no-diagnostics
|
|
import lib;
|
|
|
|
struct foo {};
|
|
|
|
template <>
|
|
inline constexpr bool lib::test<foo> = true;
|
|
|
|
template <>
|
|
constexpr bool lib::func<foo>() {
|
|
return true;
|
|
}
|
|
|
|
static_assert(lib::test<foo>);
|
|
static_assert(lib::func<foo>());
|