clang 19.0.0git
API.h
Go to the documentation of this file.
1//===- ExtractAPI/API.h -----------------------------------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8///
9/// \file
10/// This file defines the APIRecord-based structs and the APISet class.
11///
12/// Clang ExtractAPI is a tool to collect API information from a given set of
13/// header files. The structures in this file describe data representations of
14/// the API information collected for various kinds of symbols.
15///
16//===----------------------------------------------------------------------===//
17
18#ifndef LLVM_CLANG_EXTRACTAPI_API_H
19#define LLVM_CLANG_EXTRACTAPI_API_H
20
22#include "clang/AST/Decl.h"
23#include "clang/AST/DeclBase.h"
24#include "clang/AST/DeclObjC.h"
29#include "llvm/ADT/ArrayRef.h"
30#include "llvm/ADT/MapVector.h"
31#include "llvm/ADT/StringRef.h"
32#include "llvm/Support/Allocator.h"
33#include "llvm/Support/Casting.h"
34#include "llvm/Support/Compiler.h"
35#include "llvm/Support/ErrorHandling.h"
36#include "llvm/Support/raw_ostream.h"
37#include "llvm/TargetParser/Triple.h"
38#include <cstddef>
39#include <iterator>
40#include <memory>
41#include <optional>
42#include <type_traits>
43
44namespace clang {
45namespace extractapi {
46
47class Template {
48 struct TemplateParameter {
49 // "class", "typename", or concept name
50 std::string Type;
51 std::string Name;
52 unsigned int Index;
53 unsigned int Depth;
54 bool IsParameterPack;
55
56 TemplateParameter(std::string Type, std::string Name, unsigned int Index,
57 unsigned int Depth, bool IsParameterPack)
58 : Type(Type), Name(Name), Index(Index), Depth(Depth),
59 IsParameterPack(IsParameterPack) {}
60 };
61
62 struct TemplateConstraint {
63 // type name of the constraint, if it has one
64 std::string Type;
65 std::string Kind;
66 std::string LHS, RHS;
67 };
70
71public:
72 Template() = default;
73
75 for (auto *const Parameter : *Decl->getTemplateParameters()) {
76 const auto *Param = dyn_cast<TemplateTypeParmDecl>(Parameter);
77 if (!Param) // some params are null
78 continue;
79 std::string Type;
80 if (Param->hasTypeConstraint())
81 Type = Param->getTypeConstraint()->getNamedConcept()->getName().str();
82 else if (Param->wasDeclaredWithTypename())
83 Type = "typename";
84 else
85 Type = "class";
86
87 addTemplateParameter(Type, Param->getName().str(), Param->getIndex(),
88 Param->getDepth(), Param->isParameterPack());
89 }
90 }
91
93 for (auto *const Parameter : *Decl->getTemplateParameters()) {
94 const auto *Param = dyn_cast<TemplateTypeParmDecl>(Parameter);
95 if (!Param) // some params are null
96 continue;
97 std::string Type;
98 if (Param->hasTypeConstraint())
99 Type = Param->getTypeConstraint()->getNamedConcept()->getName().str();
100 else if (Param->wasDeclaredWithTypename())
101 Type = "typename";
102 else
103 Type = "class";
104
105 addTemplateParameter(Type, Param->getName().str(), Param->getIndex(),
106 Param->getDepth(), Param->isParameterPack());
107 }
108 }
109
111 for (auto *const Parameter : *Decl->getTemplateParameters()) {
112 const auto *Param = dyn_cast<TemplateTypeParmDecl>(Parameter);
113 if (!Param) // some params are null
114 continue;
115 std::string Type;
116 if (Param->hasTypeConstraint())
117 Type = Param->getTypeConstraint()->getNamedConcept()->getName().str();
118 else if (Param->wasDeclaredWithTypename())
119 Type = "typename";
120 else
121 Type = "class";
122
123 addTemplateParameter(Type, Param->getName().str(), Param->getIndex(),
124 Param->getDepth(), Param->isParameterPack());
125 }
126 }
127
129 return Parameters;
130 }
131
133 return Constraints;
134 }
135
136 void addTemplateParameter(std::string Type, std::string Name,
137 unsigned int Index, unsigned int Depth,
138 bool IsParameterPack) {
139 Parameters.emplace_back(Type, Name, Index, Depth, IsParameterPack);
140 }
141
142 bool empty() const { return Parameters.empty() && Constraints.empty(); }
143};
144
145/// DocComment is a vector of RawComment::CommentLine.
146///
147/// Each line represents one line of striped documentation comment,
148/// with source range information. This simplifies calculating the source
149/// location of a character in the doc comment for pointing back to the source
150/// file.
151/// e.g.
152/// \code
153/// /// This is a documentation comment
154/// ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~' First line.
155/// /// with multiple lines.
156/// ^~~~~~~~~~~~~~~~~~~~~~~' Second line.
157/// \endcode
158using DocComment = std::vector<RawComment::CommentLine>;
159
160struct APIRecord;
161
162// This represents a reference to another symbol that might come from external
163/// sources.
165 StringRef Name;
166 StringRef USR;
167
168 /// The source project/module/product of the referred symbol.
169 StringRef Source;
170
171 // A Pointer to the APIRecord for this reference if known
172 const APIRecord *Record = nullptr;
173
174 SymbolReference() = default;
175 SymbolReference(StringRef Name, StringRef USR, StringRef Source = "")
176 : Name(Name), USR(USR), Source(Source) {}
177 SymbolReference(const APIRecord *R);
178
179 /// Determine if this SymbolReference is empty.
180 ///
181 /// \returns true if and only if all \c Name, \c USR, and \c Source is empty.
182 bool empty() const { return Name.empty() && USR.empty() && Source.empty(); }
183};
184
185class RecordContext;
186
187// Concrete classes deriving from APIRecord need to have a construct with first
188// arguments USR, and Name, in that order. This is so that they
189// are compatible with `APISet::createRecord`.
190// When adding a new kind of record don't forget to update APIRecords.inc!
191/// The base representation of an API record. Holds common symbol information.
192struct APIRecord {
193 /// Discriminator for LLVM-style RTTI (dyn_cast<> et al.)
196 // If adding a record context record kind here make sure to update
197 // RecordContext::classof if needed and add a RECORD_CONTEXT entry to
198 // APIRecords.inc
239 };
240
241 StringRef USR;
242 StringRef Name;
243
245
249
250 /// Documentation comment lines attached to this symbol declaration.
252
253 /// Declaration fragments of this symbol declaration.
255
256 /// SubHeading provides a more detailed representation than the plain
257 /// declaration name.
258 ///
259 /// SubHeading is an array of declaration fragments of tagged declaration
260 /// name, with potentially more tokens (for example the \c +/- symbol for
261 /// Objective-C class/instance methods).
263
264 /// Whether the symbol was defined in a system header.
266
268
270
271private:
272 const RecordKind Kind;
273 friend class RecordContext;
274 // Used to store the next child record in RecordContext. This works because
275 // APIRecords semantically only have one parent.
276 mutable APIRecord *NextInContext = nullptr;
277
278public:
279 APIRecord *getNextInContext() const { return NextInContext; }
280
281 RecordKind getKind() const { return Kind; }
283
286
287 APIRecord() = delete;
288
289 APIRecord(RecordKind Kind, StringRef USR, StringRef Name,
295 : USR(USR), Name(Name), Parent(std::move(Parent)), Location(Location),
300
301 APIRecord(RecordKind Kind, StringRef USR, StringRef Name)
303
304 // Pure virtual destructor to make APIRecord abstract
305 virtual ~APIRecord() = 0;
306 static bool classof(const APIRecord *Record) { return true; }
307 static bool classofKind(RecordKind K) { return true; }
308 static bool classof(const RecordContext *Ctx) { return true; }
309};
310
311/// Base class used for specific record types that have children records this is
312/// analogous to the DeclContext for the AST
314public:
315 static bool classof(const APIRecord *Record) {
316 return classofKind(Record->getKind());
317 }
321 }
322
323 static bool classof(const RecordContext *Context) { return true; }
324
326
327 /// Append \p Other children chain into ours and empty out Other's record
328 /// chain.
330
331 APIRecord::RecordKind getKind() const { return Kind; }
332
334 private:
335 APIRecord *Current = nullptr;
336
337 public:
339 using reference = const value_type &;
340 using pointer = const value_type *;
341 using iterator_category = std::forward_iterator_tag;
342 using difference_type = std::ptrdiff_t;
343
344 record_iterator() = default;
345 explicit record_iterator(value_type R) : Current(R) {}
346 reference operator*() const { return Current; }
347 // This doesn't strictly meet the iterator requirements, but it's the
348 // behavior we want here.
349 value_type operator->() const { return Current; }
351 Current = Current->getNextInContext();
352 return *this;
353 }
355 record_iterator tmp(*this);
356 ++(*this);
357 return tmp;
358 }
359
361 return x.Current == y.Current;
362 }
364 return x.Current != y.Current;
365 }
366 };
367
368 using record_range = llvm::iterator_range<record_iterator>;
371 }
374 bool records_empty() const { return First == nullptr; };
375
376private:
378 mutable APIRecord *First = nullptr;
379 mutable APIRecord *Last = nullptr;
380 bool IsWellFormed() const;
381
382protected:
383 friend class APISet;
384 void addToRecordChain(APIRecord *) const;
385};
386
397
398 static bool classof(const APIRecord *Record) {
399 return classofKind(Record->getKind());
400 }
401 static bool classofKind(RecordKind K) { return K == RK_Namespace; }
402};
403
404/// This holds information associated with global functions.
407
418
419 GlobalFunctionRecord(RecordKind Kind, StringRef USR, StringRef Name,
422 const DocComment &Comment,
426 : APIRecord(Kind, USR, Name, Parent, Loc, std::move(Availability),
430
431 static bool classof(const APIRecord *Record) {
432 return classofKind(Record->getKind());
433 }
434 static bool classofKind(RecordKind K) { return K == RK_GlobalFunction; }
435
436private:
437 virtual void anchor();
438};
439
442
455 Templ(Template) {}
456
457 static bool classof(const APIRecord *Record) {
458 return classofKind(Record->getKind());
459 }
460 static bool classofKind(RecordKind K) {
461 return K == RK_GlobalFunctionTemplate;
462 }
463};
464
467 StringRef USR, StringRef Name, SymbolReference Parent, PresumedLoc Loc,
476
477 static bool classof(const APIRecord *Record) {
478 return classofKind(Record->getKind());
479 }
480 static bool classofKind(RecordKind K) {
482 }
483};
484
485/// This holds information associated with global functions.
496
497 GlobalVariableRecord(RecordKind Kind, StringRef USR, StringRef Name,
500 const DocComment &Comment,
503 : APIRecord(Kind, USR, Name, Parent, Loc, std::move(Availability),
506 RecordContext(Kind) {}
507
508 static bool classof(const APIRecord *Record) {
509 return classofKind(Record->getKind());
510 }
511 static bool classofKind(RecordKind K) {
512 return K == RK_GlobalVariable || K == RK_GlobalVariableTemplate ||
515 }
516
517private:
518 virtual void anchor();
519};
520
523
534 Templ(Template) {}
535
536 static bool classof(const APIRecord *Record) {
537 return classofKind(Record->getKind());
538 }
539 static bool classofKind(RecordKind K) {
540 return K == RK_GlobalVariableTemplate;
541 }
542};
543
546 StringRef USR, StringRef Name, SymbolReference Parent, PresumedLoc Loc,
554
555 static bool classof(const APIRecord *Record) {
556 return classofKind(Record->getKind());
557 }
558 static bool classofKind(RecordKind K) {
560 }
561};
562
566
568 StringRef USR, StringRef Name, SymbolReference Parent, PresumedLoc Loc,
574 USR, Name, Parent, Loc, std::move(Availability),
577 Templ(Template) {}
578
579 static bool classof(const APIRecord *Record) {
580 return classofKind(Record->getKind());
581 }
582 static bool classofKind(RecordKind K) {
584 }
585};
586
587/// This holds information associated with enum constants.
591 const DocComment &Comment,
595 std::move(Availability), LinkageInfo::none(), Comment,
597
598 static bool classof(const APIRecord *Record) {
599 return classofKind(Record->getKind());
600 }
601 static bool classofKind(RecordKind K) { return K == RK_EnumConstant; }
602
603private:
604 virtual void anchor();
605};
606
608 TagRecord(RecordKind Kind, StringRef USR, StringRef Name,
614 : APIRecord(Kind, USR, Name, Parent, Loc, std::move(Availability),
617 RecordContext(Kind),
619
620 static bool classof(const APIRecord *Record) {
621 return classofKind(Record->getKind());
622 }
623 static bool classofKind(RecordKind K) {
624 return K == RK_Struct || K == RK_Union || K == RK_Enum;
625 }
626
628
629 virtual ~TagRecord() = 0;
630};
631
632/// This holds information associated with enums.
634 EnumRecord(StringRef USR, StringRef Name, SymbolReference Parent,
643
644 static bool classof(const APIRecord *Record) {
645 return classofKind(Record->getKind());
646 }
647
648 static bool classofKind(RecordKind K) { return K == RK_Enum; }
649
650private:
651 virtual void anchor();
652};
653
654/// This holds information associated with struct or union fields fields.
656 RecordFieldRecord(RecordKind Kind, StringRef USR, StringRef Name,
661 : APIRecord(Kind, USR, Name, Parent, Loc, std::move(Availability),
664 RecordContext(Kind) {}
665
666 static bool classof(const APIRecord *Record) {
667 return classofKind(Record->getKind());
668 }
669 static bool classofKind(RecordKind K) {
670 return K == RK_StructField || K == RK_UnionField;
671 }
672
673 virtual ~RecordFieldRecord() = 0;
674};
675
676/// This holds information associated with structs and unions.
678 RecordRecord(RecordKind Kind, StringRef USR, StringRef Name,
685 : TagRecord(Kind, USR, Name, Parent, Loc, std::move(Availability),
688
689 static bool classof(const APIRecord *Record) {
690 return classofKind(Record->getKind());
691 }
692 static bool classofKind(RecordKind K) {
693 return K == RK_Struct || K == RK_Union;
694 }
695
696 bool isAnonymousWithNoTypedef() { return Name.empty(); }
697
698 virtual ~RecordRecord() = 0;
699};
700
709
710 static bool classof(const APIRecord *Record) {
711 return classofKind(Record->getKind());
712 }
713 static bool classofKind(RecordKind K) { return K == RK_StructField; }
714
715private:
716 virtual void anchor();
717};
718
728
729 static bool classof(const APIRecord *Record) {
730 return classofKind(Record->getKind());
731 }
732 static bool classofKind(RecordKind K) { return K == RK_Struct; }
733
734private:
735 virtual void anchor();
736};
737
746
747 static bool classof(const APIRecord *Record) {
748 return classofKind(Record->getKind());
749 }
750 static bool classofKind(RecordKind K) { return K == RK_UnionField; }
751
752private:
753 virtual void anchor();
754};
755
765
766 static bool classof(const APIRecord *Record) {
767 return classofKind(Record->getKind());
768 }
769 static bool classofKind(RecordKind K) { return K == RK_Union; }
770
771private:
772 virtual void anchor();
773};
774
785
786 CXXFieldRecord(RecordKind Kind, StringRef USR, StringRef Name,
792 : APIRecord(Kind, USR, Name, Parent, Loc, std::move(Availability),
795 RecordContext(Kind) {}
796
797 static bool classof(const APIRecord *Record) {
798 return classofKind(Record->getKind());
799 }
800 static bool classofKind(RecordKind K) {
801 return K == RK_CXXField || K == RK_CXXFieldTemplate || K == RK_StaticField;
802 }
803
804private:
805 virtual void anchor();
806};
807
810
813 const DocComment &Comment,
820 Templ(Template) {}
821
822 static bool classof(const APIRecord *Record) {
823 return classofKind(Record->getKind());
824 }
825 static bool classofKind(RecordKind K) { return K == RK_CXXFieldTemplate; }
826};
827
830
831 CXXMethodRecord() = delete;
832
833 CXXMethodRecord(RecordKind Kind, StringRef USR, StringRef Name,
839 : APIRecord(Kind, USR, Name, Parent, Loc, std::move(Availability),
843
844 virtual ~CXXMethodRecord() = 0;
845};
846
850 const DocComment &Comment,
859 static bool classof(const APIRecord *Record) {
860 return classofKind(Record->getKind());
861 }
862 static bool classofKind(RecordKind K) { return K == RK_CXXConstructorMethod; }
863
864private:
865 virtual void anchor();
866};
867
871 const DocComment &Comment,
880 static bool classof(const APIRecord *Record) {
881 return classofKind(Record->getKind());
882 }
883 static bool classofKind(RecordKind K) { return K == RK_CXXDestructorMethod; }
884
885private:
886 virtual void anchor();
887};
888
892 const DocComment &Comment,
901 static bool classof(const APIRecord *Record) {
902 return classofKind(Record->getKind());
903 }
904 static bool classofKind(RecordKind K) { return K == RK_CXXStaticMethod; }
905
906private:
907 virtual void anchor();
908};
909
913 const DocComment &Comment,
922
923 static bool classof(const APIRecord *Record) {
924 return classofKind(Record->getKind());
925 }
926 static bool classofKind(RecordKind K) { return K == RK_CXXInstanceMethod; }
927
928private:
929 virtual void anchor();
930};
931
934
937 const DocComment &Comment,
946 Templ(Template) {}
947
948 static bool classof(const APIRecord *Record) {
949 return classofKind(Record->getKind());
950 }
951 static bool classofKind(RecordKind K) { return K == RK_CXXMethodTemplate; }
952};
953
956 StringRef USR, StringRef Name, SymbolReference Parent, PresumedLoc Loc,
965
966 static bool classof(const APIRecord *Record) {
967 return classofKind(Record->getKind());
968 }
969 static bool classofKind(RecordKind K) {
971 }
972};
973
974/// This holds information associated with Objective-C properties.
976 /// The attributes associated with an Objective-C property.
977 enum AttributeKind : unsigned {
980 Dynamic = 1 << 2,
981 };
982
984 StringRef GetterName;
985 StringRef SetterName;
987
988 ObjCPropertyRecord(RecordKind Kind, StringRef USR, StringRef Name,
993 StringRef GetterName, StringRef SetterName,
995 : APIRecord(Kind, USR, Name, Parent, Loc, std::move(Availability),
1000
1001 bool isReadOnly() const { return Attributes & ReadOnly; }
1002 bool isDynamic() const { return Attributes & Dynamic; }
1003
1004 virtual ~ObjCPropertyRecord() = 0;
1005};
1006
1009 StringRef USR, StringRef Name, SymbolReference Parent, PresumedLoc Loc,
1012 AttributeKind Attributes, StringRef GetterName, StringRef SetterName,
1013 bool IsOptional, bool IsFromSystemHeader)
1018
1019 static bool classof(const APIRecord *Record) {
1020 return classofKind(Record->getKind());
1021 }
1022 static bool classofKind(RecordKind K) { return K == RK_ObjCInstanceProperty; }
1023
1024private:
1025 virtual void anchor();
1026};
1027
1031 const DocComment &Comment,
1035 StringRef SetterName, bool IsOptional,
1036 bool IsFromSystemHeader)
1041
1042 static bool classof(const APIRecord *Record) {
1043 return classofKind(Record->getKind());
1044 }
1045 static bool classofKind(RecordKind K) { return K == RK_ObjCClassProperty; }
1046
1047private:
1048 virtual void anchor();
1049};
1050
1051/// This holds information associated with Objective-C instance variables.
1056 const DocComment &Comment,
1059 bool IsFromSystemHeader)
1063
1064 static bool classof(const APIRecord *Record) {
1065 return classofKind(Record->getKind());
1066 }
1067 static bool classofKind(RecordKind K) { return K == RK_ObjCIvar; }
1068
1069private:
1070 virtual void anchor();
1071};
1072
1073/// This holds information associated with Objective-C methods.
1076
1078
1079 ObjCMethodRecord(RecordKind Kind, StringRef USR, StringRef Name,
1084 bool IsFromSystemHeader)
1085 : APIRecord(Kind, USR, Name, Parent, Loc, std::move(Availability),
1089
1090 virtual ~ObjCMethodRecord() = 0;
1091};
1092
1094 ObjCInstanceMethodRecord(StringRef USR, StringRef Name,
1097 const DocComment &Comment,
1104 static bool classof(const APIRecord *Record) {
1105 return classofKind(Record->getKind());
1106 }
1107 static bool classofKind(RecordKind K) { return K == RK_ObjCInstanceMethod; }
1108
1109private:
1110 virtual void anchor();
1111};
1112
1116 const DocComment &Comment,
1123
1124 static bool classof(const APIRecord *Record) {
1125 return classofKind(Record->getKind());
1126 }
1127 static bool classofKind(RecordKind K) { return K == RK_ObjCClassMethod; }
1128
1129private:
1130 virtual void anchor();
1131};
1132
1139 bool IsFromSystemHeader)
1143
1144 static bool classof(const APIRecord *Record) {
1145 return classofKind(Record->getKind());
1146 }
1147 static bool classofKind(RecordKind K) { return K == RK_StaticField; }
1148};
1149
1150/// The base representation of an Objective-C container record. Holds common
1151/// information associated with Objective-C containers.
1154
1156
1157 ObjCContainerRecord(RecordKind Kind, StringRef USR, StringRef Name,
1160 const DocComment &Comment,
1163 : APIRecord(Kind, USR, Name, Parent, Loc, std::move(Availability),
1166 RecordContext(Kind) {}
1167
1168 virtual ~ObjCContainerRecord() = 0;
1169};
1170
1173
1179 bool IsEmbeddedInVarDeclarator = false)
1180 : RecordRecord(Kind, USR, Name, Parent, Loc, std::move(Availability),
1183
1184 static bool classof(const APIRecord *Record) {
1185 return classofKind(Record->getKind());
1186 }
1187 static bool classofKind(RecordKind K) {
1188 return K == RK_CXXClass || K == RK_ClassTemplate ||
1191 }
1192
1193private:
1194 virtual void anchor();
1195};
1196
1199
1202 const DocComment &Comment,
1208 std::move(Access), IsFromSystemHeader),
1209 Templ(Template) {}
1210
1211 static bool classof(const APIRecord *Record) {
1212 return classofKind(Record->getKind());
1213 }
1214 static bool classofKind(RecordKind K) { return K == RK_ClassTemplate; }
1215};
1216
1219 StringRef USR, StringRef Name, SymbolReference Parent, PresumedLoc Loc,
1226
1227 static bool classof(const APIRecord *Record) {
1228 return classofKind(Record->getKind());
1229 }
1230 static bool classofKind(RecordKind K) {
1232 }
1233};
1234
1238 StringRef USR, StringRef Name, SymbolReference Parent, PresumedLoc Loc,
1246 Templ(Template) {}
1247
1248 static bool classof(const APIRecord *Record) {
1249 return classofKind(Record->getKind());
1250 }
1251 static bool classofKind(RecordKind K) {
1253 }
1254};
1255
1258
1263 bool IsFromSystemHeader)
1267 Templ(Template) {}
1268
1269 static bool classof(const APIRecord *Record) {
1270 return classofKind(Record->getKind());
1271 }
1272 static bool classofKind(RecordKind K) { return K == RK_Concept; }
1273};
1274
1275/// This holds information associated with Objective-C categories.
1278
1281 const DocComment &Comment,
1284 bool IsFromSystemHeader)
1286 std::move(Availability), LinkageInfo::none(),
1290
1291 static bool classof(const APIRecord *Record) {
1292 return classofKind(Record->getKind());
1293 }
1294 static bool classofKind(RecordKind K) { return K == RK_ObjCCategory; }
1295
1296 bool isExtendingExternalModule() const { return !Interface.Source.empty(); }
1297
1298 std::optional<StringRef> getExtendedExternalModule() const {
1300 return {};
1301 return Interface.Source;
1302 }
1303
1304private:
1305 virtual void anchor();
1306};
1307
1308/// This holds information associated with Objective-C interfaces/classes.
1311
1322
1323 static bool classof(const APIRecord *Record) {
1324 return classofKind(Record->getKind());
1325 }
1326 static bool classofKind(RecordKind K) { return K == RK_ObjCInterface; }
1327
1328private:
1329 virtual void anchor();
1330};
1331
1332/// This holds information associated with Objective-C protocols.
1336 const DocComment &Comment,
1340 std::move(Availability), LinkageInfo::none(),
1343
1344 static bool classof(const APIRecord *Record) {
1345 return classofKind(Record->getKind());
1346 }
1347 static bool classofKind(RecordKind K) { return K == RK_ObjCProtocol; }
1348
1349private:
1350 virtual void anchor();
1351};
1352
1353/// This holds information associated with macro definitions.
1358 bool IsFromSystemHeader)
1362
1363 static bool classof(const APIRecord *Record) {
1364 return classofKind(Record->getKind());
1365 }
1366 static bool classofKind(RecordKind K) { return K == RK_MacroDefinition; }
1367
1368private:
1369 virtual void anchor();
1370};
1371
1372/// This holds information associated with typedefs.
1373///
1374/// Note: Typedefs for anonymous enums and structs typically don't get emitted
1375/// by the serializers but still get a TypedefRecord. Instead we use the
1376/// typedef name as a name for the underlying anonymous struct or enum.
1379
1384 bool IsFromSystemHeader)
1389
1390 static bool classof(const APIRecord *Record) {
1391 return classofKind(Record->getKind());
1392 }
1393 static bool classofKind(RecordKind K) { return K == RK_Typedef; }
1394
1395private:
1396 virtual void anchor();
1397};
1398
1399/// APISet holds the set of API records collected from given inputs.
1400class APISet {
1401public:
1402 /// Get the target triple for the ExtractAPI invocation.
1403 const llvm::Triple &getTarget() const { return Target; }
1404
1405 /// Get the language used by the APIs.
1406 Language getLanguage() const { return Lang; }
1407
1408 /// Finds the APIRecord for a given USR.
1409 ///
1410 /// \returns a pointer to the APIRecord associated with that USR or nullptr.
1411 APIRecord *findRecordForUSR(StringRef USR) const;
1412
1413 /// Copy \p String into the Allocator in this APISet.
1414 ///
1415 /// \returns a StringRef of the copied string in APISet::Allocator.
1416 StringRef copyString(StringRef String);
1417
1418 SymbolReference createSymbolReference(StringRef Name, StringRef USR,
1419 StringRef Source = "");
1420
1421 /// Create a subclass of \p APIRecord and store it in the APISet.
1422 ///
1423 /// \returns A pointer to the created record or the already existing record
1424 /// matching this USR.
1425 template <typename RecordTy, typename... CtorArgsContTy>
1426 typename std::enable_if_t<std::is_base_of_v<APIRecord, RecordTy>, RecordTy> *
1427 createRecord(StringRef USR, StringRef Name, CtorArgsContTy &&...CtorArgs);
1428
1430 return TopLevelRecords;
1431 }
1432
1433 APISet(const llvm::Triple &Target, Language Lang,
1434 const std::string &ProductName)
1435 : Target(Target), Lang(Lang), ProductName(ProductName) {}
1436
1437 // Prevent moves and copies
1438 APISet(const APISet &Other) = delete;
1439 APISet &operator=(const APISet &Other) = delete;
1440 APISet(APISet &&Other) = delete;
1442
1443private:
1444 /// BumpPtrAllocator that serves as the memory arena for the allocated objects
1445 llvm::BumpPtrAllocator Allocator;
1446
1447 const llvm::Triple Target;
1448 const Language Lang;
1449
1450 struct APIRecordDeleter {
1451 void operator()(APIRecord *Record) { Record->~APIRecord(); }
1452 };
1453
1454 // Ensure that the destructor of each record is called when the LookupTable is
1455 // destroyed without calling delete operator as the memory for the record
1456 // lives in the BumpPtrAllocator.
1457 using APIRecordStoredPtr = std::unique_ptr<APIRecord, APIRecordDeleter>;
1458 llvm::DenseMap<StringRef, APIRecordStoredPtr> USRBasedLookupTable;
1459 std::vector<const APIRecord *> TopLevelRecords;
1460
1461public:
1462 const std::string ProductName;
1463};
1464
1465template <typename RecordTy, typename... CtorArgsContTy>
1466typename std::enable_if_t<std::is_base_of_v<APIRecord, RecordTy>, RecordTy> *
1467APISet::createRecord(StringRef USR, StringRef Name,
1468 CtorArgsContTy &&...CtorArgs) {
1469 // Ensure USR refers to a String stored in the allocator.
1470 auto USRString = copyString(USR);
1471 auto Result = USRBasedLookupTable.insert({USRString, nullptr});
1472 RecordTy *Record;
1473
1474 // Create the record if it does not already exist
1475 if (Result.second) {
1476 Record = new (Allocator) RecordTy(
1477 USRString, copyString(Name), std::forward<CtorArgsContTy>(CtorArgs)...);
1478 // Store the record in the record lookup map
1479 Result.first->second = APIRecordStoredPtr(Record);
1480
1481 if (auto *ParentContext =
1482 dyn_cast_if_present<RecordContext>(Record->Parent.Record))
1483 ParentContext->addToRecordChain(Record);
1484 else
1485 TopLevelRecords.push_back(Record);
1486 } else {
1487 Record = dyn_cast<RecordTy>(Result.first->second.get());
1488 }
1489
1490 return Record;
1491}
1492
1493// Helper type for implementing casting to RecordContext pointers.
1494// Selected when FromTy not a known subclass of RecordContext.
1495template <typename FromTy,
1496 bool IsKnownSubType = std::is_base_of_v<RecordContext, FromTy>>
1498 static_assert(std::is_base_of_v<APIRecord, FromTy>,
1499 "Can only cast APIRecord and derived classes to RecordContext");
1500
1501 static bool isPossible(FromTy *From) { return RecordContext::classof(From); }
1502
1503 static RecordContext *doCast(FromTy *From) {
1504 return APIRecord::castToRecordContext(From);
1505 }
1506};
1507
1508// Selected when FromTy is a known subclass of RecordContext.
1509template <typename FromTy> struct ToRecordContextCastInfoWrapper<FromTy, true> {
1510 static_assert(std::is_base_of_v<APIRecord, FromTy>,
1511 "Can only cast APIRecord and derived classes to RecordContext");
1512 static bool isPossible(const FromTy *From) { return true; }
1513 static RecordContext *doCast(FromTy *From) {
1514 return static_cast<RecordContext *>(From);
1515 }
1516};
1517
1518// Helper type for implementing casting to RecordContext pointers.
1519// Selected when ToTy isn't a known subclass of RecordContext
1520template <typename ToTy,
1521 bool IsKnownSubType = std::is_base_of_v<RecordContext, ToTy>>
1523 static_assert(
1524 std::is_base_of_v<APIRecord, ToTy>,
1525 "Can only class RecordContext to APIRecord and derived classes");
1526
1527 static bool isPossible(RecordContext *Ctx) {
1528 return ToTy::classofKind(Ctx->getKind());
1529 }
1530
1531 static ToTy *doCast(RecordContext *Ctx) {
1533 }
1534};
1535
1536// Selected when ToTy is a known subclass of RecordContext.
1537template <typename ToTy> struct FromRecordContextCastInfoWrapper<ToTy, true> {
1538 static_assert(
1539 std::is_base_of_v<APIRecord, ToTy>,
1540 "Can only class RecordContext to APIRecord and derived classes");
1541 static bool isPossible(RecordContext *Ctx) {
1542 return ToTy::classof(Ctx->getKind());
1543 }
1545 return static_cast<ToTy *>(Ctx);
1546 }
1547};
1548
1549} // namespace extractapi
1550} // namespace clang
1551
1552// Implement APIRecord (and derived classes) to and from RecordContext
1553// conversions
1554namespace llvm {
1555
1556template <typename FromTy>
1557struct CastInfo<::clang::extractapi::RecordContext, FromTy *>
1558 : public NullableValueCastFailed<::clang::extractapi::RecordContext *>,
1560 ::clang::extractapi::RecordContext *, FromTy *,
1561 CastInfo<::clang::extractapi::RecordContext, FromTy *>> {
1562 static inline bool isPossible(FromTy *From) {
1563 return ::clang::extractapi::ToRecordContextCastInfoWrapper<
1564 FromTy>::isPossible(From);
1565 }
1566
1567 static inline ::clang::extractapi::RecordContext *doCast(FromTy *From) {
1568 return ::clang::extractapi::ToRecordContextCastInfoWrapper<FromTy>::doCast(
1569 From);
1570 }
1571};
1572
1573template <typename FromTy>
1574struct CastInfo<::clang::extractapi::RecordContext, const FromTy *>
1576 ::clang::extractapi::RecordContext, const FromTy *,
1577 CastInfo<::clang::extractapi::RecordContext, FromTy *>> {};
1578
1579template <typename ToTy>
1580struct CastInfo<ToTy, ::clang::extractapi::RecordContext *>
1581 : public NullableValueCastFailed<ToTy *>,
1583 ToTy *, ::clang::extractapi::RecordContext *,
1584 CastInfo<ToTy, ::clang::extractapi::RecordContext *>> {
1586 return ::clang::extractapi::FromRecordContextCastInfoWrapper<
1587 ToTy>::isPossible(Ctx);
1588 }
1589
1590 static inline ToTy *doCast(::clang::extractapi::RecordContext *Ctx) {
1591 return ::clang::extractapi::FromRecordContextCastInfoWrapper<ToTy>::doCast(
1592 Ctx);
1593 }
1594};
1595
1596template <typename ToTy>
1597struct CastInfo<ToTy, const ::clang::extractapi::RecordContext *>
1599 ToTy, const ::clang::extractapi::RecordContext *,
1600 CastInfo<ToTy, ::clang::extractapi::RecordContext *>> {};
1601
1602} // namespace llvm
1603
1604#endif // LLVM_CLANG_EXTRACTAPI_API_H
enum clang::sema::@1648::IndirectLocalPathEntry::EntryKind Kind
This file defines the Declaration Fragments related classes.
llvm::MachO::Target Target
Definition: MachO.h:51
llvm::MachO::Record Record
Definition: MachO.h:31
SourceLocation Loc
Definition: SemaObjC.cpp:758
Defines the clang::SourceLocation class and associated facilities.
Defines various enumerations that describe declaration and type specifiers.
Decl - This represents one declaration (or definition), e.g.
Definition: DeclBase.h:86
Represents an unpacked "presumed" location which can be presented to the user.
The base class of all kinds of template declarations (e.g., class, function, etc.).
Definition: DeclTemplate.h:394
The base class of the type hierarchy.
Definition: Type.h:1826
APISet holds the set of API records collected from given inputs.
Definition: API.h:1400
std::enable_if_t< std::is_base_of_v< APIRecord, RecordTy >, RecordTy > * createRecord(StringRef USR, StringRef Name, CtorArgsContTy &&...CtorArgs)
Create a subclass of APIRecord and store it in the APISet.
Definition: API.h:1467
APISet & operator=(const APISet &Other)=delete
SymbolReference createSymbolReference(StringRef Name, StringRef USR, StringRef Source="")
Definition: API.cpp:112
Language getLanguage() const
Get the language used by the APIs.
Definition: API.h:1406
ArrayRef< const APIRecord * > getTopLevelRecords() const
Definition: API.h:1429
const std::string ProductName
Definition: API.h:1462
APISet(const APISet &Other)=delete
StringRef copyString(StringRef String)
Copy String into the Allocator in this APISet.
Definition: API.cpp:99
APISet(APISet &&Other)=delete
const llvm::Triple & getTarget() const
Get the target triple for the ExtractAPI invocation.
Definition: API.h:1403
APISet & operator=(APISet &&Other)=delete
APIRecord * findRecordForUSR(StringRef USR) const
Finds the APIRecord for a given USR.
Definition: API.cpp:88
APISet(const llvm::Triple &Target, Language Lang, const std::string &ProductName)
Definition: API.h:1433
DeclarationFragments is a vector of tagged important parts of a symbol's declaration.
Store function signature information with DeclarationFragments of the return type and parameters.
Base class used for specific record types that have children records this is analogous to the DeclCon...
Definition: API.h:313
record_iterator records_begin() const
Definition: API.h:372
bool records_empty() const
Definition: API.h:374
static bool classof(const RecordContext *Context)
Definition: API.h:323
llvm::iterator_range< record_iterator > record_range
Definition: API.h:368
APIRecord::RecordKind getKind() const
Definition: API.h:331
record_range records() const
Definition: API.h:369
void stealRecordChain(RecordContext &Other)
Append Other children chain into ours and empty out Other's record chain.
Definition: API.cpp:61
record_iterator records_end() const
Definition: API.h:373
static bool classofKind(APIRecord::RecordKind K)
Definition: API.h:318
void addToRecordChain(APIRecord *) const
Definition: API.cpp:76
RecordContext(APIRecord::RecordKind Kind)
Definition: API.h:325
static bool classof(const APIRecord *Record)
Definition: API.h:315
void addTemplateParameter(std::string Type, std::string Name, unsigned int Index, unsigned int Depth, bool IsParameterPack)
Definition: API.h:136
Template(const TemplateDecl *Decl)
Definition: API.h:74
Template(const VarTemplatePartialSpecializationDecl *Decl)
Definition: API.h:110
Template(const ClassTemplatePartialSpecializationDecl *Decl)
Definition: API.h:92
const llvm::SmallVector< TemplateParameter > & getParameters() const
Definition: API.h:128
const llvm::SmallVector< TemplateConstraint > & getConstraints() const
Definition: API.h:132
bool empty() const
Definition: API.h:142
std::vector< RawComment::CommentLine > DocComment
DocComment is a vector of RawComment::CommentLine.
Definition: API.h:158
The JSON file list parser is used to communicate input to InstallAPI.
Linkage
Describes the different kinds of linkage (C++ [basic.link], C99 6.2.2) that an entity may have.
Definition: Linkage.h:24
Language
The language for the input, used to select and validate the language standard and possible actions.
Definition: LangStandard.h:23
@ Parameter
The parameter type of a method or function.
@ Result
The result type of a method or function.
llvm::PointerUnion< TemplateTypeParmDecl *, NonTypeTemplateParmDecl *, TemplateTemplateParmDecl * > TemplateParameter
Stores a template parameter of any kind.
Definition: DeclTemplate.h:65
@ Other
Other implicit parameter.
Diagnostic wrappers for TextAPI types for error reporting.
Definition: Dominators.h:30
#define true
Definition: stdbool.h:25
Storage of availability attributes for a declaration.
Definition: Availability.h:64
The base representation of an API record. Holds common symbol information.
Definition: API.h:192
RecordKind getKind() const
Definition: API.h:281
APIRecord(RecordKind Kind, StringRef USR, StringRef Name)
Definition: API.h:301
DocComment Comment
Documentation comment lines attached to this symbol declaration.
Definition: API.h:251
AvailabilityInfo Availability
Definition: API.h:247
DeclarationFragments Declaration
Declaration fragments of this symbol declaration.
Definition: API.h:254
RecordKind getKindForDisplay() const
Definition: API.h:282
RecordKind KindForDisplay
Definition: API.h:269
APIRecord(RecordKind Kind, StringRef USR, StringRef Name, SymbolReference Parent, PresumedLoc Location, AvailabilityInfo Availability, LinkageInfo Linkage, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading, bool IsFromSystemHeader, AccessControl Access=AccessControl())
Definition: API.h:289
LinkageInfo Linkage
Definition: API.h:248
virtual ~APIRecord()=0
Definition: API.cpp:117
DeclarationFragments SubHeading
SubHeading provides a more detailed representation than the plain declaration name.
Definition: API.h:262
APIRecord * getNextInContext() const
Definition: API.h:279
static APIRecord * castFromRecordContext(const RecordContext *Ctx)
Definition: API.cpp:28
AccessControl Access
Definition: API.h:267
PresumedLoc Location
Definition: API.h:246
static bool classofKind(RecordKind K)
Definition: API.h:307
RecordKind
Discriminator for LLVM-style RTTI (dyn_cast<> et al.)
Definition: API.h:194
@ RK_GlobalFunctionTemplateSpecialization
Definition: API.h:223
@ RK_GlobalVariableTemplatePartialSpecialization
Definition: API.h:219
@ RK_GlobalVariableTemplateSpecialization
Definition: API.h:218
@ RK_ClassTemplatePartialSpecialization
Definition: API.h:210
static RecordContext * castToRecordContext(const APIRecord *Record)
Definition: API.cpp:41
SymbolReference Parent
Definition: API.h:244
static bool classof(const RecordContext *Ctx)
Definition: API.h:308
bool IsFromSystemHeader
Whether the symbol was defined in a system header.
Definition: API.h:265
static bool classof(const APIRecord *Record)
Definition: API.h:306
SmallVector< SymbolReference > Bases
Definition: API.h:1172
static bool classofKind(RecordKind K)
Definition: API.h:1187
static bool classof(const APIRecord *Record)
Definition: API.h:1184
CXXClassRecord(StringRef USR, StringRef Name, SymbolReference Parent, PresumedLoc Loc, AvailabilityInfo Availability, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading, RecordKind Kind, AccessControl Access, bool IsFromSystemHeader, bool IsEmbeddedInVarDeclarator=false)
Definition: API.h:1174
CXXConstructorRecord(StringRef USR, StringRef Name, SymbolReference Parent, PresumedLoc Loc, AvailabilityInfo Availability, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading, FunctionSignature Signature, AccessControl Access, bool IsFromSystemHeader)
Definition: API.h:848
static bool classof(const APIRecord *Record)
Definition: API.h:859
static bool classofKind(RecordKind K)
Definition: API.h:862
CXXDestructorRecord(StringRef USR, StringRef Name, SymbolReference Parent, PresumedLoc Loc, AvailabilityInfo Availability, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading, FunctionSignature Signature, AccessControl Access, bool IsFromSystemHeader)
Definition: API.h:869
static bool classofKind(RecordKind K)
Definition: API.h:883
static bool classof(const APIRecord *Record)
Definition: API.h:880
CXXFieldRecord(StringRef USR, StringRef Name, SymbolReference Parent, PresumedLoc Loc, AvailabilityInfo Availability, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading, AccessControl Access, bool IsFromSystemHeader)
Definition: API.h:776
static bool classofKind(RecordKind K)
Definition: API.h:800
static bool classof(const APIRecord *Record)
Definition: API.h:797
CXXFieldRecord(RecordKind Kind, StringRef USR, StringRef Name, SymbolReference Parent, PresumedLoc Loc, AvailabilityInfo Availability, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading, AccessControl Access, bool IsFromSystemHeader)
Definition: API.h:786
static bool classof(const APIRecord *Record)
Definition: API.h:822
static bool classofKind(RecordKind K)
Definition: API.h:825
CXXFieldTemplateRecord(StringRef USR, StringRef Name, SymbolReference Parent, PresumedLoc Loc, AvailabilityInfo Availability, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading, AccessControl Access, Template Template, bool IsFromSystemHeader)
Definition: API.h:811
static bool classof(const APIRecord *Record)
Definition: API.h:923
static bool classofKind(RecordKind K)
Definition: API.h:926
CXXInstanceMethodRecord(StringRef USR, StringRef Name, SymbolReference Parent, PresumedLoc Loc, AvailabilityInfo Availability, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading, FunctionSignature Signature, AccessControl Access, bool IsFromSystemHeader)
Definition: API.h:911
CXXMethodRecord(RecordKind Kind, StringRef USR, StringRef Name, SymbolReference Parent, PresumedLoc Loc, AvailabilityInfo Availability, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading, FunctionSignature Signature, AccessControl Access, bool IsFromSystemHeader)
Definition: API.h:833
FunctionSignature Signature
Definition: API.h:829
static bool classofKind(RecordKind K)
Definition: API.h:951
static bool classof(const APIRecord *Record)
Definition: API.h:948
CXXMethodTemplateRecord(StringRef USR, StringRef Name, SymbolReference Parent, PresumedLoc Loc, AvailabilityInfo Availability, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading, FunctionSignature Signature, AccessControl Access, Template Template, bool IsFromSystemHeader)
Definition: API.h:935
static bool classof(const APIRecord *Record)
Definition: API.h:966
CXXMethodTemplateSpecializationRecord(StringRef USR, StringRef Name, SymbolReference Parent, PresumedLoc Loc, AvailabilityInfo Availability, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading, FunctionSignature Signature, AccessControl Access, bool IsFromSystemHeader)
Definition: API.h:955
static bool classof(const APIRecord *Record)
Definition: API.h:901
CXXStaticMethodRecord(StringRef USR, StringRef Name, SymbolReference Parent, PresumedLoc Loc, AvailabilityInfo Availability, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading, FunctionSignature Signature, AccessControl Access, bool IsFromSystemHeader)
Definition: API.h:890
static bool classofKind(RecordKind K)
Definition: API.h:904
ClassTemplatePartialSpecializationRecord(StringRef USR, StringRef Name, SymbolReference Parent, PresumedLoc Loc, AvailabilityInfo Availability, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading, Template Template, AccessControl Access, bool IsFromSystemHeader)
Definition: API.h:1237
static bool classof(const APIRecord *Record)
Definition: API.h:1248
static bool classof(const APIRecord *Record)
Definition: API.h:1211
ClassTemplateRecord(StringRef USR, StringRef Name, SymbolReference Parent, PresumedLoc Loc, AvailabilityInfo Availability, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading, Template Template, AccessControl Access, bool IsFromSystemHeader)
Definition: API.h:1200
static bool classofKind(RecordKind K)
Definition: API.h:1214
ClassTemplateSpecializationRecord(StringRef USR, StringRef Name, SymbolReference Parent, PresumedLoc Loc, AvailabilityInfo Availability, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading, AccessControl Access, bool IsFromSystemHeader)
Definition: API.h:1218
static bool classof(const APIRecord *Record)
Definition: API.h:1227
ConceptRecord(StringRef USR, StringRef Name, SymbolReference Parent, PresumedLoc Loc, AvailabilityInfo Availability, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading, Template Template, bool IsFromSystemHeader)
Definition: API.h:1259
static bool classof(const APIRecord *Record)
Definition: API.h:1269
static bool classofKind(RecordKind K)
Definition: API.h:1272
This holds information associated with enum constants.
Definition: API.h:588
EnumConstantRecord(StringRef USR, StringRef Name, SymbolReference Parent, PresumedLoc Loc, AvailabilityInfo Availability, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading, bool IsFromSystemHeader)
Definition: API.h:589
static bool classofKind(RecordKind K)
Definition: API.h:601
static bool classof(const APIRecord *Record)
Definition: API.h:598
This holds information associated with enums.
Definition: API.h:633
static bool classof(const APIRecord *Record)
Definition: API.h:644
EnumRecord(StringRef USR, StringRef Name, SymbolReference Parent, PresumedLoc Loc, AvailabilityInfo Availability, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading, bool IsFromSystemHeader, bool IsEmbeddedInVarDeclarator, AccessControl Access=AccessControl())
Definition: API.h:634
static bool classofKind(RecordKind K)
Definition: API.h:648
static RecordContext * doCast(RecordContext *Ctx)
Definition: API.h:1544
static ToTy * doCast(RecordContext *Ctx)
Definition: API.h:1531
static bool isPossible(RecordContext *Ctx)
Definition: API.h:1527
This holds information associated with global functions.
Definition: API.h:405
GlobalFunctionRecord(RecordKind Kind, StringRef USR, StringRef Name, SymbolReference Parent, PresumedLoc Loc, AvailabilityInfo Availability, LinkageInfo Linkage, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading, FunctionSignature Signature, bool IsFromSystemHeader)
Definition: API.h:419
static bool classof(const APIRecord *Record)
Definition: API.h:431
static bool classofKind(RecordKind K)
Definition: API.h:434
GlobalFunctionRecord(StringRef USR, StringRef Name, SymbolReference Parent, PresumedLoc Loc, AvailabilityInfo Availability, LinkageInfo Linkage, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading, FunctionSignature Signature, bool IsFromSystemHeader)
Definition: API.h:408
GlobalFunctionTemplateRecord(StringRef USR, StringRef Name, SymbolReference Parent, PresumedLoc Loc, AvailabilityInfo Availability, LinkageInfo Linkage, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading, FunctionSignature Signature, Template Template, bool IsFromSystemHeader)
Definition: API.h:443
static bool classofKind(RecordKind K)
Definition: API.h:460
static bool classof(const APIRecord *Record)
Definition: API.h:457
static bool classof(const APIRecord *Record)
Definition: API.h:477
GlobalFunctionTemplateSpecializationRecord(StringRef USR, StringRef Name, SymbolReference Parent, PresumedLoc Loc, AvailabilityInfo Availability, LinkageInfo Linkage, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading, FunctionSignature Signature, bool IsFromSystemHeader)
Definition: API.h:466
This holds information associated with global functions.
Definition: API.h:486
static bool classof(const APIRecord *Record)
Definition: API.h:508
GlobalVariableRecord(RecordKind Kind, StringRef USR, StringRef Name, SymbolReference Parent, PresumedLoc Loc, AvailabilityInfo Availability, LinkageInfo Linkage, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading, bool IsFromSystemHeader)
Definition: API.h:497
static bool classofKind(RecordKind K)
Definition: API.h:511
GlobalVariableRecord(StringRef USR, StringRef Name, SymbolReference Parent, PresumedLoc Loc, AvailabilityInfo Availability, LinkageInfo Linkage, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading, bool IsFromSystemHeader)
Definition: API.h:487
GlobalVariableTemplatePartialSpecializationRecord(StringRef USR, StringRef Name, SymbolReference Parent, PresumedLoc Loc, AvailabilityInfo Availability, LinkageInfo Linkage, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading, class Template Template, bool IsFromSystemHeader)
Definition: API.h:567
static bool classof(const APIRecord *Record)
Definition: API.h:536
static bool classofKind(RecordKind K)
Definition: API.h:539
GlobalVariableTemplateRecord(StringRef USR, StringRef Name, SymbolReference Parent, PresumedLoc Loc, AvailabilityInfo Availability, LinkageInfo Linkage, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading, class Template Template, bool IsFromSystemHeader)
Definition: API.h:524
static bool classof(const APIRecord *Record)
Definition: API.h:555
GlobalVariableTemplateSpecializationRecord(StringRef USR, StringRef Name, SymbolReference Parent, PresumedLoc Loc, AvailabilityInfo Availability, LinkageInfo Linkage, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading, bool IsFromSystemHeader)
Definition: API.h:545
This holds information associated with macro definitions.
Definition: API.h:1354
static bool classof(const APIRecord *Record)
Definition: API.h:1363
MacroDefinitionRecord(StringRef USR, StringRef Name, SymbolReference Parent, PresumedLoc Loc, DeclarationFragments Declaration, DeclarationFragments SubHeading, bool IsFromSystemHeader)
Definition: API.h:1355
static bool classofKind(RecordKind K)
Definition: API.h:1366
static bool classof(const APIRecord *Record)
Definition: API.h:398
NamespaceRecord(StringRef USR, StringRef Name, SymbolReference Parent, PresumedLoc Loc, AvailabilityInfo Availability, LinkageInfo Linkage, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading, bool IsFromSystemHeader)
Definition: API.h:388
static bool classofKind(RecordKind K)
Definition: API.h:401
This holds information associated with Objective-C categories.
Definition: API.h:1276
static bool classofKind(RecordKind K)
Definition: API.h:1294
ObjCCategoryRecord(StringRef USR, StringRef Name, SymbolReference Parent, PresumedLoc Loc, AvailabilityInfo Availability, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading, SymbolReference Interface, bool IsFromSystemHeader)
Definition: API.h:1279
std::optional< StringRef > getExtendedExternalModule() const
Definition: API.h:1298
bool isExtendingExternalModule() const
Definition: API.h:1296
static bool classof(const APIRecord *Record)
Definition: API.h:1291
static bool classofKind(RecordKind K)
Definition: API.h:1127
ObjCClassMethodRecord(StringRef USR, StringRef Name, SymbolReference Parent, PresumedLoc Loc, AvailabilityInfo Availability, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading, FunctionSignature Signature, bool IsFromSystemHeader)
Definition: API.h:1114
static bool classof(const APIRecord *Record)
Definition: API.h:1124
static bool classof(const APIRecord *Record)
Definition: API.h:1042
static bool classofKind(RecordKind K)
Definition: API.h:1045
ObjCClassPropertyRecord(StringRef USR, StringRef Name, SymbolReference Parent, PresumedLoc Loc, AvailabilityInfo Availability, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading, AttributeKind Attributes, StringRef GetterName, StringRef SetterName, bool IsOptional, bool IsFromSystemHeader)
Definition: API.h:1029
The base representation of an Objective-C container record.
Definition: API.h:1152
SmallVector< SymbolReference > Protocols
Definition: API.h:1153
ObjCContainerRecord(RecordKind Kind, StringRef USR, StringRef Name, SymbolReference Parent, PresumedLoc Loc, AvailabilityInfo Availability, LinkageInfo Linkage, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading, bool IsFromSystemHeader)
Definition: API.h:1157
static bool classofKind(RecordKind K)
Definition: API.h:1107
ObjCInstanceMethodRecord(StringRef USR, StringRef Name, SymbolReference Parent, PresumedLoc Loc, AvailabilityInfo Availability, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading, FunctionSignature Signature, bool IsFromSystemHeader)
Definition: API.h:1094
static bool classof(const APIRecord *Record)
Definition: API.h:1104
static bool classof(const APIRecord *Record)
Definition: API.h:1019
static bool classofKind(RecordKind K)
Definition: API.h:1022
ObjCInstancePropertyRecord(StringRef USR, StringRef Name, SymbolReference Parent, PresumedLoc Loc, AvailabilityInfo Availability, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading, AttributeKind Attributes, StringRef GetterName, StringRef SetterName, bool IsOptional, bool IsFromSystemHeader)
Definition: API.h:1008
This holds information associated with Objective-C instance variables.
Definition: API.h:1052
static bool classofKind(RecordKind K)
Definition: API.h:1067
ObjCInstanceVariableRecord(StringRef USR, StringRef Name, SymbolReference Parent, PresumedLoc Loc, AvailabilityInfo Availability, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading, bool IsFromSystemHeader)
Definition: API.h:1053
static bool classof(const APIRecord *Record)
Definition: API.h:1064
This holds information associated with Objective-C interfaces/classes.
Definition: API.h:1309
static bool classof(const APIRecord *Record)
Definition: API.h:1323
static bool classofKind(RecordKind K)
Definition: API.h:1326
ObjCInterfaceRecord(StringRef USR, StringRef Name, SymbolReference Parent, PresumedLoc Loc, AvailabilityInfo Availability, LinkageInfo Linkage, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading, SymbolReference SuperClass, bool IsFromSystemHeader)
Definition: API.h:1312
This holds information associated with Objective-C methods.
Definition: API.h:1074
ObjCMethodRecord(RecordKind Kind, StringRef USR, StringRef Name, SymbolReference Parent, PresumedLoc Loc, AvailabilityInfo Availability, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading, FunctionSignature Signature, bool IsFromSystemHeader)
Definition: API.h:1079
FunctionSignature Signature
Definition: API.h:1075
This holds information associated with Objective-C properties.
Definition: API.h:975
AttributeKind
The attributes associated with an Objective-C property.
Definition: API.h:977
ObjCPropertyRecord(RecordKind Kind, StringRef USR, StringRef Name, SymbolReference Parent, PresumedLoc Loc, AvailabilityInfo Availability, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading, AttributeKind Attributes, StringRef GetterName, StringRef SetterName, bool IsOptional, bool IsFromSystemHeader)
Definition: API.h:988
This holds information associated with Objective-C protocols.
Definition: API.h:1333
static bool classof(const APIRecord *Record)
Definition: API.h:1344
static bool classofKind(RecordKind K)
Definition: API.h:1347
ObjCProtocolRecord(StringRef USR, StringRef Name, SymbolReference Parent, PresumedLoc Loc, AvailabilityInfo Availability, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading, bool IsFromSystemHeader)
Definition: API.h:1334
std::forward_iterator_tag iterator_category
Definition: API.h:341
friend bool operator==(record_iterator x, record_iterator y)
Definition: API.h:360
friend bool operator!=(record_iterator x, record_iterator y)
Definition: API.h:363
This holds information associated with struct or union fields fields.
Definition: API.h:655
RecordFieldRecord(RecordKind Kind, StringRef USR, StringRef Name, SymbolReference Parent, PresumedLoc Loc, AvailabilityInfo Availability, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading, bool IsFromSystemHeader)
Definition: API.h:656
static bool classofKind(RecordKind K)
Definition: API.h:669
static bool classof(const APIRecord *Record)
Definition: API.h:666
This holds information associated with structs and unions.
Definition: API.h:677
RecordRecord(RecordKind Kind, StringRef USR, StringRef Name, SymbolReference Parent, PresumedLoc Loc, AvailabilityInfo Availability, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading, bool IsFromSystemHeader, bool IsEmbeddedInVarDeclarator, AccessControl Access=AccessControl())
Definition: API.h:678
static bool classof(const APIRecord *Record)
Definition: API.h:689
static bool classofKind(RecordKind K)
Definition: API.h:692
static bool classof(const APIRecord *Record)
Definition: API.h:1144
static bool classofKind(RecordKind K)
Definition: API.h:1147
StaticFieldRecord(StringRef USR, StringRef Name, SymbolReference Parent, PresumedLoc Loc, AvailabilityInfo Availability, LinkageInfo Linkage, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading, AccessControl Access, bool IsFromSystemHeader)
Definition: API.h:1134
static bool classof(const APIRecord *Record)
Definition: API.h:710
static bool classofKind(RecordKind K)
Definition: API.h:713
StructFieldRecord(StringRef USR, StringRef Name, SymbolReference Parent, PresumedLoc Loc, AvailabilityInfo Availability, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading, bool IsFromSystemHeader)
Definition: API.h:702
StructRecord(StringRef USR, StringRef Name, SymbolReference Parent, PresumedLoc Loc, AvailabilityInfo Availability, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading, bool IsFromSystemHeader, bool IsEmbeddedInVarDeclarator)
Definition: API.h:720
static bool classof(const APIRecord *Record)
Definition: API.h:729
static bool classofKind(RecordKind K)
Definition: API.h:732
bool empty() const
Determine if this SymbolReference is empty.
Definition: API.h:182
SymbolReference(StringRef Name, StringRef USR, StringRef Source="")
Definition: API.h:175
StringRef Source
The source project/module/product of the referred symbol.
Definition: API.h:169
static bool classof(const APIRecord *Record)
Definition: API.h:620
static bool classofKind(RecordKind K)
Definition: API.h:623
TagRecord(RecordKind Kind, StringRef USR, StringRef Name, SymbolReference Parent, PresumedLoc Loc, AvailabilityInfo Availability, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading, bool IsFromSystemHeader, bool IsEmbeddedInVarDeclarator, AccessControl Access=AccessControl())
Definition: API.h:608
virtual ~TagRecord()=0
Definition: API.cpp:118
static RecordContext * doCast(FromTy *From)
Definition: API.h:1503
static bool isPossible(FromTy *From)
Definition: API.h:1501
This holds information associated with typedefs.
Definition: API.h:1377
static bool classofKind(RecordKind K)
Definition: API.h:1393
SymbolReference UnderlyingType
Definition: API.h:1378
TypedefRecord(StringRef USR, StringRef Name, SymbolReference Parent, PresumedLoc Loc, AvailabilityInfo Availability, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading, SymbolReference UnderlyingType, bool IsFromSystemHeader)
Definition: API.h:1380
static bool classof(const APIRecord *Record)
Definition: API.h:1390
static bool classofKind(RecordKind K)
Definition: API.h:750
static bool classof(const APIRecord *Record)
Definition: API.h:747
UnionFieldRecord(StringRef USR, StringRef Name, SymbolReference Parent, PresumedLoc Loc, AvailabilityInfo Availability, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading, bool IsFromSystemHeader)
Definition: API.h:739
static bool classof(const APIRecord *Record)
Definition: API.h:766
UnionRecord(StringRef USR, StringRef Name, SymbolReference Parent, PresumedLoc Loc, AvailabilityInfo Availability, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading, bool IsFromSystemHeader, bool IsEmbeddedInVarDeclarator)
Definition: API.h:757
static bool classofKind(RecordKind K)
Definition: API.h:769
static ToTy * doCast(::clang::extractapi::RecordContext *Ctx)
Definition: API.h:1590
static bool isPossible(::clang::extractapi::RecordContext *Ctx)
Definition: API.h:1585
static inline ::clang::extractapi::RecordContext * doCast(FromTy *From)
Definition: API.h:1567