@@ -99,6 +99,24 @@ class Template {
99
99
}
100
100
}
101
101
102
+ Template (const VarTemplatePartialSpecializationDecl *Decl) {
103
+ for (auto *const Parameter : *Decl->getTemplateParameters ()) {
104
+ const auto *Param = dyn_cast<TemplateTypeParmDecl>(Parameter);
105
+ if (!Param) // some params are null
106
+ continue ;
107
+ std::string Type;
108
+ if (Param->hasTypeConstraint ())
109
+ Type = Param->getTypeConstraint ()->getNamedConcept ()->getName ().str ();
110
+ else if (Param->wasDeclaredWithTypename ())
111
+ Type = " typename" ;
112
+ else
113
+ Type = " class" ;
114
+
115
+ addTemplateParameter (Type, Param->getName ().str (), Param->getIndex (),
116
+ Param->getDepth (), Param->isParameterPack ());
117
+ }
118
+ }
119
+
102
120
const llvm::SmallVector<TemplateParameter> &getParameters () const {
103
121
return Parameters;
104
122
}
@@ -141,6 +159,9 @@ struct APIRecord {
141
159
RK_Unknown,
142
160
RK_GlobalFunction,
143
161
RK_GlobalVariable,
162
+ RK_GlobalVariableTemplate,
163
+ RK_GlobalVariableTemplateSpecialization,
164
+ RK_GlobalVariableTemplatePartialSpecialization,
144
165
RK_EnumConstant,
145
166
RK_Enum,
146
167
RK_StructField,
@@ -275,6 +296,14 @@ struct GlobalVariableRecord : APIRecord {
275
296
Linkage, Comment, Declaration, SubHeading,
276
297
IsFromSystemHeader) {}
277
298
299
+ GlobalVariableRecord (RecordKind Kind, StringRef USR, StringRef Name,
300
+ PresumedLoc Loc, AvailabilitySet Availabilities,
301
+ LinkageInfo Linkage, const DocComment &Comment,
302
+ DeclarationFragments Declaration,
303
+ DeclarationFragments SubHeading, bool IsFromSystemHeader)
304
+ : APIRecord(Kind, USR, Name, Loc, std::move(Availabilities), Linkage,
305
+ Comment, Declaration, SubHeading, IsFromSystemHeader) {}
306
+
278
307
static bool classof (const APIRecord *Record) {
279
308
return Record->getKind () == RK_GlobalVariable;
280
309
}
@@ -283,6 +312,61 @@ struct GlobalVariableRecord : APIRecord {
283
312
virtual void anchor ();
284
313
};
285
314
315
+ struct GlobalVariableTemplateRecord : GlobalVariableRecord {
316
+ Template Templ;
317
+
318
+ GlobalVariableTemplateRecord (StringRef USR, StringRef Name, PresumedLoc Loc,
319
+ AvailabilitySet Availabilities,
320
+ LinkageInfo Linkage, const DocComment &Comment,
321
+ DeclarationFragments Declaration,
322
+ DeclarationFragments SubHeading,
323
+ class Template Template, bool IsFromSystemHeader)
324
+ : GlobalVariableRecord(RK_GlobalVariableTemplate, USR, Name, Loc,
325
+ std::move (Availabilities), Linkage, Comment,
326
+ Declaration, SubHeading, IsFromSystemHeader),
327
+ Templ(Template) {}
328
+
329
+ static bool classof (const APIRecord *Record) {
330
+ return Record->getKind () == RK_GlobalVariableTemplate;
331
+ }
332
+ };
333
+
334
+ struct GlobalVariableTemplateSpecializationRecord : GlobalVariableRecord {
335
+ GlobalVariableTemplateSpecializationRecord (
336
+ StringRef USR, StringRef Name, PresumedLoc Loc,
337
+ AvailabilitySet Availabilities, LinkageInfo Linkage,
338
+ const DocComment &Comment, DeclarationFragments Declaration,
339
+ DeclarationFragments SubHeading, bool IsFromSystemHeader)
340
+ : GlobalVariableRecord(RK_GlobalVariableTemplateSpecialization, USR, Name,
341
+ Loc, std::move(Availabilities), Linkage, Comment,
342
+ Declaration, SubHeading, IsFromSystemHeader) {}
343
+
344
+ static bool classof (const APIRecord *Record) {
345
+ return Record->getKind () == RK_GlobalVariableTemplateSpecialization;
346
+ }
347
+ };
348
+
349
+ struct GlobalVariableTemplatePartialSpecializationRecord
350
+ : GlobalVariableRecord {
351
+ Template Templ;
352
+
353
+ GlobalVariableTemplatePartialSpecializationRecord (
354
+ StringRef USR, StringRef Name, PresumedLoc Loc,
355
+ AvailabilitySet Availabilities, LinkageInfo Linkage,
356
+ const DocComment &Comment, DeclarationFragments Declaration,
357
+ DeclarationFragments SubHeading, class Template Template,
358
+ bool IsFromSystemHeader)
359
+ : GlobalVariableRecord(RK_GlobalVariableTemplatePartialSpecialization,
360
+ USR, Name, Loc, std::move(Availabilities), Linkage,
361
+ Comment, Declaration, SubHeading,
362
+ IsFromSystemHeader),
363
+ Templ (Template) {}
364
+
365
+ static bool classof (const APIRecord *Record) {
366
+ return Record->getKind () == RK_GlobalVariableTemplatePartialSpecialization;
367
+ }
368
+ };
369
+
286
370
// / This holds information associated with enum constants.
287
371
struct EnumConstantRecord : APIRecord {
288
372
EnumConstantRecord (StringRef USR, StringRef Name, PresumedLoc Loc,
@@ -778,6 +862,7 @@ struct ClassTemplatePartialSpecializationRecord : CXXClassRecord {
778
862
779
863
struct ConceptRecord : APIRecord {
780
864
Template Templ;
865
+
781
866
ConceptRecord (StringRef USR, StringRef Name, PresumedLoc Loc,
782
867
AvailabilitySet Availabilities, const DocComment &Comment,
783
868
DeclarationFragments Declaration,
@@ -787,10 +872,6 @@ struct ConceptRecord : APIRecord {
787
872
LinkageInfo::none (), Comment, Declaration, SubHeading,
788
873
IsFromSystemHeader),
789
874
Templ(Template) {}
790
-
791
- static bool classof (const APIRecord *Record) {
792
- return Record->getKind () == RK_Concept;
793
- }
794
875
};
795
876
796
877
// / This holds information associated with Objective-C categories.
@@ -932,6 +1013,11 @@ template <>
932
1013
struct has_template <ClassTemplatePartialSpecializationRecord>
933
1014
: public std::true_type {};
934
1015
template <> struct has_template <ConceptRecord> : public std::true_type {};
1016
+ template <>
1017
+ struct has_template <GlobalVariableTemplateRecord> : public std::true_type {};
1018
+ template <>
1019
+ struct has_template <GlobalVariableTemplatePartialSpecializationRecord>
1020
+ : public std::true_type {};
935
1021
936
1022
// / APISet holds the set of API records collected from given inputs.
937
1023
class APISet {
@@ -948,6 +1034,14 @@ class APISet {
948
1034
const DocComment &Comment, DeclarationFragments Declaration,
949
1035
DeclarationFragments SubHeadin, bool IsFromSystemHeaderg);
950
1036
1037
+ GlobalVariableTemplateRecord *
1038
+ addGlobalVariableTemplate (StringRef Name, StringRef USR, PresumedLoc Loc,
1039
+ AvailabilitySet Availability, LinkageInfo Linkage,
1040
+ const DocComment &Comment,
1041
+ DeclarationFragments Declaration,
1042
+ DeclarationFragments SubHeading, Template Template,
1043
+ bool IsFromSystemHeader);
1044
+
951
1045
// / Create and add a function record into the API set.
952
1046
// /
953
1047
// / Note: the caller is responsible for keeping the StringRef \p Name and
@@ -1050,6 +1144,21 @@ class APISet {
1050
1144
DeclarationFragments Declaration, DeclarationFragments SubHeading,
1051
1145
Template Template, bool IsFromSystemHeader);
1052
1146
1147
+ GlobalVariableTemplateSpecializationRecord *
1148
+ addGlobalVariableTemplateSpecialization (
1149
+ StringRef Name, StringRef USR, PresumedLoc Loc,
1150
+ AvailabilitySet Availability, LinkageInfo Linkage,
1151
+ const DocComment &Comment, DeclarationFragments Declaration,
1152
+ DeclarationFragments SubHeading, bool IsFromSystemHeader);
1153
+
1154
+ GlobalVariableTemplatePartialSpecializationRecord *
1155
+ addGlobalVariableTemplatePartialSpecialization (
1156
+ StringRef Name, StringRef USR, PresumedLoc Loc,
1157
+ AvailabilitySet Availability, LinkageInfo Linkage,
1158
+ const DocComment &Comment, DeclarationFragments Declaration,
1159
+ DeclarationFragments SubHeading, Template Template,
1160
+ bool IsFromSystemHeader);
1161
+
1053
1162
CXXMethodRecord *
1054
1163
addCXXMethod (CXXClassRecord *CXXClassRecord, StringRef Name, StringRef USR,
1055
1164
PresumedLoc Loc, AvailabilitySet Availability,
@@ -1193,9 +1302,21 @@ class APISet {
1193
1302
const RecordMap<GlobalVariableRecord> &getGlobalVariables () const {
1194
1303
return GlobalVariables;
1195
1304
}
1305
+ const RecordMap<GlobalVariableTemplateRecord> &
1306
+ getGlobalVariableTemplates () const {
1307
+ return GlobalVariableTemplates;
1308
+ }
1196
1309
const RecordMap<StaticFieldRecord> &getStaticFields () const {
1197
1310
return StaticFields;
1198
1311
}
1312
+ const RecordMap<GlobalVariableTemplateSpecializationRecord> &
1313
+ getGlobalVariableTemplateSpecializations () const {
1314
+ return GlobalVariableTemplateSpecializations;
1315
+ }
1316
+ const RecordMap<GlobalVariableTemplatePartialSpecializationRecord> &
1317
+ getGlobalVariableTemplatePartialSpecializations () const {
1318
+ return GlobalVariableTemplatePartialSpecializations;
1319
+ }
1199
1320
const RecordMap<EnumRecord> &getEnums () const { return Enums; }
1200
1321
const RecordMap<StructRecord> &getStructs () const { return Structs; }
1201
1322
const RecordMap<CXXClassRecord> &getCXXClasses () const { return CXXClasses; }
@@ -1265,6 +1386,11 @@ class APISet {
1265
1386
llvm::DenseMap<StringRef, APIRecord *> USRBasedLookupTable;
1266
1387
RecordMap<GlobalFunctionRecord> GlobalFunctions;
1267
1388
RecordMap<GlobalVariableRecord> GlobalVariables;
1389
+ RecordMap<GlobalVariableTemplateRecord> GlobalVariableTemplates;
1390
+ RecordMap<GlobalVariableTemplateSpecializationRecord>
1391
+ GlobalVariableTemplateSpecializations;
1392
+ RecordMap<GlobalVariableTemplatePartialSpecializationRecord>
1393
+ GlobalVariableTemplatePartialSpecializations;
1268
1394
RecordMap<ConceptRecord> Concepts;
1269
1395
RecordMap<StaticFieldRecord> StaticFields;
1270
1396
RecordMap<EnumRecord> Enums;
0 commit comments