1 | // RUN: c-index-test core -print-source-symbols -- %s -std=c++14 -target x86_64-apple-macosx10.7 | FileCheck %s |
2 | // References to declarations in instantiations should be canonicalized: |
3 | |
4 | template<typename T> |
5 | class BaseTemplate { |
6 | public: |
7 | T baseTemplateFunction(); |
8 | // CHECK: [[@LINE-1]]:5 | instance-method/C++ | baseTemplateFunction | c:@ST>1#T@BaseTemplate@F@baseTemplateFunction# |
9 | |
10 | T baseTemplateField; |
11 | // CHECK: [[@LINE-1]]:5 | field/C++ | baseTemplateField | c:@ST>1#T@BaseTemplate@FI@baseTemplateField |
12 | |
13 | struct NestedBaseType { }; |
14 | // CHECK: [[@LINE-1]]:10 | struct/C | NestedBaseType | c:@ST>1#T@BaseTemplate@S@NestedBaseType | |
15 | }; |
16 | |
17 | template<typename T, typename S> |
18 | class TemplateClass: public BaseTemplate<T> { |
19 | public: |
20 | T function() { return T(); } |
21 | // CHECK: [[@LINE-1]]:5 | instance-method/C++ | function | c:@ST>2#T#T@TemplateClass@F@function# |
22 | |
23 | static void staticFunction() { } |
24 | // CHECK: [[@LINE-1]]:15 | static-method/C++ | staticFunction | c:@ST>2#T#T@TemplateClass@F@staticFunction#S |
25 | |
26 | T field; |
27 | // CHECK: [[@LINE-1]]:5 | field/C++ | field | c:@ST>2#T#T@TemplateClass@FI@field |
28 | |
29 | struct NestedType { |
30 | // CHECK: [[@LINE-1]]:10 | struct/C++ | NestedType | c:@ST>2#T#T@TemplateClass@S@NestedType | |
31 | |
32 | T nestedField; |
33 | // CHECK: [[@LINE-1]]:7 | field/C++ | nestedField | c:@ST>2#T#T@TemplateClass@S@NestedType@FI@nestedField | |
34 | |
35 | class SubNestedType { |
36 | // CHECK: [[@LINE-1]]:11 | class/C++ | SubNestedType | c:@ST>2#T#T@TemplateClass@S@NestedType@S@SubNestedType | |
37 | public: |
38 | SubNestedType(int); |
39 | }; |
40 | using TypeAlias = T; |
41 | // CHECK: [[@LINE-1]]:11 | type-alias/C++ | TypeAlias | c:@ST>2#T#T@TemplateClass@S@NestedType@TypeAlias | |
42 | |
43 | typedef int Typedef; |
44 | // CHECK: [[@LINE-1]]:17 | type-alias/C | Typedef | c:{{.*}}index-instantiated-source.cpp@ST>2#T#T@TemplateClass@S@NestedType@T@Typedef | |
45 | |
46 | enum Enum { |
47 | // CHECK: [[@LINE-1]]:10 | enum/C | Enum | c:@ST>2#T#T@TemplateClass@S@NestedType@E@Enum | |
48 | EnumCase |
49 | // CHECK: [[@LINE-1]]:7 | enumerator/C | EnumCase | c:@ST>2#T#T@TemplateClass@S@NestedType@E@Enum@EnumCase | |
50 | }; |
51 | }; |
52 | }; |
53 | |
54 | void canonicalizeInstaniationReferences(TemplateClass<int, float> &object) { |
55 | (void)object.function(); |
56 | // CHECK: [[@LINE-1]]:16 | instance-method/C++ | function | c:@ST>2#T#T@TemplateClass@F@function# | <no-cgname> |
57 | (void)object.field; |
58 | // CHECK: [[@LINE-1]]:16 | field/C++ | field | c:@ST>2#T#T@TemplateClass@FI@field | <no-cgname> | Ref,RelCont | rel: 1 |
59 | (void)object.baseTemplateFunction(); |
60 | // CHECK: [[@LINE-1]]:16 | instance-method/C++ | baseTemplateFunction | c:@ST>1#T@BaseTemplate@F@baseTemplateFunction# | <no-cgname> |
61 | (void)object.baseTemplateField; |
62 | // CHECK: [[@LINE-1]]:16 | field/C++ | baseTemplateField | c:@ST>1#T@BaseTemplate@FI@baseTemplateField | <no-cgname> | Ref,RelCont | rel: 1 |
63 | |
64 | TemplateClass<int, float>::staticFunction(); |
65 | // CHECK: [[@LINE-1]]:30 | static-method/C++ | staticFunction | c:@ST>2#T#T@TemplateClass@F@staticFunction#S | <no-cgname |
66 | |
67 | TemplateClass<int, float>::NestedBaseType nestedBaseType; |
68 | // CHECK: [[@LINE-1]]:30 | struct/C | NestedBaseType | c:@ST>1#T@BaseTemplate@S@NestedBaseType | |
69 | TemplateClass<int, float>::NestedType nestedSubType; |
70 | // CHECK: [[@LINE-1]]:30 | struct/C++ | NestedType | c:@ST>2#T#T@TemplateClass@S@NestedType | |
71 | (void)nestedSubType.nestedField; |
72 | // CHECK: [[@LINE-1]]:23 | field/C++ | nestedField | c:@ST>2#T#T@TemplateClass@S@NestedType@FI@nestedField | |
73 | |
74 | typedef TemplateClass<int, float> TT; |
75 | TT::NestedType::SubNestedType subNestedType(0); |
76 | // CHECK: [[@LINE-1]]:7 | struct/C++ | NestedType | c:@ST>2#T#T@TemplateClass@S@NestedType | |
77 | // CHECK: [[@LINE-2]]:19 | class/C++ | SubNestedType | c:@ST>2#T#T@TemplateClass@S@NestedType@S@SubNestedType | |
78 | |
79 | TT::NestedType::TypeAlias nestedTypeAlias; |
80 | // CHECK: [[@LINE-1]]:19 | type-alias/C++ | TypeAlias | c:@ST>2#T#T@TemplateClass@S@NestedType@TypeAlias | |
81 | TT::NestedType::Typedef nestedTypedef; |
82 | // CHECK: [[@LINE-1]]:19 | type-alias/C | Typedef | c:{{.*}}index-instantiated-source.cpp@ST>2#T#T@TemplateClass@S@NestedType@T@Typedef | |
83 | |
84 | TT::NestedType::Enum nestedEnum; |
85 | // CHECK: [[@LINE-1]]:19 | enum/C | Enum | c:@ST>2#T#T@TemplateClass@S@NestedType@E@Enum | |
86 | (void)TT::NestedType::Enum::EnumCase; |
87 | // CHECK: [[@LINE-1]]:31 | enumerator/C | EnumCase | c:@ST>2#T#T@TemplateClass@S@NestedType@E@Enum@EnumCase | |
88 | } |
89 | |