llvm-project/clang/test/CodeGenCXX/header-unit-member-func-linkage.cpp
Chuanqi Xu 79fa0ec8c4 [C++20] [Modules] Make member functions with a in-class definition in HU implicitly inline
According to [dcl.inline]p7/note4,

> In the global module, a function defined within a class definition is
> implicitly inline.

And the declarations in the header unit are attached to the global
module fragment. So the function defined within a class definition in
header units should be implicitly inline too.

This fixes https://github.com/llvm/llvm-project/issues/57571.
2022-09-13 13:11:56 +08:00

25 lines
666 B
C++

// Tests that the member function with-in an class definition in the header unit is still implicit inline.
// RUN: rm -rf %t
// RUN: split-file %s %t
//
// RUN: %clang_cc1 -std=c++20 -triple %itanium_abi_triple -xc++-user-header -emit-header-unit %t/foo.h -o %t/foo.pcm
// RUN: %clang_cc1 -std=c++20 -triple %itanium_abi_triple -fmodule-file=%t/foo.pcm %t/user.cpp \
// RUN: -S -emit-llvm -disable-llvm-passes -o - | FileCheck %t/user.cpp
//--- foo.h
class foo {
public:
int getValue() {
return 43;
}
};
//--- user.cpp
import "foo.h";
int use() {
foo f;
return f.getValue();
}
// CHECK: define{{.*}}linkonce_odr{{.*}}@_ZN3foo8getValueEv