@@ -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,
@@ -279,6 +300,14 @@ struct GlobalVariableRecord : APIRecord {
279
300
Linkage, Comment, Declaration, SubHeading,
280
301
IsFromSystemHeader) {}
281
302
303
+ GlobalVariableRecord (RecordKind Kind, StringRef USR, StringRef Name,
304
+ PresumedLoc Loc, AvailabilitySet Availabilities,
305
+ LinkageInfo Linkage, const DocComment &Comment,
306
+ DeclarationFragments Declaration,
307
+ DeclarationFragments SubHeading, bool IsFromSystemHeader)
308
+ : APIRecord(Kind, USR, Name, Loc, std::move(Availabilities), Linkage,
309
+ Comment, Declaration, SubHeading, IsFromSystemHeader) {}
310
+
282
311
static bool classof (const APIRecord *Record) {
283
312
return Record->getKind () == RK_GlobalVariable;
284
313
}
@@ -287,6 +316,61 @@ struct GlobalVariableRecord : APIRecord {
287
316
virtual void anchor ();
288
317
};
289
318
319
+ struct GlobalVariableTemplateRecord : GlobalVariableRecord {
320
+ Template Templ;
321
+
322
+ GlobalVariableTemplateRecord (StringRef USR, StringRef Name, PresumedLoc Loc,
323
+ AvailabilitySet Availabilities,
324
+ LinkageInfo Linkage, const DocComment &Comment,
325
+ DeclarationFragments Declaration,
326
+ DeclarationFragments SubHeading,
327
+ class Template Template, bool IsFromSystemHeader)
328
+ : GlobalVariableRecord(RK_GlobalVariableTemplate, USR, Name, Loc,
329
+ std::move (Availabilities), Linkage, Comment,
330
+ Declaration, SubHeading, IsFromSystemHeader),
331
+ Templ(Template) {}
332
+
333
+ static bool classof (const APIRecord *Record) {
334
+ return Record->getKind () == RK_GlobalVariableTemplate;
335
+ }
336
+ };
337
+
338
+ struct GlobalVariableTemplateSpecializationRecord : GlobalVariableRecord {
339
+ GlobalVariableTemplateSpecializationRecord (
340
+ StringRef USR, StringRef Name, PresumedLoc Loc,
341
+ AvailabilitySet Availabilities, LinkageInfo Linkage,
342
+ const DocComment &Comment, DeclarationFragments Declaration,
343
+ DeclarationFragments SubHeading, bool IsFromSystemHeader)
344
+ : GlobalVariableRecord(RK_GlobalVariableTemplateSpecialization, USR, Name,
345
+ Loc, std::move(Availabilities), Linkage, Comment,
346
+ Declaration, SubHeading, IsFromSystemHeader) {}
347
+
348
+ static bool classof (const APIRecord *Record) {
349
+ return Record->getKind () == RK_GlobalVariableTemplateSpecialization;
350
+ }
351
+ };
352
+
353
+ struct GlobalVariableTemplatePartialSpecializationRecord
354
+ : GlobalVariableRecord {
355
+ Template Templ;
356
+
357
+ GlobalVariableTemplatePartialSpecializationRecord (
358
+ StringRef USR, StringRef Name, PresumedLoc Loc,
359
+ AvailabilitySet Availabilities, LinkageInfo Linkage,
360
+ const DocComment &Comment, DeclarationFragments Declaration,
361
+ DeclarationFragments SubHeading, class Template Template,
362
+ bool IsFromSystemHeader)
363
+ : GlobalVariableRecord(RK_GlobalVariableTemplatePartialSpecialization,
364
+ USR, Name, Loc, std::move(Availabilities), Linkage,
365
+ Comment, Declaration, SubHeading,
366
+ IsFromSystemHeader),
367
+ Templ (Template) {}
368
+
369
+ static bool classof (const APIRecord *Record) {
370
+ return Record->getKind () == RK_GlobalVariableTemplatePartialSpecialization;
371
+ }
372
+ };
373
+
290
374
// / This holds information associated with enum constants.
291
375
struct EnumConstantRecord : APIRecord {
292
376
EnumConstantRecord (StringRef USR, StringRef Name, PresumedLoc Loc,
@@ -782,6 +866,7 @@ struct ClassTemplatePartialSpecializationRecord : CXXClassRecord {
782
866
783
867
struct ConceptRecord : APIRecord {
784
868
Template Templ;
869
+
785
870
ConceptRecord (StringRef USR, StringRef Name, PresumedLoc Loc,
786
871
AvailabilitySet Availabilities, const DocComment &Comment,
787
872
DeclarationFragments Declaration,
@@ -791,10 +876,6 @@ struct ConceptRecord : APIRecord {
791
876
LinkageInfo::none (), Comment, Declaration, SubHeading,
792
877
IsFromSystemHeader),
793
878
Templ(Template) {}
794
-
795
- static bool classof (const APIRecord *Record) {
796
- return Record->getKind () == RK_Concept;
797
- }
798
879
};
799
880
800
881
// / This holds information associated with Objective-C categories.
@@ -938,6 +1019,11 @@ template <>
938
1019
struct has_template <ClassTemplatePartialSpecializationRecord>
939
1020
: public std::true_type {};
940
1021
template <> struct has_template <ConceptRecord> : public std::true_type {};
1022
+ template <>
1023
+ struct has_template <GlobalVariableTemplateRecord> : public std::true_type {};
1024
+ template <>
1025
+ struct has_template <GlobalVariableTemplatePartialSpecializationRecord>
1026
+ : public std::true_type {};
941
1027
942
1028
// / APISet holds the set of API records collected from given inputs.
943
1029
class APISet {
@@ -954,6 +1040,14 @@ class APISet {
954
1040
const DocComment &Comment, DeclarationFragments Declaration,
955
1041
DeclarationFragments SubHeadin, bool IsFromSystemHeaderg);
956
1042
1043
+ GlobalVariableTemplateRecord *
1044
+ addGlobalVariableTemplate (StringRef Name, StringRef USR, PresumedLoc Loc,
1045
+ AvailabilitySet Availability, LinkageInfo Linkage,
1046
+ const DocComment &Comment,
1047
+ DeclarationFragments Declaration,
1048
+ DeclarationFragments SubHeading, Template Template,
1049
+ bool IsFromSystemHeader);
1050
+
957
1051
// / Create and add a function record into the API set.
958
1052
// /
959
1053
// / Note: the caller is responsible for keeping the StringRef \p Name and
@@ -1056,6 +1150,21 @@ class APISet {
1056
1150
DeclarationFragments Declaration, DeclarationFragments SubHeading,
1057
1151
Template Template, bool IsFromSystemHeader);
1058
1152
1153
+ GlobalVariableTemplateSpecializationRecord *
1154
+ addGlobalVariableTemplateSpecialization (
1155
+ StringRef Name, StringRef USR, PresumedLoc Loc,
1156
+ AvailabilitySet Availability, LinkageInfo Linkage,
1157
+ const DocComment &Comment, DeclarationFragments Declaration,
1158
+ DeclarationFragments SubHeading, bool IsFromSystemHeader);
1159
+
1160
+ GlobalVariableTemplatePartialSpecializationRecord *
1161
+ addGlobalVariableTemplatePartialSpecialization (
1162
+ StringRef Name, StringRef USR, PresumedLoc Loc,
1163
+ AvailabilitySet Availability, LinkageInfo Linkage,
1164
+ const DocComment &Comment, DeclarationFragments Declaration,
1165
+ DeclarationFragments SubHeading, Template Template,
1166
+ bool IsFromSystemHeader);
1167
+
1059
1168
CXXMethodRecord *
1060
1169
addCXXMethod (CXXClassRecord *CXXClassRecord, StringRef Name, StringRef USR,
1061
1170
PresumedLoc Loc, AvailabilitySet Availability,
@@ -1199,9 +1308,21 @@ class APISet {
1199
1308
const RecordMap<GlobalVariableRecord> &getGlobalVariables () const {
1200
1309
return GlobalVariables;
1201
1310
}
1311
+ const RecordMap<GlobalVariableTemplateRecord> &
1312
+ getGlobalVariableTemplates () const {
1313
+ return GlobalVariableTemplates;
1314
+ }
1202
1315
const RecordMap<StaticFieldRecord> &getStaticFields () const {
1203
1316
return StaticFields;
1204
1317
}
1318
+ const RecordMap<GlobalVariableTemplateSpecializationRecord> &
1319
+ getGlobalVariableTemplateSpecializations () const {
1320
+ return GlobalVariableTemplateSpecializations;
1321
+ }
1322
+ const RecordMap<GlobalVariableTemplatePartialSpecializationRecord> &
1323
+ getGlobalVariableTemplatePartialSpecializations () const {
1324
+ return GlobalVariableTemplatePartialSpecializations;
1325
+ }
1205
1326
const RecordMap<EnumRecord> &getEnums () const { return Enums; }
1206
1327
const RecordMap<StructRecord> &getStructs () const { return Structs; }
1207
1328
const RecordMap<CXXClassRecord> &getCXXClasses () const { return CXXClasses; }
@@ -1271,6 +1392,11 @@ class APISet {
1271
1392
llvm::DenseMap<StringRef, APIRecord *> USRBasedLookupTable;
1272
1393
RecordMap<GlobalFunctionRecord> GlobalFunctions;
1273
1394
RecordMap<GlobalVariableRecord> GlobalVariables;
1395
+ RecordMap<GlobalVariableTemplateRecord> GlobalVariableTemplates;
1396
+ RecordMap<GlobalVariableTemplateSpecializationRecord>
1397
+ GlobalVariableTemplateSpecializations;
1398
+ RecordMap<GlobalVariableTemplatePartialSpecializationRecord>
1399
+ GlobalVariableTemplatePartialSpecializations;
1274
1400
RecordMap<ConceptRecord> Concepts;
1275
1401
RecordMap<StaticFieldRecord> StaticFields;
1276
1402
RecordMap<EnumRecord> Enums;
0 commit comments