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
269private:
270 const RecordKind Kind;
271 friend class RecordContext;
272 // Used to store the next child record in RecordContext. This works because
273 // APIRecords semantically only have one parent.
274 mutable APIRecord *NextInContext = nullptr;
275
276public:
277 APIRecord *getNextInContext() const { return NextInContext; }
278
279 RecordKind getKind() const { return Kind; }
280
283
284 APIRecord() = delete;
285
286 APIRecord(RecordKind Kind, StringRef USR, StringRef Name,
292 : USR(USR), Name(Name), Parent(std::move(Parent)), Location(Location),
296 Kind(Kind) {}
297
298 APIRecord(RecordKind Kind, StringRef USR, StringRef Name)
299 : USR(USR), Name(Name), Kind(Kind) {}
300
301 // Pure virtual destructor to make APIRecord abstract
302 virtual ~APIRecord() = 0;
303 static bool classof(const APIRecord *Record) { return true; }
304 static bool classofKind(RecordKind K) { return true; }
305 static bool classof(const RecordContext *Ctx) { return true; }
306};
307
308/// Base class used for specific record types that have children records this is
309/// analogous to the DeclContext for the AST
311public:
312 static bool classof(const APIRecord *Record) {
313 return classofKind(Record->getKind());
314 }
318 }
319
320 static bool classof(const RecordContext *Context) { return true; }
321
323
324 /// Append \p Other children chain into ours and empty out Other's record
325 /// chain.
327
328 APIRecord::RecordKind getKind() const { return Kind; }
329
331 private:
332 APIRecord *Current = nullptr;
333
334 public:
336 using reference = const value_type &;
337 using pointer = const value_type *;
338 using iterator_category = std::forward_iterator_tag;
339 using difference_type = std::ptrdiff_t;
340
341 record_iterator() = default;
342 explicit record_iterator(value_type R) : Current(R) {}
343 reference operator*() const { return Current; }
344 // This doesn't strictly meet the iterator requirements, but it's the
345 // behavior we want here.
346 value_type operator->() const { return Current; }
348 Current = Current->getNextInContext();
349 return *this;
350 }
352 record_iterator tmp(*this);
353 ++(*this);
354 return tmp;
355 }
356
358 return x.Current == y.Current;
359 }
361 return x.Current != y.Current;
362 }
363 };
364
365 using record_range = llvm::iterator_range<record_iterator>;
368 }
371 bool records_empty() const { return First == nullptr; };
372
373private:
375 mutable APIRecord *First = nullptr;
376 mutable APIRecord *Last = nullptr;
377 bool IsWellFormed() const;
378
379protected:
380 friend class APISet;
381 void addToRecordChain(APIRecord *) const;
382};
383
394
395 static bool classof(const APIRecord *Record) {
396 return classofKind(Record->getKind());
397 }
398 static bool classofKind(RecordKind K) { return K == RK_Namespace; }
399};
400
401/// This holds information associated with global functions.
404
415
416 GlobalFunctionRecord(RecordKind Kind, StringRef USR, StringRef Name,
419 const DocComment &Comment,
423 : APIRecord(Kind, USR, Name, Parent, Loc, std::move(Availability),
427
428 static bool classof(const APIRecord *Record) {
429 return classofKind(Record->getKind());
430 }
431 static bool classofKind(RecordKind K) { return K == RK_GlobalFunction; }
432
433private:
434 virtual void anchor();
435};
436
439
452 Templ(Template) {}
453
454 static bool classof(const APIRecord *Record) {
455 return classofKind(Record->getKind());
456 }
457 static bool classofKind(RecordKind K) {
458 return K == RK_GlobalFunctionTemplate;
459 }
460};
461
464 StringRef USR, StringRef Name, SymbolReference Parent, PresumedLoc Loc,
470 Parent, Loc, std::move(Availability), Linkage,
473
474 static bool classof(const APIRecord *Record) {
475 return classofKind(Record->getKind());
476 }
477 static bool classofKind(RecordKind K) {
479 }
480};
481
482/// This holds information associated with global functions.
493
494 GlobalVariableRecord(RecordKind Kind, StringRef USR, StringRef Name,
497 const DocComment &Comment,
500 : APIRecord(Kind, USR, Name, Parent, Loc, std::move(Availability),
503 RecordContext(Kind) {}
504
505 static bool classof(const APIRecord *Record) {
506 return classofKind(Record->getKind());
507 }
508 static bool classofKind(RecordKind K) {
509 return K == RK_GlobalVariable || K == RK_GlobalVariableTemplate ||
512 }
513
514private:
515 virtual void anchor();
516};
517
520
531 Templ(Template) {}
532
533 static bool classof(const APIRecord *Record) {
534 return classofKind(Record->getKind());
535 }
536 static bool classofKind(RecordKind K) {
537 return K == RK_GlobalVariableTemplate;
538 }
539};
540
543 StringRef USR, StringRef Name, SymbolReference Parent, PresumedLoc Loc,
548 Parent, Loc, std::move(Availability), Linkage,
551
552 static bool classof(const APIRecord *Record) {
553 return classofKind(Record->getKind());
554 }
555 static bool classofKind(RecordKind K) {
557 }
558};
559
563
565 StringRef USR, StringRef Name, SymbolReference Parent, PresumedLoc Loc,
571 USR, Name, Parent, Loc, std::move(Availability),
574 Templ(Template) {}
575
576 static bool classof(const APIRecord *Record) {
577 return classofKind(Record->getKind());
578 }
579 static bool classofKind(RecordKind K) {
581 }
582};
583
584/// This holds information associated with enum constants.
588 const DocComment &Comment,
592 std::move(Availability), LinkageInfo::none(), Comment,
594
595 static bool classof(const APIRecord *Record) {
596 return classofKind(Record->getKind());
597 }
598 static bool classofKind(RecordKind K) { return K == RK_EnumConstant; }
599
600private:
601 virtual void anchor();
602};
603
605 TagRecord(RecordKind Kind, StringRef USR, StringRef Name,
611 : APIRecord(Kind, USR, Name, Parent, Loc, std::move(Availability),
614 RecordContext(Kind),
616
617 static bool classof(const APIRecord *Record) {
618 return classofKind(Record->getKind());
619 }
620 static bool classofKind(RecordKind K) {
621 return K == RK_Struct || K == RK_Union || K == RK_Enum;
622 }
623
625
626 virtual ~TagRecord() = 0;
627};
628
629/// This holds information associated with enums.
631 EnumRecord(StringRef USR, StringRef Name, SymbolReference Parent,
637 : TagRecord(RK_Enum, USR, Name, Parent, Loc, std::move(Availability),
640
641 static bool classof(const APIRecord *Record) {
642 return classofKind(Record->getKind());
643 }
644
645 static bool classofKind(RecordKind K) { return K == RK_Enum; }
646
647private:
648 virtual void anchor();
649};
650
651/// This holds information associated with struct or union fields fields.
653 RecordFieldRecord(RecordKind Kind, StringRef USR, StringRef Name,
658 : APIRecord(Kind, USR, Name, Parent, Loc, std::move(Availability),
661 RecordContext(Kind) {}
662
663 static bool classof(const APIRecord *Record) {
664 return classofKind(Record->getKind());
665 }
666 static bool classofKind(RecordKind K) {
667 return K == RK_StructField || K == RK_UnionField;
668 }
669
670 virtual ~RecordFieldRecord() = 0;
671};
672
673/// This holds information associated with structs and unions.
675 RecordRecord(RecordKind Kind, StringRef USR, StringRef Name,
682 : TagRecord(Kind, USR, Name, Parent, Loc, std::move(Availability),
685
686 static bool classof(const APIRecord *Record) {
687 return classofKind(Record->getKind());
688 }
689 static bool classofKind(RecordKind K) {
690 return K == RK_Struct || K == RK_Union;
691 }
692
693 bool isAnonymousWithNoTypedef() { return Name.empty(); }
694
695 virtual ~RecordRecord() = 0;
696};
697
706
707 static bool classof(const APIRecord *Record) {
708 return classofKind(Record->getKind());
709 }
710 static bool classofKind(RecordKind K) { return K == RK_StructField; }
711
712private:
713 virtual void anchor();
714};
715
725
726 static bool classof(const APIRecord *Record) {
727 return classofKind(Record->getKind());
728 }
729 static bool classofKind(RecordKind K) { return K == RK_Struct; }
730
731private:
732 virtual void anchor();
733};
734
743
744 static bool classof(const APIRecord *Record) {
745 return classofKind(Record->getKind());
746 }
747 static bool classofKind(RecordKind K) { return K == RK_UnionField; }
748
749private:
750 virtual void anchor();
751};
752
762
763 static bool classof(const APIRecord *Record) {
764 return classofKind(Record->getKind());
765 }
766 static bool classofKind(RecordKind K) { return K == RK_Union; }
767
768private:
769 virtual void anchor();
770};
771
782
783 CXXFieldRecord(RecordKind Kind, StringRef USR, StringRef Name,
789 : APIRecord(Kind, USR, Name, Parent, Loc, std::move(Availability),
792 RecordContext(Kind) {}
793
794 static bool classof(const APIRecord *Record) {
795 return classofKind(Record->getKind());
796 }
797 static bool classofKind(RecordKind K) {
798 return K == RK_CXXField || K == RK_CXXFieldTemplate || K == RK_StaticField;
799 }
800
801private:
802 virtual void anchor();
803};
804
807
810 const DocComment &Comment,
817 Templ(Template) {}
818
819 static bool classof(const APIRecord *Record) {
820 return classofKind(Record->getKind());
821 }
822 static bool classofKind(RecordKind K) { return K == RK_CXXFieldTemplate; }
823};
824
827
828 CXXMethodRecord() = delete;
829
830 CXXMethodRecord(RecordKind Kind, StringRef USR, StringRef Name,
836 : APIRecord(Kind, USR, Name, Parent, Loc, std::move(Availability),
840
841 virtual ~CXXMethodRecord() = 0;
842};
843
847 const DocComment &Comment,
856 static bool classof(const APIRecord *Record) {
857 return classofKind(Record->getKind());
858 }
859 static bool classofKind(RecordKind K) { return K == RK_CXXConstructorMethod; }
860
861private:
862 virtual void anchor();
863};
864
868 const DocComment &Comment,
877 static bool classof(const APIRecord *Record) {
878 return classofKind(Record->getKind());
879 }
880 static bool classofKind(RecordKind K) { return K == RK_CXXDestructorMethod; }
881
882private:
883 virtual void anchor();
884};
885
889 const DocComment &Comment,
898 static bool classof(const APIRecord *Record) {
899 return classofKind(Record->getKind());
900 }
901 static bool classofKind(RecordKind K) { return K == RK_CXXStaticMethod; }
902
903private:
904 virtual void anchor();
905};
906
910 const DocComment &Comment,
919
920 static bool classof(const APIRecord *Record) {
921 return classofKind(Record->getKind());
922 }
923 static bool classofKind(RecordKind K) { return K == RK_CXXInstanceMethod; }
924
925private:
926 virtual void anchor();
927};
928
931
934 const DocComment &Comment,
943 Templ(Template) {}
944
945 static bool classof(const APIRecord *Record) {
946 return classofKind(Record->getKind());
947 }
948 static bool classofKind(RecordKind K) { return K == RK_CXXMethodTemplate; }
949};
950
953 StringRef USR, StringRef Name, SymbolReference Parent, PresumedLoc Loc,
959 Loc, std::move(Availability), Comment, Declaration,
962
963 static bool classof(const APIRecord *Record) {
964 return classofKind(Record->getKind());
965 }
966 static bool classofKind(RecordKind K) {
968 }
969};
970
971/// This holds information associated with Objective-C properties.
973 /// The attributes associated with an Objective-C property.
974 enum AttributeKind : unsigned {
977 Dynamic = 1 << 2,
978 };
979
981 StringRef GetterName;
982 StringRef SetterName;
984
985 ObjCPropertyRecord(RecordKind Kind, StringRef USR, StringRef Name,
990 StringRef GetterName, StringRef SetterName,
992 : APIRecord(Kind, USR, Name, Parent, Loc, std::move(Availability),
997
998 bool isReadOnly() const { return Attributes & ReadOnly; }
999 bool isDynamic() const { return Attributes & Dynamic; }
1000
1001 virtual ~ObjCPropertyRecord() = 0;
1002};
1003
1006 StringRef USR, StringRef Name, SymbolReference Parent, PresumedLoc Loc,
1009 AttributeKind Attributes, StringRef GetterName, StringRef SetterName,
1010 bool IsOptional, bool IsFromSystemHeader)
1015
1016 static bool classof(const APIRecord *Record) {
1017 return classofKind(Record->getKind());
1018 }
1019 static bool classofKind(RecordKind K) { return K == RK_ObjCInstanceProperty; }
1020
1021private:
1022 virtual void anchor();
1023};
1024
1028 const DocComment &Comment,
1032 StringRef SetterName, bool IsOptional,
1033 bool IsFromSystemHeader)
1038
1039 static bool classof(const APIRecord *Record) {
1040 return classofKind(Record->getKind());
1041 }
1042 static bool classofKind(RecordKind K) { return K == RK_ObjCClassProperty; }
1043
1044private:
1045 virtual void anchor();
1046};
1047
1048/// This holds information associated with Objective-C instance variables.
1053 const DocComment &Comment,
1056 bool IsFromSystemHeader)
1060
1061 static bool classof(const APIRecord *Record) {
1062 return classofKind(Record->getKind());
1063 }
1064 static bool classofKind(RecordKind K) { return K == RK_ObjCIvar; }
1065
1066private:
1067 virtual void anchor();
1068};
1069
1070/// This holds information associated with Objective-C methods.
1073
1075
1076 ObjCMethodRecord(RecordKind Kind, StringRef USR, StringRef Name,
1081 bool IsFromSystemHeader)
1082 : APIRecord(Kind, USR, Name, Parent, Loc, std::move(Availability),
1086
1087 virtual ~ObjCMethodRecord() = 0;
1088};
1089
1091 ObjCInstanceMethodRecord(StringRef USR, StringRef Name,
1094 const DocComment &Comment,
1101 static bool classof(const APIRecord *Record) {
1102 return classofKind(Record->getKind());
1103 }
1104 static bool classofKind(RecordKind K) { return K == RK_ObjCInstanceMethod; }
1105
1106private:
1107 virtual void anchor();
1108};
1109
1113 const DocComment &Comment,
1120
1121 static bool classof(const APIRecord *Record) {
1122 return classofKind(Record->getKind());
1123 }
1124 static bool classofKind(RecordKind K) { return K == RK_ObjCClassMethod; }
1125
1126private:
1127 virtual void anchor();
1128};
1129
1136 bool IsFromSystemHeader)
1140
1141 static bool classof(const APIRecord *Record) {
1142 return classofKind(Record->getKind());
1143 }
1144 static bool classofKind(RecordKind K) { return K == RK_StaticField; }
1145};
1146
1147/// The base representation of an Objective-C container record. Holds common
1148/// information associated with Objective-C containers.
1151
1153
1154 ObjCContainerRecord(RecordKind Kind, StringRef USR, StringRef Name,
1157 const DocComment &Comment,
1160 : APIRecord(Kind, USR, Name, Parent, Loc, std::move(Availability),
1163 RecordContext(Kind) {}
1164
1165 virtual ~ObjCContainerRecord() = 0;
1166};
1167
1170
1176 bool IsEmbeddedInVarDeclarator = false)
1177 : RecordRecord(Kind, USR, Name, Parent, Loc, std::move(Availability),
1180
1181 static bool classof(const APIRecord *Record) {
1182 return classofKind(Record->getKind());
1183 }
1184 static bool classofKind(RecordKind K) {
1185 return K == RK_CXXClass || K == RK_ClassTemplate ||
1188 }
1189
1190private:
1191 virtual void anchor();
1192};
1193
1196
1199 const DocComment &Comment,
1205 std::move(Access), IsFromSystemHeader),
1206 Templ(Template) {}
1207
1208 static bool classof(const APIRecord *Record) {
1209 return classofKind(Record->getKind());
1210 }
1211 static bool classofKind(RecordKind K) { return K == RK_ClassTemplate; }
1212};
1213
1216 StringRef USR, StringRef Name, SymbolReference Parent, PresumedLoc Loc,
1223
1224 static bool classof(const APIRecord *Record) {
1225 return classofKind(Record->getKind());
1226 }
1227 static bool classofKind(RecordKind K) {
1229 }
1230};
1231
1235 StringRef USR, StringRef Name, SymbolReference Parent, PresumedLoc Loc,
1243 Templ(Template) {}
1244
1245 static bool classof(const APIRecord *Record) {
1246 return classofKind(Record->getKind());
1247 }
1248 static bool classofKind(RecordKind K) {
1250 }
1251};
1252
1255
1260 bool IsFromSystemHeader)
1264 Templ(Template) {}
1265
1266 static bool classof(const APIRecord *Record) {
1267 return classofKind(Record->getKind());
1268 }
1269 static bool classofKind(RecordKind K) { return K == RK_Concept; }
1270};
1271
1272/// This holds information associated with Objective-C categories.
1275
1278 const DocComment &Comment,
1281 bool IsFromSystemHeader)
1283 std::move(Availability), LinkageInfo::none(),
1287
1288 static bool classof(const APIRecord *Record) {
1289 return classofKind(Record->getKind());
1290 }
1291 static bool classofKind(RecordKind K) { return K == RK_ObjCCategory; }
1292
1293 bool isExtendingExternalModule() const { return !Interface.Source.empty(); }
1294
1295 std::optional<StringRef> getExtendedExternalModule() const {
1297 return {};
1298 return Interface.Source;
1299 }
1300
1301private:
1302 virtual void anchor();
1303};
1304
1305/// This holds information associated with Objective-C interfaces/classes.
1308
1319
1320 static bool classof(const APIRecord *Record) {
1321 return classofKind(Record->getKind());
1322 }
1323 static bool classofKind(RecordKind K) { return K == RK_ObjCInterface; }
1324
1325private:
1326 virtual void anchor();
1327};
1328
1329/// This holds information associated with Objective-C protocols.
1333 const DocComment &Comment,
1337 std::move(Availability), LinkageInfo::none(),
1340
1341 static bool classof(const APIRecord *Record) {
1342 return classofKind(Record->getKind());
1343 }
1344 static bool classofKind(RecordKind K) { return K == RK_ObjCProtocol; }
1345
1346private:
1347 virtual void anchor();
1348};
1349
1350/// This holds information associated with macro definitions.
1355 bool IsFromSystemHeader)
1359
1360 static bool classof(const APIRecord *Record) {
1361 return classofKind(Record->getKind());
1362 }
1363 static bool classofKind(RecordKind K) { return K == RK_MacroDefinition; }
1364
1365private:
1366 virtual void anchor();
1367};
1368
1369/// This holds information associated with typedefs.
1370///
1371/// Note: Typedefs for anonymous enums and structs typically don't get emitted
1372/// by the serializers but still get a TypedefRecord. Instead we use the
1373/// typedef name as a name for the underlying anonymous struct or enum.
1376
1381 bool IsFromSystemHeader)
1386
1387 static bool classof(const APIRecord *Record) {
1388 return classofKind(Record->getKind());
1389 }
1390 static bool classofKind(RecordKind K) { return K == RK_Typedef; }
1391
1392private:
1393 virtual void anchor();
1394};
1395
1396/// APISet holds the set of API records collected from given inputs.
1397class APISet {
1398public:
1399 /// Get the target triple for the ExtractAPI invocation.
1400 const llvm::Triple &getTarget() const { return Target; }
1401
1402 /// Get the language used by the APIs.
1403 Language getLanguage() const { return Lang; }
1404
1405 /// Finds the APIRecord for a given USR.
1406 ///
1407 /// \returns a pointer to the APIRecord associated with that USR or nullptr.
1408 APIRecord *findRecordForUSR(StringRef USR) const;
1409
1410 /// Copy \p String into the Allocator in this APISet.
1411 ///
1412 /// \returns a StringRef of the copied string in APISet::Allocator.
1413 StringRef copyString(StringRef String);
1414
1415 SymbolReference createSymbolReference(StringRef Name, StringRef USR,
1416 StringRef Source = "");
1417
1418 /// Create a subclass of \p APIRecord and store it in the APISet.
1419 ///
1420 /// \returns A pointer to the created record or the already existing record
1421 /// matching this USR.
1422 template <typename RecordTy, typename... CtorArgsContTy>
1423 typename std::enable_if_t<std::is_base_of_v<APIRecord, RecordTy>, RecordTy> *
1424 createRecord(StringRef USR, StringRef Name, CtorArgsContTy &&...CtorArgs);
1425
1427 return TopLevelRecords;
1428 }
1429
1430 APISet(const llvm::Triple &Target, Language Lang,
1431 const std::string &ProductName)
1432 : Target(Target), Lang(Lang), ProductName(ProductName) {}
1433
1434 // Prevent moves and copies
1435 APISet(const APISet &Other) = delete;
1436 APISet &operator=(const APISet &Other) = delete;
1437 APISet(APISet &&Other) = delete;
1439
1440private:
1441 /// BumpPtrAllocator that serves as the memory arena for the allocated objects
1442 llvm::BumpPtrAllocator Allocator;
1443
1444 const llvm::Triple Target;
1445 const Language Lang;
1446
1447 struct APIRecordDeleter {
1448 void operator()(APIRecord *Record) { Record->~APIRecord(); }
1449 };
1450
1451 // Ensure that the destructor of each record is called when the LookupTable is
1452 // destroyed without calling delete operator as the memory for the record
1453 // lives in the BumpPtrAllocator.
1454 using APIRecordStoredPtr = std::unique_ptr<APIRecord, APIRecordDeleter>;
1455 llvm::DenseMap<StringRef, APIRecordStoredPtr> USRBasedLookupTable;
1456 std::vector<const APIRecord *> TopLevelRecords;
1457
1458public:
1459 const std::string ProductName;
1460};
1461
1462template <typename RecordTy, typename... CtorArgsContTy>
1463typename std::enable_if_t<std::is_base_of_v<APIRecord, RecordTy>, RecordTy> *
1464APISet::createRecord(StringRef USR, StringRef Name,
1465 CtorArgsContTy &&...CtorArgs) {
1466 // Ensure USR refers to a String stored in the allocator.
1467 auto USRString = copyString(USR);
1468 auto Result = USRBasedLookupTable.insert({USRString, nullptr});
1469 RecordTy *Record;
1470
1471 // Create the record if it does not already exist
1472 if (Result.second) {
1473 Record = new (Allocator) RecordTy(
1474 USRString, copyString(Name), std::forward<CtorArgsContTy>(CtorArgs)...);
1475 // Store the record in the record lookup map
1476 Result.first->second = APIRecordStoredPtr(Record);
1477
1478 if (auto *ParentContext =
1479 dyn_cast_if_present<RecordContext>(Record->Parent.Record))
1480 ParentContext->addToRecordChain(Record);
1481 else
1482 TopLevelRecords.push_back(Record);
1483 } else {
1484 Record = dyn_cast<RecordTy>(Result.first->second.get());
1485 }
1486
1487 return Record;
1488}
1489
1490// Helper type for implementing casting to RecordContext pointers.
1491// Selected when FromTy not a known subclass of RecordContext.
1492template <typename FromTy,
1493 bool IsKnownSubType = std::is_base_of_v<RecordContext, FromTy>>
1495 static_assert(std::is_base_of_v<APIRecord, FromTy>,
1496 "Can only cast APIRecord and derived classes to RecordContext");
1497
1498 static bool isPossible(FromTy *From) { return RecordContext::classof(From); }
1499
1500 static RecordContext *doCast(FromTy *From) {
1501 return APIRecord::castToRecordContext(From);
1502 }
1503};
1504
1505// Selected when FromTy is a known subclass of RecordContext.
1506template <typename FromTy> struct ToRecordContextCastInfoWrapper<FromTy, true> {
1507 static_assert(std::is_base_of_v<APIRecord, FromTy>,
1508 "Can only cast APIRecord and derived classes to RecordContext");
1509 static bool isPossible(const FromTy *From) { return true; }
1510 static RecordContext *doCast(FromTy *From) {
1511 return static_cast<RecordContext *>(From);
1512 }
1513};
1514
1515// Helper type for implementing casting to RecordContext pointers.
1516// Selected when ToTy isn't a known subclass of RecordContext
1517template <typename ToTy,
1518 bool IsKnownSubType = std::is_base_of_v<RecordContext, ToTy>>
1520 static_assert(
1521 std::is_base_of_v<APIRecord, ToTy>,
1522 "Can only class RecordContext to APIRecord and derived classes");
1523
1524 static bool isPossible(RecordContext *Ctx) {
1525 return ToTy::classofKind(Ctx->getKind());
1526 }
1527
1528 static ToTy *doCast(RecordContext *Ctx) {
1530 }
1531};
1532
1533// Selected when ToTy is a known subclass of RecordContext.
1534template <typename ToTy> struct FromRecordContextCastInfoWrapper<ToTy, true> {
1535 static_assert(
1536 std::is_base_of_v<APIRecord, ToTy>,
1537 "Can only class RecordContext to APIRecord and derived classes");
1538 static bool isPossible(RecordContext *Ctx) {
1539 return ToTy::classof(Ctx->getKind());
1540 }
1542 return static_cast<ToTy *>(Ctx);
1543 }
1544};
1545
1546} // namespace extractapi
1547} // namespace clang
1548
1549// Implement APIRecord (and derived classes) to and from RecordContext
1550// conversions
1551namespace llvm {
1552
1553template <typename FromTy>
1554struct CastInfo<::clang::extractapi::RecordContext, FromTy *>
1555 : public NullableValueCastFailed<::clang::extractapi::RecordContext *>,
1557 ::clang::extractapi::RecordContext *, FromTy *,
1558 CastInfo<::clang::extractapi::RecordContext, FromTy *>> {
1559 static inline bool isPossible(FromTy *From) {
1560 return ::clang::extractapi::ToRecordContextCastInfoWrapper<
1561 FromTy>::isPossible(From);
1562 }
1563
1564 static inline ::clang::extractapi::RecordContext *doCast(FromTy *From) {
1565 return ::clang::extractapi::ToRecordContextCastInfoWrapper<FromTy>::doCast(
1566 From);
1567 }
1568};
1569
1570template <typename FromTy>
1571struct CastInfo<::clang::extractapi::RecordContext, const FromTy *>
1573 ::clang::extractapi::RecordContext, const FromTy *,
1574 CastInfo<::clang::extractapi::RecordContext, FromTy *>> {};
1575
1576template <typename ToTy>
1577struct CastInfo<ToTy, ::clang::extractapi::RecordContext *>
1578 : public NullableValueCastFailed<ToTy *>,
1580 ToTy *, ::clang::extractapi::RecordContext *,
1581 CastInfo<ToTy, ::clang::extractapi::RecordContext *>> {
1583 return ::clang::extractapi::FromRecordContextCastInfoWrapper<
1584 ToTy>::isPossible(Ctx);
1585 }
1586
1587 static inline ToTy *doCast(::clang::extractapi::RecordContext *Ctx) {
1588 return ::clang::extractapi::FromRecordContextCastInfoWrapper<ToTy>::doCast(
1589 Ctx);
1590 }
1591};
1592
1593template <typename ToTy>
1594struct CastInfo<ToTy, const ::clang::extractapi::RecordContext *>
1596 ToTy, const ::clang::extractapi::RecordContext *,
1597 CastInfo<ToTy, ::clang::extractapi::RecordContext *>> {};
1598
1599} // namespace llvm
1600
1601#endif // LLVM_CLANG_EXTRACTAPI_API_H
This file defines the Declaration Fragments related classes.
llvm::MachO::Target Target
Definition: MachO.h:50
llvm::MachO::Record Record
Definition: MachO.h:31
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:1813
APISet holds the set of API records collected from given inputs.
Definition: API.h:1397
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:1464
APISet & operator=(const APISet &Other)=delete
SymbolReference createSymbolReference(StringRef Name, StringRef USR, StringRef Source="")
Definition: API.cpp:113
Language getLanguage() const
Get the language used by the APIs.
Definition: API.h:1403
ArrayRef< const APIRecord * > getTopLevelRecords() const
Definition: API.h:1426
const std::string ProductName
Definition: API.h:1459
APISet(const APISet &Other)=delete
StringRef copyString(StringRef String)
Copy String into the Allocator in this APISet.
Definition: API.cpp:100
APISet(APISet &&Other)=delete
const llvm::Triple & getTarget() const
Get the target triple for the ExtractAPI invocation.
Definition: API.h:1400
APISet & operator=(APISet &&Other)=delete
APIRecord * findRecordForUSR(StringRef USR) const
Finds the APIRecord for a given USR.
Definition: API.cpp:89
APISet(const llvm::Triple &Target, Language Lang, const std::string &ProductName)
Definition: API.h:1430
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:310
record_iterator records_begin() const
Definition: API.h:369
bool records_empty() const
Definition: API.h:371
static bool classof(const RecordContext *Context)
Definition: API.h:320
llvm::iterator_range< record_iterator > record_range
Definition: API.h:365
APIRecord::RecordKind getKind() const
Definition: API.h:328
record_range records() const
Definition: API.h:366
void stealRecordChain(RecordContext &Other)
Append Other children chain into ours and empty out Other's record chain.
Definition: API.cpp:62
record_iterator records_end() const
Definition: API.h:370
static bool classofKind(APIRecord::RecordKind K)
Definition: API.h:315
void addToRecordChain(APIRecord *) const
Definition: API.cpp:77
RecordContext(APIRecord::RecordKind Kind)
Definition: API.h:322
static bool classof(const APIRecord *Record)
Definition: API.h:312
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
Definition: Format.h:5428
#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:279
APIRecord(RecordKind Kind, StringRef USR, StringRef Name)
Definition: API.h:298
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
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:286
LinkageInfo Linkage
Definition: API.h:248
virtual ~APIRecord()=0
Definition: API.cpp:118
DeclarationFragments SubHeading
SubHeading provides a more detailed representation than the plain declaration name.
Definition: API.h:262
APIRecord * getNextInContext() const
Definition: API.h:277
static APIRecord * castFromRecordContext(const RecordContext *Ctx)
Definition: API.cpp:29
AccessControl Access
Definition: API.h:267
PresumedLoc Location
Definition: API.h:246
static bool classofKind(RecordKind K)
Definition: API.h:304
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:42
SymbolReference Parent
Definition: API.h:244
static bool classof(const RecordContext *Ctx)
Definition: API.h:305
bool IsFromSystemHeader
Whether the symbol was defined in a system header.
Definition: API.h:265
static bool classof(const APIRecord *Record)
Definition: API.h:303
SmallVector< SymbolReference > Bases
Definition: API.h:1169
static bool classofKind(RecordKind K)
Definition: API.h:1184
static bool classof(const APIRecord *Record)
Definition: API.h:1181
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:1171
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:845
static bool classof(const APIRecord *Record)
Definition: API.h:856
static bool classofKind(RecordKind K)
Definition: API.h:859
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:866
static bool classofKind(RecordKind K)
Definition: API.h:880
static bool classof(const APIRecord *Record)
Definition: API.h:877
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:773
static bool classofKind(RecordKind K)
Definition: API.h:797
static bool classof(const APIRecord *Record)
Definition: API.h:794
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:783
static bool classof(const APIRecord *Record)
Definition: API.h:819
static bool classofKind(RecordKind K)
Definition: API.h:822
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:808
static bool classof(const APIRecord *Record)
Definition: API.h:920
static bool classofKind(RecordKind K)
Definition: API.h:923
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:908
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:830
FunctionSignature Signature
Definition: API.h:826
static bool classofKind(RecordKind K)
Definition: API.h:948
static bool classof(const APIRecord *Record)
Definition: API.h:945
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:932
static bool classof(const APIRecord *Record)
Definition: API.h:963
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:952
static bool classof(const APIRecord *Record)
Definition: API.h:898
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:887
static bool classofKind(RecordKind K)
Definition: API.h:901
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:1234
static bool classof(const APIRecord *Record)
Definition: API.h:1245
static bool classof(const APIRecord *Record)
Definition: API.h:1208
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:1197
static bool classofKind(RecordKind K)
Definition: API.h:1211
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:1215
static bool classof(const APIRecord *Record)
Definition: API.h:1224
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:1256
static bool classof(const APIRecord *Record)
Definition: API.h:1266
static bool classofKind(RecordKind K)
Definition: API.h:1269
This holds information associated with enum constants.
Definition: API.h:585
EnumConstantRecord(StringRef USR, StringRef Name, SymbolReference Parent, PresumedLoc Loc, AvailabilityInfo Availability, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading, bool IsFromSystemHeader)
Definition: API.h:586
static bool classofKind(RecordKind K)
Definition: API.h:598
static bool classof(const APIRecord *Record)
Definition: API.h:595
This holds information associated with enums.
Definition: API.h:630
static bool classof(const APIRecord *Record)
Definition: API.h:641
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:631
static bool classofKind(RecordKind K)
Definition: API.h:645
static RecordContext * doCast(RecordContext *Ctx)
Definition: API.h:1541
static ToTy * doCast(RecordContext *Ctx)
Definition: API.h:1528
static bool isPossible(RecordContext *Ctx)
Definition: API.h:1524
This holds information associated with global functions.
Definition: API.h:402
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:416
static bool classof(const APIRecord *Record)
Definition: API.h:428
static bool classofKind(RecordKind K)
Definition: API.h:431
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:405
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:440
static bool classofKind(RecordKind K)
Definition: API.h:457
static bool classof(const APIRecord *Record)
Definition: API.h:454
static bool classof(const APIRecord *Record)
Definition: API.h:474
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:463
This holds information associated with global functions.
Definition: API.h:483
static bool classof(const APIRecord *Record)
Definition: API.h:505
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:494
static bool classofKind(RecordKind K)
Definition: API.h:508
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:484
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:564
static bool classof(const APIRecord *Record)
Definition: API.h:533
static bool classofKind(RecordKind K)
Definition: API.h:536
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:521
static bool classof(const APIRecord *Record)
Definition: API.h:552
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:542
This holds information associated with macro definitions.
Definition: API.h:1351
static bool classof(const APIRecord *Record)
Definition: API.h:1360
MacroDefinitionRecord(StringRef USR, StringRef Name, SymbolReference Parent, PresumedLoc Loc, DeclarationFragments Declaration, DeclarationFragments SubHeading, bool IsFromSystemHeader)
Definition: API.h:1352
static bool classofKind(RecordKind K)
Definition: API.h:1363
static bool classof(const APIRecord *Record)
Definition: API.h:395
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:385
static bool classofKind(RecordKind K)
Definition: API.h:398
This holds information associated with Objective-C categories.
Definition: API.h:1273
static bool classofKind(RecordKind K)
Definition: API.h:1291
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:1276
std::optional< StringRef > getExtendedExternalModule() const
Definition: API.h:1295
bool isExtendingExternalModule() const
Definition: API.h:1293
static bool classof(const APIRecord *Record)
Definition: API.h:1288
static bool classofKind(RecordKind K)
Definition: API.h:1124
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:1111
static bool classof(const APIRecord *Record)
Definition: API.h:1121
static bool classof(const APIRecord *Record)
Definition: API.h:1039
static bool classofKind(RecordKind K)
Definition: API.h:1042
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:1026
The base representation of an Objective-C container record.
Definition: API.h:1149
SmallVector< SymbolReference > Protocols
Definition: API.h:1150
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:1154
static bool classofKind(RecordKind K)
Definition: API.h:1104
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:1091
static bool classof(const APIRecord *Record)
Definition: API.h:1101
static bool classof(const APIRecord *Record)
Definition: API.h:1016
static bool classofKind(RecordKind K)
Definition: API.h:1019
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:1005
This holds information associated with Objective-C instance variables.
Definition: API.h:1049
static bool classofKind(RecordKind K)
Definition: API.h:1064
ObjCInstanceVariableRecord(StringRef USR, StringRef Name, SymbolReference Parent, PresumedLoc Loc, AvailabilityInfo Availability, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading, bool IsFromSystemHeader)
Definition: API.h:1050
static bool classof(const APIRecord *Record)
Definition: API.h:1061
This holds information associated with Objective-C interfaces/classes.
Definition: API.h:1306
static bool classof(const APIRecord *Record)
Definition: API.h:1320
static bool classofKind(RecordKind K)
Definition: API.h:1323
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:1309
This holds information associated with Objective-C methods.
Definition: API.h:1071
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:1076
FunctionSignature Signature
Definition: API.h:1072
This holds information associated with Objective-C properties.
Definition: API.h:972
AttributeKind
The attributes associated with an Objective-C property.
Definition: API.h:974
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:985
This holds information associated with Objective-C protocols.
Definition: API.h:1330
static bool classof(const APIRecord *Record)
Definition: API.h:1341
static bool classofKind(RecordKind K)
Definition: API.h:1344
ObjCProtocolRecord(StringRef USR, StringRef Name, SymbolReference Parent, PresumedLoc Loc, AvailabilityInfo Availability, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading, bool IsFromSystemHeader)
Definition: API.h:1331
std::forward_iterator_tag iterator_category
Definition: API.h:338
friend bool operator==(record_iterator x, record_iterator y)
Definition: API.h:357
friend bool operator!=(record_iterator x, record_iterator y)
Definition: API.h:360
This holds information associated with struct or union fields fields.
Definition: API.h:652
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:653
static bool classofKind(RecordKind K)
Definition: API.h:666
static bool classof(const APIRecord *Record)
Definition: API.h:663
This holds information associated with structs and unions.
Definition: API.h:674
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:675
static bool classof(const APIRecord *Record)
Definition: API.h:686
static bool classofKind(RecordKind K)
Definition: API.h:689
static bool classof(const APIRecord *Record)
Definition: API.h:1141
static bool classofKind(RecordKind K)
Definition: API.h:1144
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:1131
static bool classof(const APIRecord *Record)
Definition: API.h:707
static bool classofKind(RecordKind K)
Definition: API.h:710
StructFieldRecord(StringRef USR, StringRef Name, SymbolReference Parent, PresumedLoc Loc, AvailabilityInfo Availability, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading, bool IsFromSystemHeader)
Definition: API.h:699
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:717
static bool classof(const APIRecord *Record)
Definition: API.h:726
static bool classofKind(RecordKind K)
Definition: API.h:729
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:617
static bool classofKind(RecordKind K)
Definition: API.h:620
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:605
virtual ~TagRecord()=0
Definition: API.cpp:119
static RecordContext * doCast(FromTy *From)
Definition: API.h:1500
static bool isPossible(FromTy *From)
Definition: API.h:1498
This holds information associated with typedefs.
Definition: API.h:1374
static bool classofKind(RecordKind K)
Definition: API.h:1390
SymbolReference UnderlyingType
Definition: API.h:1375
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:1377
static bool classof(const APIRecord *Record)
Definition: API.h:1387
static bool classofKind(RecordKind K)
Definition: API.h:747
static bool classof(const APIRecord *Record)
Definition: API.h:744
UnionFieldRecord(StringRef USR, StringRef Name, SymbolReference Parent, PresumedLoc Loc, AvailabilityInfo Availability, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading, bool IsFromSystemHeader)
Definition: API.h:736
static bool classof(const APIRecord *Record)
Definition: API.h:763
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:754
static bool classofKind(RecordKind K)
Definition: API.h:766
static ToTy * doCast(::clang::extractapi::RecordContext *Ctx)
Definition: API.h:1587
static bool isPossible(::clang::extractapi::RecordContext *Ctx)
Definition: API.h:1582
static inline ::clang::extractapi::RecordContext * doCast(FromTy *From)
Definition: API.h:1564