llvm-project/clang/test/InterfaceStubs/template-namespace-function.cpp
Puyan Lotfi e3033c0ce5 [llvm][clang][IFS] Enhancing the llvm-ifs yaml format for symbol lists.
Prior to this change the clang interface stubs format resembled
something ending with a symbol list like this:

 Symbols:
   a: { Type: Func }

This was problematic because we didn't actually want a map format and
also because we didn't like that an empty symbol list required
"Symbols: {}". That is to say without the empty {} llvm-ifs would crash
on an empty list.

With this new format it is much more clear which field is the symbol
name, and instead the [] that is used to express an empty symbol vector
is optional, ie:

Symbols:
 - { Name: a, Type: Func }

or

Symbols: []

or

Symbols:

This further diverges the format from existing llvm-elftapi. This is a
good thing because although the format originally came from the same
place, they are not the same in any way.

Differential Revision: https://reviews.llvm.org/D76979
2020-04-01 10:49:06 -04:00

32 lines
982 B
C++

// REQUIRES: x86-registered-target
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -o - -emit-interface-stubs %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: - { Name: "_ZN3qux3barEii", Type: Func }
// CHECK-DAG: - { Name: "_ZN3baz3addIiEET_S1_S1_", Type: Func }
// CHECK-DAG: - { Name: "_Z4fbarff", Type: Func }
// CHECK-DAG: - { Name: "_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 <typename T>
T add(T a, T b) {
return a + b;
}
} // namespace baz
namespace qux {
int bar(int a, int b) { return baz::add<int>(a, b); }
} // namespace qux
float fbar(float a, float b) { return baz::add<float>(a, b); }