llvm-project/clang/test/InterfaceStubs/virtual.cpp

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

41 lines
1.4 KiB
C++
Raw Normal View History

// REQUIRES: x86-registered-target
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -o - -emit-interface-stubs %s | \
[clang-ifs] Clang Interface Stubs, first version (second landing attempt). This change reverts r363649; effectively re-landing r363626. At this point clang::Index::CodegenNameGeneratorImpl has been refactored into clang::AST::ASTNameGenerator. This makes it so that the previous circular link dependency no longer exists, fixing the previous share lib (-DBUILD_SHARED_LIBS=ON) build issue which was the reason for r363649. Clang interface stubs (previously referred to as clang-ifsos) is a new frontend action in clang that allows the generation of stub files that contain mangled name info that can be used to produce a stub library. These stub libraries can be useful for breaking up build dependencies and controlling access to a library's internal symbols. Generation of these stubs can be invoked by: clang -fvisibility=<visibility> -emit-interface-stubs \ -interface-stub-version=<interface format> Notice that -fvisibility (along with use of visibility attributes) can be used to control what symbols get generated. Currently the interface format is experimental but there are a wide range of possibilities here. Currently clang-ifs produces .ifs files that can be thought of as analogous to object (.o) files, but just for the mangled symbol info. In a subsequent patch I intend to add support for merging the .ifs files into one .ifs/.ifso file that can be the input to something like llvm-elfabi to produce something like a .so file or .dll (but without any of the code, just symbols). Differential Revision: https://reviews.llvm.org/D60974 llvm-svn: 363948
2019-06-21 00:59:48 +08:00
// RUN: FileCheck -check-prefix=CHECK-TAPI %s
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -o - -emit-interface-stubs %s | \
[clang-ifs] Clang Interface Stubs, first version (second landing attempt). This change reverts r363649; effectively re-landing r363626. At this point clang::Index::CodegenNameGeneratorImpl has been refactored into clang::AST::ASTNameGenerator. This makes it so that the previous circular link dependency no longer exists, fixing the previous share lib (-DBUILD_SHARED_LIBS=ON) build issue which was the reason for r363649. Clang interface stubs (previously referred to as clang-ifsos) is a new frontend action in clang that allows the generation of stub files that contain mangled name info that can be used to produce a stub library. These stub libraries can be useful for breaking up build dependencies and controlling access to a library's internal symbols. Generation of these stubs can be invoked by: clang -fvisibility=<visibility> -emit-interface-stubs \ -interface-stub-version=<interface format> Notice that -fvisibility (along with use of visibility attributes) can be used to control what symbols get generated. Currently the interface format is experimental but there are a wide range of possibilities here. Currently clang-ifs produces .ifs files that can be thought of as analogous to object (.o) files, but just for the mangled symbol info. In a subsequent patch I intend to add support for merging the .ifs files into one .ifs/.ifso file that can be the input to something like llvm-elfabi to produce something like a .so file or .dll (but without any of the code, just symbols). Differential Revision: https://reviews.llvm.org/D60974 llvm-svn: 363948
2019-06-21 00:59:48 +08:00
// RUN: FileCheck -check-prefix=CHECK-TAPI2 %s
// RUN: %clang -target x86_64-unknown-linux-gnu -o - -c %s | \
// RUN: llvm-readelf -s - 2>&1 | FileCheck -check-prefix=CHECK-SYMBOLS %s
#define HIDDEN __attribute__((__visibility__(("hidden"))))
#define DEFAULT __attribute__((__visibility__(("default"))))
// CHECK-TAPI-NOT: _ZNK1Q5func1Ev
// CHECK-TAPI-NOT: _ZNK1Q5func2Ev
// CHECK-SYMBOLS-DAG: NOTYPE GLOBAL HIDDEN {{.*}} _ZNK1Q5func1Ev
// CHECK-SYMBOLS-DAG: NOTYPE GLOBAL DEFAULT {{.*}} _ZNK1Q5func2Ev
struct Q {
virtual HIDDEN int func1() const;
virtual DEFAULT int func2() const;
} q;
// CHECK-TAPI-NOT: _ZNK1S5func1Ev
// CHECK-TAPI2-DAG: _ZNK1S5func2Ev
// CHECK-SYMBOLS-DAG: FUNC WEAK HIDDEN {{.*}} _ZNK1S5func1Ev
// CHECK-SYMBOLS-DAG: FUNC WEAK DEFAULT {{.*}} _ZNK1S5func2Ev
struct S {
virtual HIDDEN int func1() const { return 42; }
virtual DEFAULT int func2() const { return 42; }
} s;
// CHECK-TAPI-NOT: _ZNK1R5func1Ev
// CHECK-TAPI-NOT: _ZNK1R5func2Ev
// CHECK-SYMBOLS-NOT: _ZNK1R5func1Ev
// CHECK-SYMBOLS-NOT: _ZNK1R5func2Ev
struct R {
virtual HIDDEN int func1() const = 0;
virtual DEFAULT int func2() const = 0;
};
int a = q.func1() + q.func2();