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 APIRecord::RecordKind getKind() const { return Kind; }
325
327 private:
328 APIRecord *Current = nullptr;
329
330 public:
332 using reference = const value_type &;
333 using pointer = const value_type *;
334 using iterator_category = std::forward_iterator_tag;
335 using difference_type = std::ptrdiff_t;
336
337 record_iterator() = default;
338 explicit record_iterator(value_type R) : Current(R) {}
339 reference operator*() const { return Current; }
340 // This doesn't strictly meet the iterator requirements, but it's the
341 // behavior we want here.
342 value_type operator->() const { return Current; }
344 Current = Current->getNextInContext();
345 return *this;
346 }
348 record_iterator tmp(*this);
349 ++(*this);
350 return tmp;
351 }
352
354 return x.Current == y.Current;
355 }
357 return x.Current != y.Current;
358 }
359 };
360
361 using record_range = llvm::iterator_range<record_iterator>;
364 }
367 bool records_empty() const { return First == nullptr; };
368
369private:
371 mutable APIRecord *First = nullptr;
372 mutable APIRecord *Last = nullptr;
373
374protected:
375 friend class APISet;
376 void addToRecordChain(APIRecord *) const;
377};
378
389
390 static bool classof(const APIRecord *Record) {
391 return classofKind(Record->getKind());
392 }
393 static bool classofKind(RecordKind K) { return K == RK_Namespace; }
394};
395
396/// This holds information associated with global functions.
399
410
411 GlobalFunctionRecord(RecordKind Kind, StringRef USR, StringRef Name,
414 const DocComment &Comment,
418 : APIRecord(Kind, USR, Name, Parent, Loc, std::move(Availability),
422
423 static bool classof(const APIRecord *Record) {
424 return classofKind(Record->getKind());
425 }
426 static bool classofKind(RecordKind K) { return K == RK_GlobalFunction; }
427
428private:
429 virtual void anchor();
430};
431
434
447 Templ(Template) {}
448
449 static bool classof(const APIRecord *Record) {
450 return classofKind(Record->getKind());
451 }
452 static bool classofKind(RecordKind K) {
453 return K == RK_GlobalFunctionTemplate;
454 }
455};
456
459 StringRef USR, StringRef Name, SymbolReference Parent, PresumedLoc Loc,
465 Parent, Loc, std::move(Availability), Linkage,
468
469 static bool classof(const APIRecord *Record) {
470 return classofKind(Record->getKind());
471 }
472 static bool classofKind(RecordKind K) {
474 }
475};
476
477/// This holds information associated with global functions.
487
488 GlobalVariableRecord(RecordKind Kind, StringRef USR, StringRef Name,
490
495 : APIRecord(Kind, USR, Name, Parent, Loc, std::move(Availability),
498
499 static bool classof(const APIRecord *Record) {
500 return classofKind(Record->getKind());
501 }
502 static bool classofKind(RecordKind K) { return K == RK_GlobalVariable; }
503
504private:
505 virtual void anchor();
506};
507
510
521 Templ(Template) {}
522
523 static bool classof(const APIRecord *Record) {
524 return classofKind(Record->getKind());
525 }
526 static bool classofKind(RecordKind K) {
527 return K == RK_GlobalVariableTemplate;
528 }
529};
530
533 StringRef USR, StringRef Name, SymbolReference Parent, PresumedLoc Loc,
538 Parent, Loc, std::move(Availability), Linkage,
541
542 static bool classof(const APIRecord *Record) {
543 return classofKind(Record->getKind());
544 }
545 static bool classofKind(RecordKind K) {
547 }
548};
549
553
555 StringRef USR, StringRef Name, SymbolReference Parent, PresumedLoc Loc,
561 USR, Name, Parent, Loc, std::move(Availability),
564 Templ(Template) {}
565
566 static bool classof(const APIRecord *Record) {
567 return classofKind(Record->getKind());
568 }
569 static bool classofKind(RecordKind K) {
571 }
572};
573
574/// This holds information associated with enum constants.
578 const DocComment &Comment,
582 std::move(Availability), LinkageInfo::none(), Comment,
584
585 static bool classof(const APIRecord *Record) {
586 return classofKind(Record->getKind());
587 }
588 static bool classofKind(RecordKind K) { return K == RK_EnumConstant; }
589
590private:
591 virtual void anchor();
592};
593
594/// This holds information associated with enums.
596 EnumRecord(StringRef USR, StringRef Name, SymbolReference Parent,
600 : APIRecord(RK_Enum, USR, Name, Parent, Loc, std::move(Availability),
604
605 static bool classof(const APIRecord *Record) {
606 return classofKind(Record->getKind());
607 }
608 static bool classofKind(RecordKind K) { return K == RK_Enum; }
609
610private:
611 virtual void anchor();
612};
613
614/// This holds information associated with struct or union fields fields.
616 RecordFieldRecord(RecordKind Kind, StringRef USR, StringRef Name,
621 : APIRecord(Kind, USR, Name, Parent, Loc, std::move(Availability),
624
625 static bool classof(const APIRecord *Record) {
626 return classofKind(Record->getKind());
627 }
628 static bool classofKind(RecordKind K) {
629 return K == RK_StructField || K == RK_UnionField;
630 }
631
632 virtual ~RecordFieldRecord() = 0;
633};
634
635/// This holds information associated with structs and unions.
637 RecordRecord(RecordKind Kind, StringRef USR, StringRef Name,
642 : APIRecord(Kind, USR, Name, Parent, Loc, std::move(Availability),
645 RecordContext(Kind) {}
646
647 static bool classof(const APIRecord *Record) {
648 return classofKind(Record->getKind());
649 }
650 static bool classofKind(RecordKind K) {
651 return K == RK_Struct || K == RK_Union;
652 }
653
654 virtual ~RecordRecord() = 0;
655};
656
665
666 static bool classof(const APIRecord *Record) {
667 return classofKind(Record->getKind());
668 }
669 static bool classofKind(RecordKind K) { return K == RK_StructField; }
670
671private:
672 virtual void anchor();
673};
674
682
683 static bool classof(const APIRecord *Record) {
684 return classofKind(Record->getKind());
685 }
686 static bool classofKind(RecordKind K) { return K == RK_Struct; }
687
688private:
689 virtual void anchor();
690};
691
700
701 static bool classof(const APIRecord *Record) {
702 return classofKind(Record->getKind());
703 }
704 static bool classofKind(RecordKind K) { return K == RK_UnionField; }
705
706private:
707 virtual void anchor();
708};
709
717
718 static bool classof(const APIRecord *Record) {
719 return classofKind(Record->getKind());
720 }
721 static bool classofKind(RecordKind K) { return K == RK_Union; }
722
723private:
724 virtual void anchor();
725};
726
735 IsFromSystemHeader, std::move(Access)) {}
736
737 CXXFieldRecord(RecordKind Kind, StringRef USR, StringRef Name,
743 : APIRecord(Kind, USR, Name, Parent, Loc, std::move(Availability),
745 IsFromSystemHeader, std::move(Access)) {}
746
747 static bool classof(const APIRecord *Record) {
748 return classofKind(Record->getKind());
749 }
750 static bool classofKind(RecordKind K) {
751 return K == RK_CXXField || K == RK_CXXFieldTemplate || K == RK_StaticField;
752 }
753
754private:
755 virtual void anchor();
756};
757
760
763 const DocComment &Comment,
770 Templ(Template) {}
771
772 static bool classof(const APIRecord *Record) {
773 return classofKind(Record->getKind());
774 }
775 static bool classofKind(RecordKind K) { return K == RK_CXXFieldTemplate; }
776};
777
780
781 CXXMethodRecord() = delete;
782
783 CXXMethodRecord(RecordKind Kind, StringRef USR, StringRef Name,
789 : APIRecord(Kind, USR, Name, Parent, Loc, std::move(Availability),
793
794 virtual ~CXXMethodRecord() = 0;
795};
796
800 const DocComment &Comment,
809 static bool classof(const APIRecord *Record) {
810 return classofKind(Record->getKind());
811 }
812 static bool classofKind(RecordKind K) { return K == RK_CXXConstructorMethod; }
813
814private:
815 virtual void anchor();
816};
817
821 const DocComment &Comment,
830 static bool classof(const APIRecord *Record) {
831 return classofKind(Record->getKind());
832 }
833 static bool classofKind(RecordKind K) { return K == RK_CXXDestructorMethod; }
834
835private:
836 virtual void anchor();
837};
838
842 const DocComment &Comment,
851 static bool classof(const APIRecord *Record) {
852 return classofKind(Record->getKind());
853 }
854 static bool classofKind(RecordKind K) { return K == RK_CXXStaticMethod; }
855
856private:
857 virtual void anchor();
858};
859
863 const DocComment &Comment,
872
873 static bool classof(const APIRecord *Record) {
874 return classofKind(Record->getKind());
875 }
876 static bool classofKind(RecordKind K) { return K == RK_CXXInstanceMethod; }
877
878private:
879 virtual void anchor();
880};
881
884
887 const DocComment &Comment,
896 Templ(Template) {}
897
898 static bool classof(const APIRecord *Record) {
899 return classofKind(Record->getKind());
900 }
901 static bool classofKind(RecordKind K) { return K == RK_CXXMethodTemplate; }
902};
903
906 StringRef USR, StringRef Name, SymbolReference Parent, PresumedLoc Loc,
912 Loc, std::move(Availability), Comment, Declaration,
915
916 static bool classof(const APIRecord *Record) {
917 return classofKind(Record->getKind());
918 }
919 static bool classofKind(RecordKind K) {
921 }
922};
923
924/// This holds information associated with Objective-C properties.
926 /// The attributes associated with an Objective-C property.
927 enum AttributeKind : unsigned {
930 Dynamic = 1 << 2,
931 };
932
934 StringRef GetterName;
935 StringRef SetterName;
937
938 ObjCPropertyRecord(RecordKind Kind, StringRef USR, StringRef Name,
943 StringRef GetterName, StringRef SetterName,
945 : APIRecord(Kind, USR, Name, Parent, Loc, std::move(Availability),
950
951 bool isReadOnly() const { return Attributes & ReadOnly; }
952 bool isDynamic() const { return Attributes & Dynamic; }
953
954 virtual ~ObjCPropertyRecord() = 0;
955};
956
959 StringRef USR, StringRef Name, SymbolReference Parent, PresumedLoc Loc,
962 AttributeKind Attributes, StringRef GetterName, StringRef SetterName,
968
969 static bool classof(const APIRecord *Record) {
970 return classofKind(Record->getKind());
971 }
972 static bool classofKind(RecordKind K) { return K == RK_ObjCInstanceProperty; }
973
974private:
975 virtual void anchor();
976};
977
981 const DocComment &Comment,
985 StringRef SetterName, bool IsOptional,
991
992 static bool classof(const APIRecord *Record) {
993 return classofKind(Record->getKind());
994 }
995 static bool classofKind(RecordKind K) { return K == RK_ObjCClassProperty; }
996
997private:
998 virtual void anchor();
999};
1000
1001/// This holds information associated with Objective-C instance variables.
1006 const DocComment &Comment,
1009 bool IsFromSystemHeader)
1013
1014 static bool classof(const APIRecord *Record) {
1015 return classofKind(Record->getKind());
1016 }
1017 static bool classofKind(RecordKind K) { return K == RK_ObjCIvar; }
1018
1019private:
1020 virtual void anchor();
1021};
1022
1023/// This holds information associated with Objective-C methods.
1026
1028
1029 ObjCMethodRecord(RecordKind Kind, StringRef USR, StringRef Name,
1034 bool IsFromSystemHeader)
1035 : APIRecord(Kind, USR, Name, Parent, Loc, std::move(Availability),
1039
1040 virtual ~ObjCMethodRecord() = 0;
1041};
1042
1044 ObjCInstanceMethodRecord(StringRef USR, StringRef Name,
1047 const DocComment &Comment,
1054 static bool classof(const APIRecord *Record) {
1055 return classofKind(Record->getKind());
1056 }
1057 static bool classofKind(RecordKind K) { return K == RK_ObjCInstanceMethod; }
1058
1059private:
1060 virtual void anchor();
1061};
1062
1066 const DocComment &Comment,
1073
1074 static bool classof(const APIRecord *Record) {
1075 return classofKind(Record->getKind());
1076 }
1077 static bool classofKind(RecordKind K) { return K == RK_ObjCClassMethod; }
1078
1079private:
1080 virtual void anchor();
1081};
1082
1089 bool IsFromSystemHeader)
1093
1094 static bool classof(const APIRecord *Record) {
1095 return classofKind(Record->getKind());
1096 }
1097 static bool classofKind(RecordKind K) { return K == RK_StaticField; }
1098};
1099
1100/// The base representation of an Objective-C container record. Holds common
1101/// information associated with Objective-C containers.
1104
1106
1107 ObjCContainerRecord(RecordKind Kind, StringRef USR, StringRef Name,
1110 const DocComment &Comment,
1113 : APIRecord(Kind, USR, Name, Parent, Loc, std::move(Availability),
1116 RecordContext(Kind) {}
1117
1118 virtual ~ObjCContainerRecord() = 0;
1119};
1120
1123
1129 : APIRecord(Kind, USR, Name, Parent, Loc, std::move(Availability),
1131 IsFromSystemHeader, std::move(Access)),
1132 RecordContext(Kind) {}
1133
1134 static bool classof(const APIRecord *Record) {
1135 return classofKind(Record->getKind());
1136 }
1137 static bool classofKind(RecordKind K) {
1138 return K == RK_CXXClass || K == RK_ClassTemplate ||
1141 }
1142
1143private:
1144 virtual void anchor();
1145};
1146
1149
1152 const DocComment &Comment,
1158 std::move(Access), IsFromSystemHeader),
1159 Templ(Template) {}
1160
1161 static bool classof(const APIRecord *Record) {
1162 return classofKind(Record->getKind());
1163 }
1164 static bool classofKind(RecordKind K) { return K == RK_ClassTemplate; }
1165};
1166
1169 StringRef USR, StringRef Name, SymbolReference Parent, PresumedLoc Loc,
1176
1177 static bool classof(const APIRecord *Record) {
1178 return classofKind(Record->getKind());
1179 }
1180 static bool classofKind(RecordKind K) {
1182 }
1183};
1184
1188 StringRef USR, StringRef Name, SymbolReference Parent, PresumedLoc Loc,
1196 Templ(Template) {}
1197
1198 static bool classof(const APIRecord *Record) {
1199 return classofKind(Record->getKind());
1200 }
1201 static bool classofKind(RecordKind K) {
1203 }
1204};
1205
1208
1213 bool IsFromSystemHeader)
1217 Templ(Template) {}
1218
1219 static bool classof(const APIRecord *Record) {
1220 return classofKind(Record->getKind());
1221 }
1222 static bool classofKind(RecordKind K) { return K == RK_Concept; }
1223};
1224
1225/// This holds information associated with Objective-C categories.
1228
1231 const DocComment &Comment,
1234 bool IsFromSystemHeader)
1236 std::move(Availability), LinkageInfo::none(),
1240
1241 static bool classof(const APIRecord *Record) {
1242 return classofKind(Record->getKind());
1243 }
1244 static bool classofKind(RecordKind K) { return K == RK_ObjCCategory; }
1245
1246 bool isExtendingExternalModule() const { return !Interface.Source.empty(); }
1247
1248 std::optional<StringRef> getExtendedExternalModule() const {
1250 return {};
1251 return Interface.Source;
1252 }
1253
1254private:
1255 virtual void anchor();
1256};
1257
1258/// This holds information associated with Objective-C interfaces/classes.
1261
1272
1273 static bool classof(const APIRecord *Record) {
1274 return classofKind(Record->getKind());
1275 }
1276 static bool classofKind(RecordKind K) { return K == RK_ObjCInterface; }
1277
1278private:
1279 virtual void anchor();
1280};
1281
1282/// This holds information associated with Objective-C protocols.
1286 const DocComment &Comment,
1290 std::move(Availability), LinkageInfo::none(),
1293
1294 static bool classof(const APIRecord *Record) {
1295 return classofKind(Record->getKind());
1296 }
1297 static bool classofKind(RecordKind K) { return K == RK_ObjCProtocol; }
1298
1299private:
1300 virtual void anchor();
1301};
1302
1303/// This holds information associated with macro definitions.
1308 bool IsFromSystemHeader)
1312
1313 static bool classof(const APIRecord *Record) {
1314 return classofKind(Record->getKind());
1315 }
1316 static bool classofKind(RecordKind K) { return K == RK_MacroDefinition; }
1317
1318private:
1319 virtual void anchor();
1320};
1321
1322/// This holds information associated with typedefs.
1323///
1324/// Note: Typedefs for anonymous enums and structs typically don't get emitted
1325/// by the serializers but still get a TypedefRecord. Instead we use the
1326/// typedef name as a name for the underlying anonymous struct or enum.
1329
1334 bool IsFromSystemHeader)
1339
1340 static bool classof(const APIRecord *Record) {
1341 return classofKind(Record->getKind());
1342 }
1343 static bool classofKind(RecordKind K) { return K == RK_Typedef; }
1344
1345private:
1346 virtual void anchor();
1347};
1348
1349/// APISet holds the set of API records collected from given inputs.
1350class APISet {
1351public:
1352 /// Get the target triple for the ExtractAPI invocation.
1353 const llvm::Triple &getTarget() const { return Target; }
1354
1355 /// Get the language used by the APIs.
1356 Language getLanguage() const { return Lang; }
1357
1358 /// Finds the APIRecord for a given USR.
1359 ///
1360 /// \returns a pointer to the APIRecord associated with that USR or nullptr.
1361 APIRecord *findRecordForUSR(StringRef USR) const;
1362
1363 /// Copy \p String into the Allocator in this APISet.
1364 ///
1365 /// \returns a StringRef of the copied string in APISet::Allocator.
1366 StringRef copyString(StringRef String);
1367
1368 SymbolReference createSymbolReference(StringRef Name, StringRef USR,
1369 StringRef Source = "");
1370
1371 /// Create a subclass of \p APIRecord and store it in the APISet.
1372 ///
1373 /// \returns A pointer to the created record or the already existing record
1374 /// matching this USR.
1375 template <typename RecordTy, typename... CtorArgsContTy>
1376 typename std::enable_if_t<std::is_base_of_v<APIRecord, RecordTy>, RecordTy> *
1377 createRecord(StringRef USR, StringRef Name, CtorArgsContTy &&...CtorArgs);
1378
1380 return TopLevelRecords;
1381 }
1382
1383 APISet(const llvm::Triple &Target, Language Lang,
1384 const std::string &ProductName)
1385 : Target(Target), Lang(Lang), ProductName(ProductName) {}
1386
1387 // Prevent moves and copies
1388 APISet(const APISet &Other) = delete;
1389 APISet &operator=(const APISet &Other) = delete;
1390 APISet(APISet &&Other) = delete;
1392
1393private:
1394 /// BumpPtrAllocator that serves as the memory arena for the allocated objects
1395 llvm::BumpPtrAllocator Allocator;
1396
1397 const llvm::Triple Target;
1398 const Language Lang;
1399
1400 struct APIRecordDeleter {
1401 void operator()(APIRecord *Record) { Record->~APIRecord(); }
1402 };
1403
1404 // Ensure that the destructor of each record is called when the LookupTable is
1405 // destroyed without calling delete operator as the memory for the record
1406 // lives in the BumpPtrAllocator.
1407 using APIRecordStoredPtr = std::unique_ptr<APIRecord, APIRecordDeleter>;
1408 llvm::DenseMap<StringRef, APIRecordStoredPtr> USRBasedLookupTable;
1409 std::vector<const APIRecord *> TopLevelRecords;
1410
1411public:
1412 const std::string ProductName;
1413};
1414
1415template <typename RecordTy, typename... CtorArgsContTy>
1416typename std::enable_if_t<std::is_base_of_v<APIRecord, RecordTy>, RecordTy> *
1417APISet::createRecord(StringRef USR, StringRef Name,
1418 CtorArgsContTy &&...CtorArgs) {
1419 // Ensure USR refers to a String stored in the allocator.
1420 auto USRString = copyString(USR);
1421 auto Result = USRBasedLookupTable.insert({USRString, nullptr});
1422 RecordTy *Record;
1423
1424 // Create the record if it does not already exist
1425 if (Result.second) {
1426 Record = new (Allocator) RecordTy(
1427 USRString, copyString(Name), std::forward<CtorArgsContTy>(CtorArgs)...);
1428 // Store the record in the record lookup map
1429 Result.first->second = APIRecordStoredPtr(Record);
1430
1431 if (auto *ParentContext =
1432 dyn_cast_if_present<RecordContext>(Record->Parent.Record))
1433 ParentContext->addToRecordChain(Record);
1434 else
1435 TopLevelRecords.push_back(Record);
1436 } else {
1437 Record = dyn_cast<RecordTy>(Result.first->second.get());
1438 }
1439
1440 return Record;
1441}
1442
1443// Helper type for implementing casting to RecordContext pointers.
1444// Selected when FromTy not a known subclass of RecordContext.
1445template <typename FromTy,
1446 bool IsKnownSubType = std::is_base_of_v<RecordContext, FromTy>>
1448 static_assert(std::is_base_of_v<APIRecord, FromTy>,
1449 "Can only cast APIRecord and derived classes to RecordContext");
1450
1451 static bool isPossible(FromTy *From) { return RecordContext::classof(From); }
1452
1453 static RecordContext *doCast(FromTy *From) {
1454 return APIRecord::castToRecordContext(From);
1455 }
1456};
1457
1458// Selected when FromTy is a known subclass of RecordContext.
1459template <typename FromTy> struct ToRecordContextCastInfoWrapper<FromTy, true> {
1460 static_assert(std::is_base_of_v<APIRecord, FromTy>,
1461 "Can only cast APIRecord and derived classes to RecordContext");
1462 static bool isPossible(const FromTy *From) { return true; }
1463 static RecordContext *doCast(FromTy *From) {
1464 return static_cast<RecordContext *>(From);
1465 }
1466};
1467
1468// Helper type for implementing casting to RecordContext pointers.
1469// Selected when ToTy isn't a known subclass of RecordContext
1470template <typename ToTy,
1471 bool IsKnownSubType = std::is_base_of_v<RecordContext, ToTy>>
1473 static_assert(
1474 std::is_base_of_v<APIRecord, ToTy>,
1475 "Can only class RecordContext to APIRecord and derived classes");
1476
1477 static bool isPossible(RecordContext *Ctx) {
1478 return ToTy::classofKind(Ctx->getKind());
1479 }
1480
1481 static ToTy *doCast(RecordContext *Ctx) {
1483 }
1484};
1485
1486// Selected when ToTy is a known subclass of RecordContext.
1487template <typename ToTy> struct FromRecordContextCastInfoWrapper<ToTy, true> {
1488 static_assert(
1489 std::is_base_of_v<APIRecord, ToTy>,
1490 "Can only class RecordContext to APIRecord and derived classes");
1491 static bool isPossible(RecordContext *Ctx) {
1492 return ToTy::classof(Ctx->getKind());
1493 }
1495 return static_cast<ToTy *>(Ctx);
1496 }
1497};
1498
1499} // namespace extractapi
1500} // namespace clang
1501
1502// Implement APIRecord (and derived classes) to and from RecordContext
1503// conversions
1504namespace llvm {
1505
1506template <typename FromTy>
1507struct CastInfo<::clang::extractapi::RecordContext, FromTy *>
1508 : public NullableValueCastFailed<::clang::extractapi::RecordContext *>,
1510 ::clang::extractapi::RecordContext *, FromTy *,
1511 CastInfo<::clang::extractapi::RecordContext, FromTy *>> {
1512 static inline bool isPossible(FromTy *From) {
1513 return ::clang::extractapi::ToRecordContextCastInfoWrapper<
1514 FromTy>::isPossible(From);
1515 }
1516
1517 static inline ::clang::extractapi::RecordContext *doCast(FromTy *From) {
1518 return ::clang::extractapi::ToRecordContextCastInfoWrapper<FromTy>::doCast(
1519 From);
1520 }
1521};
1522
1523template <typename FromTy>
1524struct CastInfo<::clang::extractapi::RecordContext, const FromTy *>
1526 ::clang::extractapi::RecordContext, const FromTy *,
1527 CastInfo<::clang::extractapi::RecordContext, FromTy *>> {};
1528
1529template <typename ToTy>
1530struct CastInfo<ToTy, ::clang::extractapi::RecordContext *>
1531 : public NullableValueCastFailed<ToTy *>,
1533 ToTy *, ::clang::extractapi::RecordContext *,
1534 CastInfo<ToTy, ::clang::extractapi::RecordContext *>> {
1536 return ::clang::extractapi::FromRecordContextCastInfoWrapper<
1537 ToTy>::isPossible(Ctx);
1538 }
1539
1540 static inline ToTy *doCast(::clang::extractapi::RecordContext *Ctx) {
1541 return ::clang::extractapi::FromRecordContextCastInfoWrapper<ToTy>::doCast(
1542 Ctx);
1543 }
1544};
1545
1546template <typename ToTy>
1547struct CastInfo<ToTy, const ::clang::extractapi::RecordContext *>
1549 ToTy, const ::clang::extractapi::RecordContext *,
1550 CastInfo<ToTy, ::clang::extractapi::RecordContext *>> {};
1551
1552} // namespace llvm
1553
1554#endif // LLVM_CLANG_EXTRACTAPI_API_H
This file defines the Declaration Fragments related classes.
llvm::MachO::Target Target
Definition: MachO.h:48
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:85
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:1607
APISet holds the set of API records collected from given inputs.
Definition: API.h:1350
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:1417
APISet & operator=(const APISet &Other)=delete
SymbolReference createSymbolReference(StringRef Name, StringRef USR, StringRef Source="")
Definition: API.cpp:92
Language getLanguage() const
Get the language used by the APIs.
Definition: API.h:1356
ArrayRef< const APIRecord * > getTopLevelRecords() const
Definition: API.h:1379
const std::string ProductName
Definition: API.h:1412
APISet(const APISet &Other)=delete
StringRef copyString(StringRef String)
Copy String into the Allocator in this APISet.
Definition: API.cpp:79
APISet(APISet &&Other)=delete
const llvm::Triple & getTarget() const
Get the target triple for the ExtractAPI invocation.
Definition: API.h:1353
APISet & operator=(APISet &&Other)=delete
APIRecord * findRecordForUSR(StringRef USR) const
Finds the APIRecord for a given USR.
Definition: API.cpp:68
APISet(const llvm::Triple &Target, Language Lang, const std::string &ProductName)
Definition: API.h:1383
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:365
bool records_empty() const
Definition: API.h:367
static bool classof(const RecordContext *Context)
Definition: API.h:320
llvm::iterator_range< record_iterator > record_range
Definition: API.h:361
APIRecord::RecordKind getKind() const
Definition: API.h:324
record_range records() const
Definition: API.h:362
record_iterator records_end() const
Definition: API.h:366
static bool classofKind(APIRecord::RecordKind K)
Definition: API.h:315
void addToRecordChain(APIRecord *) const
Definition: API.cpp:57
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:5394
#define true
Definition: stdbool.h:21
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:97
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:214
@ RK_GlobalVariableTemplatePartialSpecialization
Definition: API.h:218
@ RK_GlobalVariableTemplateSpecialization
Definition: API.h:217
@ 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:1122
static bool classofKind(RecordKind K)
Definition: API.h:1137
static bool classof(const APIRecord *Record)
Definition: API.h:1134
CXXClassRecord(StringRef USR, StringRef Name, SymbolReference Parent, PresumedLoc Loc, AvailabilityInfo Availability, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading, RecordKind Kind, AccessControl Access, bool IsFromSystemHeader)
Definition: API.h:1124
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:798
static bool classof(const APIRecord *Record)
Definition: API.h:809
static bool classofKind(RecordKind K)
Definition: API.h:812
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:819
static bool classofKind(RecordKind K)
Definition: API.h:833
static bool classof(const APIRecord *Record)
Definition: API.h:830
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:728
static bool classofKind(RecordKind K)
Definition: API.h:750
static bool classof(const APIRecord *Record)
Definition: API.h:747
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:737
static bool classof(const APIRecord *Record)
Definition: API.h:772
static bool classofKind(RecordKind K)
Definition: API.h:775
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:761
static bool classof(const APIRecord *Record)
Definition: API.h:873
static bool classofKind(RecordKind K)
Definition: API.h:876
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:861
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:783
FunctionSignature Signature
Definition: API.h:779
static bool classofKind(RecordKind K)
Definition: API.h:901
static bool classof(const APIRecord *Record)
Definition: API.h:898
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:885
static bool classof(const APIRecord *Record)
Definition: API.h:916
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:905
static bool classof(const APIRecord *Record)
Definition: API.h:851
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:840
static bool classofKind(RecordKind K)
Definition: API.h:854
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:1187
static bool classof(const APIRecord *Record)
Definition: API.h:1198
static bool classof(const APIRecord *Record)
Definition: API.h:1161
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:1150
static bool classofKind(RecordKind K)
Definition: API.h:1164
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:1168
static bool classof(const APIRecord *Record)
Definition: API.h:1177
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:1209
static bool classof(const APIRecord *Record)
Definition: API.h:1219
static bool classofKind(RecordKind K)
Definition: API.h:1222
This holds information associated with enum constants.
Definition: API.h:575
EnumConstantRecord(StringRef USR, StringRef Name, SymbolReference Parent, PresumedLoc Loc, AvailabilityInfo Availability, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading, bool IsFromSystemHeader)
Definition: API.h:576
static bool classofKind(RecordKind K)
Definition: API.h:588
static bool classof(const APIRecord *Record)
Definition: API.h:585
This holds information associated with enums.
Definition: API.h:595
static bool classof(const APIRecord *Record)
Definition: API.h:605
EnumRecord(StringRef USR, StringRef Name, SymbolReference Parent, PresumedLoc Loc, AvailabilityInfo Availability, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading, bool IsFromSystemHeader)
Definition: API.h:596
static bool classofKind(RecordKind K)
Definition: API.h:608
static RecordContext * doCast(RecordContext *Ctx)
Definition: API.h:1494
static ToTy * doCast(RecordContext *Ctx)
Definition: API.h:1481
static bool isPossible(RecordContext *Ctx)
Definition: API.h:1477
This holds information associated with global functions.
Definition: API.h:397
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:411
static bool classof(const APIRecord *Record)
Definition: API.h:423
static bool classofKind(RecordKind K)
Definition: API.h:426
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:400
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:435
static bool classofKind(RecordKind K)
Definition: API.h:452
static bool classof(const APIRecord *Record)
Definition: API.h:449
static bool classof(const APIRecord *Record)
Definition: API.h:469
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:458
This holds information associated with global functions.
Definition: API.h:478
static bool classof(const APIRecord *Record)
Definition: API.h:499
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:488
static bool classofKind(RecordKind K)
Definition: API.h:502
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:479
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:554
static bool classof(const APIRecord *Record)
Definition: API.h:523
static bool classofKind(RecordKind K)
Definition: API.h:526
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:511
static bool classof(const APIRecord *Record)
Definition: API.h:542
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:532
This holds information associated with macro definitions.
Definition: API.h:1304
static bool classof(const APIRecord *Record)
Definition: API.h:1313
MacroDefinitionRecord(StringRef USR, StringRef Name, SymbolReference Parent, PresumedLoc Loc, DeclarationFragments Declaration, DeclarationFragments SubHeading, bool IsFromSystemHeader)
Definition: API.h:1305
static bool classofKind(RecordKind K)
Definition: API.h:1316
static bool classof(const APIRecord *Record)
Definition: API.h:390
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:380
static bool classofKind(RecordKind K)
Definition: API.h:393
This holds information associated with Objective-C categories.
Definition: API.h:1226
static bool classofKind(RecordKind K)
Definition: API.h:1244
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:1229
std::optional< StringRef > getExtendedExternalModule() const
Definition: API.h:1248
bool isExtendingExternalModule() const
Definition: API.h:1246
static bool classof(const APIRecord *Record)
Definition: API.h:1241
static bool classofKind(RecordKind K)
Definition: API.h:1077
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:1064
static bool classof(const APIRecord *Record)
Definition: API.h:1074
static bool classof(const APIRecord *Record)
Definition: API.h:992
static bool classofKind(RecordKind K)
Definition: API.h:995
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:979
The base representation of an Objective-C container record.
Definition: API.h:1102
SmallVector< SymbolReference > Protocols
Definition: API.h:1103
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:1107
static bool classofKind(RecordKind K)
Definition: API.h:1057
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:1044
static bool classof(const APIRecord *Record)
Definition: API.h:1054
static bool classof(const APIRecord *Record)
Definition: API.h:969
static bool classofKind(RecordKind K)
Definition: API.h:972
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:958
This holds information associated with Objective-C instance variables.
Definition: API.h:1002
static bool classofKind(RecordKind K)
Definition: API.h:1017
ObjCInstanceVariableRecord(StringRef USR, StringRef Name, SymbolReference Parent, PresumedLoc Loc, AvailabilityInfo Availability, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading, bool IsFromSystemHeader)
Definition: API.h:1003
static bool classof(const APIRecord *Record)
Definition: API.h:1014
This holds information associated with Objective-C interfaces/classes.
Definition: API.h:1259
static bool classof(const APIRecord *Record)
Definition: API.h:1273
static bool classofKind(RecordKind K)
Definition: API.h:1276
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:1262
This holds information associated with Objective-C methods.
Definition: API.h:1024
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:1029
FunctionSignature Signature
Definition: API.h:1025
This holds information associated with Objective-C properties.
Definition: API.h:925
AttributeKind
The attributes associated with an Objective-C property.
Definition: API.h:927
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:938
This holds information associated with Objective-C protocols.
Definition: API.h:1283
static bool classof(const APIRecord *Record)
Definition: API.h:1294
static bool classofKind(RecordKind K)
Definition: API.h:1297
ObjCProtocolRecord(StringRef USR, StringRef Name, SymbolReference Parent, PresumedLoc Loc, AvailabilityInfo Availability, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading, bool IsFromSystemHeader)
Definition: API.h:1284
std::forward_iterator_tag iterator_category
Definition: API.h:334
friend bool operator==(record_iterator x, record_iterator y)
Definition: API.h:353
friend bool operator!=(record_iterator x, record_iterator y)
Definition: API.h:356
This holds information associated with struct or union fields fields.
Definition: API.h:615
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:616
static bool classofKind(RecordKind K)
Definition: API.h:628
static bool classof(const APIRecord *Record)
Definition: API.h:625
This holds information associated with structs and unions.
Definition: API.h:636
RecordRecord(RecordKind Kind, StringRef USR, StringRef Name, SymbolReference Parent, PresumedLoc Loc, AvailabilityInfo Availability, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading, bool IsFromSystemHeader)
Definition: API.h:637
static bool classof(const APIRecord *Record)
Definition: API.h:647
static bool classofKind(RecordKind K)
Definition: API.h:650
static bool classof(const APIRecord *Record)
Definition: API.h:1094
static bool classofKind(RecordKind K)
Definition: API.h:1097
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:1084
static bool classof(const APIRecord *Record)
Definition: API.h:666
static bool classofKind(RecordKind K)
Definition: API.h:669
StructFieldRecord(StringRef USR, StringRef Name, SymbolReference Parent, PresumedLoc Loc, AvailabilityInfo Availability, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading, bool IsFromSystemHeader)
Definition: API.h:658
StructRecord(StringRef USR, StringRef Name, SymbolReference Parent, PresumedLoc Loc, AvailabilityInfo Availability, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading, bool IsFromSystemHeader)
Definition: API.h:676
static bool classof(const APIRecord *Record)
Definition: API.h:683
static bool classofKind(RecordKind K)
Definition: API.h:686
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 RecordContext * doCast(FromTy *From)
Definition: API.h:1453
static bool isPossible(FromTy *From)
Definition: API.h:1451
This holds information associated with typedefs.
Definition: API.h:1327
static bool classofKind(RecordKind K)
Definition: API.h:1343
SymbolReference UnderlyingType
Definition: API.h:1328
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:1330
static bool classof(const APIRecord *Record)
Definition: API.h:1340
static bool classofKind(RecordKind K)
Definition: API.h:704
static bool classof(const APIRecord *Record)
Definition: API.h:701
UnionFieldRecord(StringRef USR, StringRef Name, SymbolReference Parent, PresumedLoc Loc, AvailabilityInfo Availability, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading, bool IsFromSystemHeader)
Definition: API.h:693
UnionRecord(StringRef USR, StringRef Name, SymbolReference Parent, PresumedLoc Loc, AvailabilityInfo Availability, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading, bool IsFromSystemHeader)
Definition: API.h:711
static bool classof(const APIRecord *Record)
Definition: API.h:718
static bool classofKind(RecordKind K)
Definition: API.h:721
static ToTy * doCast(::clang::extractapi::RecordContext *Ctx)
Definition: API.h:1540
static bool isPossible(::clang::extractapi::RecordContext *Ctx)
Definition: API.h:1535
static inline ::clang::extractapi::RecordContext * doCast(FromTy *From)
Definition: API.h:1517