Debian Codegraph @

clang/test/CodeGenCXX/function-template-specialization.cpp

raw
1 // RUN: %clang_cc1 -emit-llvm -Wundefined-func-template -verify -triple %itanium_abi_triple %s -o - | FileCheck %s
2 // expected-no-diagnostics
3
4 // CHECK-DAG: _ZZN7PR219047GetDataIiEERKibE1i = internal global i32 4
5 // CHECK-DAG: _ZZN7PR219047GetDataIiEERKibE1i_0 = internal global i32 2
6
7 template<typename T, typename U>
8 T* next(T* ptr, const U& diff);
9
10 template<typename T, typename U>
11 T* next(T* ptr, const U& diff) {
12 return ptr + diff;
13 }
14
15 void test(int *iptr, float *fptr, int diff) {
16 // CHECK: _Z4nextIiiEPT_S1_RKT0_
17 iptr = next(iptr, diff);
18
19 // CHECK: _Z4nextIfiEPT_S1_RKT0_
20 fptr = next(fptr, diff);
21 }
22
23 template<typename T, typename U>
24 T* next(T* ptr, const U& diff);
25
26 void test2(int *iptr, double *dptr, int diff) {
27 iptr = next(iptr, diff);
28
29 // CHECK: _Z4nextIdiEPT_S1_RKT0_
30 dptr = next(dptr, diff);
31 }
32
33 namespace PR21904 {
34 template <typename>
35 const int &GetData(bool);
36
37 template <>
38 const int &GetData<int>(bool b) {
39 static int i = 4;
40 if (b) {
41 static int i = 2;
42 return i;
43 }
44 return i;
45 }
46 }
47
48 namespace GH125747 {
49
50 template<typename F> constexpr int visit(F f) { return f(0); }
51
52 template <class T> int G(T t);
53
54 int main() { return visit([](auto s) -> int { return G(s); }); }
55
56 template <class T> int G(T t) {
57 return 0;
58 }
59
60 // CHECK: define {{.*}} @_ZN8GH1257471GIiEEiT_
61
62 }