xref: /llvm-project/clang/test/CodeGenCXX/header-unit-friend-within-class-linkage.cpp (revision 7c1d9b15eee3a34678addab2bab66f3020ac0753)
1 // Tests that the friend function with-in an class definition in the header unit is still implicit inline.
2 // RUN: rm -rf %t
3 // RUN: split-file %s %t
4 //
5 // RUN: %clang_cc1 -std=c++20 -triple %itanium_abi_triple -xc++-user-header -emit-header-unit %t/foo.h -o %t/foo.pcm
6 // RUN: %clang_cc1 -std=c++20 -triple %itanium_abi_triple -fmodule-file=%t/foo.pcm %t/user.cpp \
7 // RUN:   -emit-llvm -disable-llvm-passes -o - | FileCheck %t/user.cpp
8 
9 //--- foo.h
10 class foo {
11     int value;
12 public:
foo(int v)13     foo(int v) : value(v) {}
14 
getFooValue(foo f)15     friend int getFooValue(foo f) {
16         return f.value;
17     }
18 };
19 
20 //--- user.cpp
21 import "foo.h";
use()22 int use() {
23     foo f(43);
24     return getFooValue(f);
25 }
26 
27 // CHECK: define{{.*}}linkonce_odr{{.*}}@_Z11getFooValue3foo
28