xref: /llvm-project/clang/test/InterfaceStubs/virtual.cpp (revision e782192d5e6540b0cbb957a6b738d98e24c88ee3)
1678e19d8SPuyan Lotfi // REQUIRES: x86-registered-target
2*e782192dSPuyan Lotfi // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -o - -emit-interface-stubs %s | \
368f29dacSPuyan Lotfi // RUN: FileCheck -check-prefix=CHECK-TAPI %s
4*e782192dSPuyan Lotfi // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -o - -emit-interface-stubs %s | \
568f29dacSPuyan Lotfi // RUN: FileCheck -check-prefix=CHECK-TAPI2 %s
668f29dacSPuyan Lotfi // RUN: %clang -target x86_64-unknown-linux-gnu -o - -c %s | \
768f29dacSPuyan Lotfi // RUN: llvm-readelf -s - 2>&1 | FileCheck -check-prefix=CHECK-SYMBOLS %s
868f29dacSPuyan Lotfi 
968f29dacSPuyan Lotfi #define HIDDEN  __attribute__((__visibility__(("hidden"))))
1068f29dacSPuyan Lotfi #define DEFAULT __attribute__((__visibility__(("default"))))
1168f29dacSPuyan Lotfi 
1268f29dacSPuyan Lotfi // CHECK-TAPI-NOT: _ZNK1Q5func1Ev
1368f29dacSPuyan Lotfi // CHECK-TAPI-NOT: _ZNK1Q5func2Ev
1468f29dacSPuyan Lotfi // CHECK-SYMBOLS-DAG: NOTYPE  GLOBAL HIDDEN   {{.*}} _ZNK1Q5func1Ev
1568f29dacSPuyan Lotfi // CHECK-SYMBOLS-DAG: NOTYPE  GLOBAL DEFAULT  {{.*}} _ZNK1Q5func2Ev
1668f29dacSPuyan Lotfi struct Q {
1768f29dacSPuyan Lotfi   virtual HIDDEN  int func1() const;
1868f29dacSPuyan Lotfi   virtual DEFAULT int func2() const;
1968f29dacSPuyan Lotfi } q;
2068f29dacSPuyan Lotfi 
2168f29dacSPuyan Lotfi // CHECK-TAPI-NOT: _ZNK1S5func1Ev
2268f29dacSPuyan Lotfi // CHECK-TAPI2-DAG: _ZNK1S5func2Ev
2368f29dacSPuyan Lotfi // CHECK-SYMBOLS-DAG: FUNC    WEAK   HIDDEN   {{.*}} _ZNK1S5func1Ev
2468f29dacSPuyan Lotfi // CHECK-SYMBOLS-DAG: FUNC    WEAK   DEFAULT  {{.*}} _ZNK1S5func2Ev
2568f29dacSPuyan Lotfi struct S {
func1S2668f29dacSPuyan Lotfi   virtual HIDDEN  int func1() const { return 42; }
func2S2768f29dacSPuyan Lotfi   virtual DEFAULT int func2() const { return 42; }
2868f29dacSPuyan Lotfi } s;
2968f29dacSPuyan Lotfi 
3068f29dacSPuyan Lotfi // CHECK-TAPI-NOT: _ZNK1R5func1Ev
3168f29dacSPuyan Lotfi // CHECK-TAPI-NOT: _ZNK1R5func2Ev
3268f29dacSPuyan Lotfi // CHECK-SYMBOLS-NOT: _ZNK1R5func1Ev
3368f29dacSPuyan Lotfi // CHECK-SYMBOLS-NOT: _ZNK1R5func2Ev
3468f29dacSPuyan Lotfi struct R {
3568f29dacSPuyan Lotfi   virtual HIDDEN  int func1() const = 0;
3668f29dacSPuyan Lotfi   virtual DEFAULT int func2() const = 0;
3768f29dacSPuyan Lotfi };
3868f29dacSPuyan Lotfi 
3968f29dacSPuyan Lotfi int a = q.func1() + q.func2();
4068f29dacSPuyan Lotfi 
41