From 68f29dac4be8a9fc31533263c308252934d50a05 Mon Sep 17 00:00:00 2001 From: Puyan Lotfi Date: Thu, 20 Jun 2019 16:59:48 +0000 Subject: [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= -emit-interface-stubs \ -interface-stub-version= 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 --- .../InterfaceStubs/template-namespace-function.cpp | 31 ++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 clang/test/InterfaceStubs/template-namespace-function.cpp (limited to 'clang/test/InterfaceStubs/template-namespace-function.cpp') diff --git a/clang/test/InterfaceStubs/template-namespace-function.cpp b/clang/test/InterfaceStubs/template-namespace-function.cpp new file mode 100644 index 00000000000..879318122b0 --- /dev/null +++ b/clang/test/InterfaceStubs/template-namespace-function.cpp @@ -0,0 +1,31 @@ +// RUN: %clang -target x86_64-unknown-linux-gnu -o - -emit-interface-stubs \ +// RUN: -interface-stub-version=experimental-tapi-elf-v1 %s | \ +// RUN: FileCheck %s + +// RUN: %clang -target x86_64-unknown-linux-gnu -o - -c %s | llvm-nm - 2>&1 | \ +// RUN: FileCheck -check-prefix=CHECK-SYMBOLS %s + +// CHECK: Symbols: +// CHECK-DAG: _ZN3qux3barEii: { Type: Func } +// CHECK-DAG: _ZN3baz3addIiEET_S1_S1_: { Type: Func } +// CHECK-DAG: _Z4fbarff: { Type: Func } +// CHECK-DAG: _ZN3baz3addIfEET_S1_S1_: { Type: Func } + +// Same symbols just different order. +// CHECK-SYMBOLS-DAG: _Z4fbarff +// CHECK-SYMBOLS-DAG: _ZN3baz3addIfEET_S1_S1_ +// CHECK-SYMBOLS-DAG: _ZN3baz3addIiEET_S1_S1_ +// CHECK-SYMBOLS-DAG: _ZN3qux3barEii + +namespace baz { +template +T add(T a, T b) { + return a + b; +} +} // namespace baz + +namespace qux { +int bar(int a, int b) { return baz::add(a, b); } +} // namespace qux + +float fbar(float a, float b) { return baz::add(a, b); } -- cgit v1.2.3