xref: /llvm-project/clang/test/InterfaceStubs/class-template-specialization.cpp (revision e782192d5e6540b0cbb957a6b738d98e24c88ee3)
1 // REQUIRES: x86-registered-target
2 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -o - -emit-interface-stubs %s | \
3 // RUN: FileCheck -check-prefix=CHECK-TAPI %s
4 
5 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -o - -emit-interface-stubs %s | \
6 // RUN: FileCheck -check-prefix=CHECK-TAPI2 %s
7 
8 // RUN: %clang -target x86_64-unknown-linux-gnu -c -o - %s | llvm-readelf -s - 2>&1 | \
9 // RUN: FileCheck -check-prefix=CHECK-SYMBOLS %s
10 
11 // For the following:
12 // g()
13 // n::S<int>::S()
14 // n::S<int>::~S()
15 // n::S<int>::func() const
16 // n::S<int>::S(n::S<int> const&)
17 
18 // We expect these manglings:
19 // CHECK-TAPI: Symbols:
20 // CHECK-TAPI-NOT: _ZNK1n1SIiEclEv
21 // CHECK-TAPI2: Symbols:
22 // CHECK-TAPI2: _Z1g
23 
24 // CHECK-SYMBOLS-DAG: FUNC    GLOBAL DEFAULT    {{[0-9]}} _Z1g
25 // CHECK-SYMBOLS-DAG: FUNC    WEAK   HIDDEN     {{[0-9]}} _ZNK1n1SIiEclEv
26 
27 namespace n {
28 template <typename T>
29 struct __attribute__((__visibility__("default"))) S {
30   S() = default;
31   ~S() = default;
funcn::S32   int __attribute__((__visibility__(("default")))) func() const {
33     return 1844;
34   }
operator ()n::S35   int __attribute__((__visibility__(("hidden")))) operator()() const {
36     return 1863;
37   }
38 };
39 } // namespace n
40 
g()41 void g() { n::S<int>()(); }
42