clang 20.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/DeclBase.h"
26#include "llvm/ADT/SmallVector.h"
27#include "llvm/Support/Allocator.h"
28#include "llvm/Support/Casting.h"
29#include "llvm/Support/Compiler.h"
30#include "llvm/TargetParser/Triple.h"
31#include <cstddef>
32#include <iterator>
33#include <memory>
34#include <optional>
35#include <type_traits>
36
37namespace clang {
38namespace extractapi {
39
40class Template {
41 struct TemplateParameter {
42 // "class", "typename", or concept name
43 std::string Type;
44 std::string Name;
45 unsigned int Index;
46 unsigned int Depth;
47 bool IsParameterPack;
48
49 TemplateParameter(std::string Type, std::string Name, unsigned int Index,
50 unsigned int Depth, bool IsParameterPack)
51 : Type(Type), Name(Name), Index(Index), Depth(Depth),
52 IsParameterPack(IsParameterPack) {}
53 };
54
55 struct TemplateConstraint {
56 // type name of the constraint, if it has one
57 std::string Type;
58 std::string Kind;
59 std::string LHS, RHS;
60 };
63
64public:
65 Template() = default;
66
68 for (auto *const Parameter : *Decl->getTemplateParameters()) {
69 const auto *Param = dyn_cast<TemplateTypeParmDecl>(Parameter);
70 if (!Param) // some params are null
71 continue;
72 std::string Type;
73 if (Param->hasTypeConstraint())
74 Type = Param->getTypeConstraint()->getNamedConcept()->getName().str();
75 else if (Param->wasDeclaredWithTypename())
76 Type = "typename";
77 else
78 Type = "class";
79
80 addTemplateParameter(Type, Param->getName().str(), Param->getIndex(),
81 Param->getDepth(), Param->isParameterPack());
82 }
83 }
84
86 for (auto *const Parameter : *Decl->getTemplateParameters()) {
87 const auto *Param = dyn_cast<TemplateTypeParmDecl>(Parameter);
88 if (!Param) // some params are null
89 continue;
90 std::string Type;
91 if (Param->hasTypeConstraint())
92 Type = Param->getTypeConstraint()->getNamedConcept()->getName().str();
93 else if (Param->wasDeclaredWithTypename())
94 Type = "typename";
95 else
96 Type = "class";
97
98 addTemplateParameter(Type, Param->getName().str(), Param->getIndex(),
99 Param->getDepth(), Param->isParameterPack());
100 }
101 }
102
104 for (auto *const Parameter : *Decl->getTemplateParameters()) {
105 const auto *Param = dyn_cast<TemplateTypeParmDecl>(Parameter);
106 if (!Param) // some params are null
107 continue;
108 std::string Type;
109 if (Param->hasTypeConstraint())
110 Type = Param->getTypeConstraint()->getNamedConcept()->getName().str();
111 else if (Param->wasDeclaredWithTypename())
112 Type = "typename";
113 else
114 Type = "class";
115
116 addTemplateParameter(Type, Param->getName().str(), Param->getIndex(),
117 Param->getDepth(), Param->isParameterPack());
118 }
119 }
120
122 return Parameters;
123 }
124
126 return Constraints;
127 }
128
129 void addTemplateParameter(std::string Type, std::string Name,
130 unsigned int Index, unsigned int Depth,
131 bool IsParameterPack) {
132 Parameters.emplace_back(Type, Name, Index, Depth, IsParameterPack);
133 }
134
135 bool empty() const { return Parameters.empty() && Constraints.empty(); }
136};
137
138/// DocComment is a vector of RawComment::CommentLine.
139///
140/// Each line represents one line of striped documentation comment,
141/// with source range information. This simplifies calculating the source
142/// location of a character in the doc comment for pointing back to the source
143/// file.
144/// e.g.
145/// \code
146/// /// This is a documentation comment
147/// ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~' First line.
148/// /// with multiple lines.
149/// ^~~~~~~~~~~~~~~~~~~~~~~' Second line.
150/// \endcode
151using DocComment = std::vector<RawComment::CommentLine>;
152
153struct APIRecord;
154
155// This represents a reference to another symbol that might come from external
156/// sources.
158 StringRef Name;
159 StringRef USR;
160
161 /// The source project/module/product of the referred symbol.
162 StringRef Source;
163
164 // A Pointer to the APIRecord for this reference if known
165 const APIRecord *Record = nullptr;
166
167 SymbolReference() = default;
168 SymbolReference(StringRef Name, StringRef USR, StringRef Source = "")
169 : Name(Name), USR(USR), Source(Source) {}
170 SymbolReference(const APIRecord *R);
171
172 /// Determine if this SymbolReference is empty.
173 ///
174 /// \returns true if and only if all \c Name, \c USR, and \c Source is empty.
175 bool empty() const { return Name.empty() && USR.empty() && Source.empty(); }
176};
177
178class RecordContext;
179
180// Concrete classes deriving from APIRecord need to have a construct with first
181// arguments USR, and Name, in that order. This is so that they
182// are compatible with `APISet::createRecord`.
183// When adding a new kind of record don't forget to update APIRecords.inc!
184/// The base representation of an API record. Holds common symbol information.
185struct APIRecord {
186 /// Discriminator for LLVM-style RTTI (dyn_cast<> et al.)
189 // If adding a record context record kind here make sure to update
190 // RecordContext::classof if needed and add a RECORD_CONTEXT entry to
191 // APIRecords.inc
232 };
233
234 StringRef USR;
235 StringRef Name;
236
238
242
243 /// Documentation comment lines attached to this symbol declaration.
245
246 /// Declaration fragments of this symbol declaration.
248
249 /// SubHeading provides a more detailed representation than the plain
250 /// declaration name.
251 ///
252 /// SubHeading is an array of declaration fragments of tagged declaration
253 /// name, with potentially more tokens (for example the \c +/- symbol for
254 /// Objective-C class/instance methods).
256
257 /// Whether the symbol was defined in a system header.
259
261
263
264private:
265 const RecordKind Kind;
266 friend class RecordContext;
267 // Used to store the next child record in RecordContext. This works because
268 // APIRecords semantically only have one parent.
269 mutable APIRecord *NextInContext = nullptr;
270
271public:
272 APIRecord *getNextInContext() const { return NextInContext; }
273
274 RecordKind getKind() const { return Kind; }
276
279
280 APIRecord() = delete;
281
282 APIRecord(RecordKind Kind, StringRef USR, StringRef Name,
288 : USR(USR), Name(Name), Parent(std::move(Parent)), Location(Location),
293
294 APIRecord(RecordKind Kind, StringRef USR, StringRef Name)
296
297 // Pure virtual destructor to make APIRecord abstract
298 virtual ~APIRecord() = 0;
299 static bool classof(const APIRecord *Record) { return true; }
300 static bool classofKind(RecordKind K) { return true; }
301 static bool classof(const RecordContext *Ctx) { return true; }
302};
303
304/// Base class used for specific record types that have children records this is
305/// analogous to the DeclContext for the AST
307public:
308 static bool classof(const APIRecord *Record) {
309 return classofKind(Record->getKind());
310 }
314 }
315
316 static bool classof(const RecordContext *Context) { return true; }
317
319
320 /// Append \p Other children chain into ours and empty out Other's record
321 /// chain.
323
325
326 APIRecord::RecordKind getKind() const { return Kind; }
327
329 private:
330 APIRecord *Current = nullptr;
331
332 public:
334 using reference = const value_type &;
335 using pointer = const value_type *;
336 using iterator_category = std::forward_iterator_tag;
337 using difference_type = std::ptrdiff_t;
338
339 record_iterator() = default;
340 explicit record_iterator(value_type R) : Current(R) {}
341 reference operator*() const { return Current; }
342 // This doesn't strictly meet the iterator requirements, but it's the
343 // behavior we want here.
344 value_type operator->() const { return Current; }
346 Current = Current->getNextInContext();
347 return *this;
348 }
350 record_iterator tmp(*this);
351 ++(*this);
352 return tmp;
353 }
354
356 return x.Current == y.Current;
357 }
359 return x.Current != y.Current;
360 }
361 };
362
363 using record_range = llvm::iterator_range<record_iterator>;
366 }
369 bool records_empty() const { return First == nullptr; };
370
371private:
373 mutable APIRecord *First = nullptr;
374 mutable APIRecord *Last = nullptr;
375 bool IsWellFormed() const;
376
377protected:
378 friend class APISet;
379 void addToRecordChain(APIRecord *) const;
380};
381
392
393 static bool classof(const APIRecord *Record) {
394 return classofKind(Record->getKind());
395 }
396 static bool classofKind(RecordKind K) { return K == RK_Namespace; }
397};
398
399/// This holds information associated with global functions.
402
413
414 GlobalFunctionRecord(RecordKind Kind, StringRef USR, StringRef Name,
417 const DocComment &Comment,
421 : APIRecord(Kind, USR, Name, Parent, Loc, std::move(Availability),
425
426 static bool classof(const APIRecord *Record) {
427 return classofKind(Record->getKind());
428 }
429 static bool classofKind(RecordKind K) { return K == RK_GlobalFunction; }
430
431private:
432 virtual void anchor();
433};
434
437
450 Templ(Template) {}
451
452 static bool classof(const APIRecord *Record) {
453 return classofKind(Record->getKind());
454 }
455 static bool classofKind(RecordKind K) {
456 return K == RK_GlobalFunctionTemplate;
457 }
458};
459
462 StringRef USR, StringRef Name, SymbolReference Parent, PresumedLoc Loc,
471
472 static bool classof(const APIRecord *Record) {
473 return classofKind(Record->getKind());
474 }
475 static bool classofKind(RecordKind K) {
477 }
478};
479
480/// This holds information associated with global functions.
491
492 GlobalVariableRecord(RecordKind Kind, StringRef USR, StringRef Name,
495 const DocComment &Comment,
498 : APIRecord(Kind, USR, Name, Parent, Loc, std::move(Availability),
501 RecordContext(Kind) {}
502
503 static bool classof(const APIRecord *Record) {
504 return classofKind(Record->getKind());
505 }
506 static bool classofKind(RecordKind K) {
507 return K == RK_GlobalVariable || K == RK_GlobalVariableTemplate ||
510 }
511
512private:
513 virtual void anchor();
514};
515
518
529 Templ(Template) {}
530
531 static bool classof(const APIRecord *Record) {
532 return classofKind(Record->getKind());
533 }
534 static bool classofKind(RecordKind K) {
535 return K == RK_GlobalVariableTemplate;
536 }
537};
538
541 StringRef USR, StringRef Name, SymbolReference Parent, PresumedLoc Loc,
549
550 static bool classof(const APIRecord *Record) {
551 return classofKind(Record->getKind());
552 }
553 static bool classofKind(RecordKind K) {
555 }
556};
557
561
563 StringRef USR, StringRef Name, SymbolReference Parent, PresumedLoc Loc,
569 USR, Name, Parent, Loc, std::move(Availability),
572 Templ(Template) {}
573
574 static bool classof(const APIRecord *Record) {
575 return classofKind(Record->getKind());
576 }
577 static bool classofKind(RecordKind K) {
579 }
580};
581
582/// This holds information associated with enum constants.
586 const DocComment &Comment,
590 std::move(Availability), LinkageInfo::none(), Comment,
592
593 static bool classof(const APIRecord *Record) {
594 return classofKind(Record->getKind());
595 }
596 static bool classofKind(RecordKind K) { return K == RK_EnumConstant; }
597
598private:
599 virtual void anchor();
600};
601
603 TagRecord(RecordKind Kind, StringRef USR, StringRef Name,
609 : APIRecord(Kind, USR, Name, Parent, Loc, std::move(Availability),
612 RecordContext(Kind),
614
615 static bool classof(const APIRecord *Record) {
616 return classofKind(Record->getKind());
617 }
618 static bool classofKind(RecordKind K) {
619 switch (K) {
620 case RK_Enum:
621 LLVM_FALLTHROUGH;
622 case RK_Struct:
623 LLVM_FALLTHROUGH;
624 case RK_Union:
625 LLVM_FALLTHROUGH;
626 case RK_CXXClass:
627 LLVM_FALLTHROUGH;
628 case RK_ClassTemplate:
629 LLVM_FALLTHROUGH;
631 LLVM_FALLTHROUGH;
633 return true;
634 default:
635 return false;
636 }
637 }
638
640
641 virtual ~TagRecord() = 0;
642};
643
644/// This holds information associated with enums.
646 EnumRecord(StringRef USR, StringRef Name, SymbolReference Parent,
655
656 static bool classof(const APIRecord *Record) {
657 return classofKind(Record->getKind());
658 }
659
660 static bool classofKind(RecordKind K) { return K == RK_Enum; }
661
662private:
663 virtual void anchor();
664};
665
666/// This holds information associated with struct or union fields fields.
668 RecordFieldRecord(RecordKind Kind, StringRef USR, StringRef Name,
673 : APIRecord(Kind, USR, Name, Parent, Loc, std::move(Availability),
676 RecordContext(Kind) {}
677
678 static bool classof(const APIRecord *Record) {
679 return classofKind(Record->getKind());
680 }
681 static bool classofKind(RecordKind K) {
682 return K == RK_StructField || K == RK_UnionField;
683 }
684
685 virtual ~RecordFieldRecord() = 0;
686};
687
688/// This holds information associated with structs and unions.
690 RecordRecord(RecordKind Kind, StringRef USR, StringRef Name,
697 : TagRecord(Kind, USR, Name, Parent, Loc, std::move(Availability),
700
701 static bool classof(const APIRecord *Record) {
702 return classofKind(Record->getKind());
703 }
704 static bool classofKind(RecordKind K) {
705 switch (K) {
706 case RK_Struct:
707 LLVM_FALLTHROUGH;
708 case RK_Union:
709 LLVM_FALLTHROUGH;
710 case RK_CXXClass:
711 LLVM_FALLTHROUGH;
712 case RK_ClassTemplate:
713 LLVM_FALLTHROUGH;
715 LLVM_FALLTHROUGH;
717 return true;
718 default:
719 return false;
720 }
721 }
722
723 bool isAnonymousWithNoTypedef() { return Name.empty(); }
724
725 virtual ~RecordRecord() = 0;
726};
727
736
737 static bool classof(const APIRecord *Record) {
738 return classofKind(Record->getKind());
739 }
740 static bool classofKind(RecordKind K) { return K == RK_StructField; }
741
742private:
743 virtual void anchor();
744};
745
755
756 static bool classof(const APIRecord *Record) {
757 return classofKind(Record->getKind());
758 }
759 static bool classofKind(RecordKind K) { return K == RK_Struct; }
760
761private:
762 virtual void anchor();
763};
764
773
774 static bool classof(const APIRecord *Record) {
775 return classofKind(Record->getKind());
776 }
777 static bool classofKind(RecordKind K) { return K == RK_UnionField; }
778
779private:
780 virtual void anchor();
781};
782
792
793 static bool classof(const APIRecord *Record) {
794 return classofKind(Record->getKind());
795 }
796 static bool classofKind(RecordKind K) { return K == RK_Union; }
797
798private:
799 virtual void anchor();
800};
801
812
813 CXXFieldRecord(RecordKind Kind, StringRef USR, StringRef Name,
819 : APIRecord(Kind, USR, Name, Parent, Loc, std::move(Availability),
822 RecordContext(Kind) {}
823
824 static bool classof(const APIRecord *Record) {
825 return classofKind(Record->getKind());
826 }
827 static bool classofKind(RecordKind K) {
828 return K == RK_CXXField || K == RK_CXXFieldTemplate || K == RK_StaticField;
829 }
830
831private:
832 virtual void anchor();
833};
834
837
840 const DocComment &Comment,
847 Templ(Template) {}
848
849 static bool classof(const APIRecord *Record) {
850 return classofKind(Record->getKind());
851 }
852 static bool classofKind(RecordKind K) { return K == RK_CXXFieldTemplate; }
853};
854
857
858 CXXMethodRecord() = delete;
859
860 CXXMethodRecord(RecordKind Kind, StringRef USR, StringRef Name,
866 : APIRecord(Kind, USR, Name, Parent, Loc, std::move(Availability),
870
871 virtual ~CXXMethodRecord() = 0;
872};
873
877 const DocComment &Comment,
886 static bool classof(const APIRecord *Record) {
887 return classofKind(Record->getKind());
888 }
889 static bool classofKind(RecordKind K) { return K == RK_CXXConstructorMethod; }
890
891private:
892 virtual void anchor();
893};
894
898 const DocComment &Comment,
907 static bool classof(const APIRecord *Record) {
908 return classofKind(Record->getKind());
909 }
910 static bool classofKind(RecordKind K) { return K == RK_CXXDestructorMethod; }
911
912private:
913 virtual void anchor();
914};
915
919 const DocComment &Comment,
928 static bool classof(const APIRecord *Record) {
929 return classofKind(Record->getKind());
930 }
931 static bool classofKind(RecordKind K) { return K == RK_CXXStaticMethod; }
932
933private:
934 virtual void anchor();
935};
936
940 const DocComment &Comment,
949
950 static bool classof(const APIRecord *Record) {
951 return classofKind(Record->getKind());
952 }
953 static bool classofKind(RecordKind K) { return K == RK_CXXInstanceMethod; }
954
955private:
956 virtual void anchor();
957};
958
961
964 const DocComment &Comment,
973 Templ(Template) {}
974
975 static bool classof(const APIRecord *Record) {
976 return classofKind(Record->getKind());
977 }
978 static bool classofKind(RecordKind K) { return K == RK_CXXMethodTemplate; }
979};
980
983 StringRef USR, StringRef Name, SymbolReference Parent, PresumedLoc Loc,
992
993 static bool classof(const APIRecord *Record) {
994 return classofKind(Record->getKind());
995 }
996 static bool classofKind(RecordKind K) {
998 }
999};
1000
1001/// This holds information associated with Objective-C properties.
1003 /// The attributes associated with an Objective-C property.
1004 enum AttributeKind : unsigned {
1007 Dynamic = 1 << 2,
1008 };
1009
1011 StringRef GetterName;
1012 StringRef SetterName;
1014
1015 ObjCPropertyRecord(RecordKind Kind, StringRef USR, StringRef Name,
1020 StringRef GetterName, StringRef SetterName,
1021 bool IsOptional, bool IsFromSystemHeader)
1022 : APIRecord(Kind, USR, Name, Parent, Loc, std::move(Availability),
1027
1028 bool isReadOnly() const { return Attributes & ReadOnly; }
1029 bool isDynamic() const { return Attributes & Dynamic; }
1030
1031 virtual ~ObjCPropertyRecord() = 0;
1032};
1033
1036 StringRef USR, StringRef Name, SymbolReference Parent, PresumedLoc Loc,
1039 AttributeKind Attributes, StringRef GetterName, StringRef SetterName,
1040 bool IsOptional, bool IsFromSystemHeader)
1045
1046 static bool classof(const APIRecord *Record) {
1047 return classofKind(Record->getKind());
1048 }
1049 static bool classofKind(RecordKind K) { return K == RK_ObjCInstanceProperty; }
1050
1051private:
1052 virtual void anchor();
1053};
1054
1058 const DocComment &Comment,
1062 StringRef SetterName, bool IsOptional,
1063 bool IsFromSystemHeader)
1068
1069 static bool classof(const APIRecord *Record) {
1070 return classofKind(Record->getKind());
1071 }
1072 static bool classofKind(RecordKind K) { return K == RK_ObjCClassProperty; }
1073
1074private:
1075 virtual void anchor();
1076};
1077
1078/// This holds information associated with Objective-C instance variables.
1083 const DocComment &Comment,
1086 bool IsFromSystemHeader)
1090
1091 static bool classof(const APIRecord *Record) {
1092 return classofKind(Record->getKind());
1093 }
1094 static bool classofKind(RecordKind K) { return K == RK_ObjCIvar; }
1095
1096private:
1097 virtual void anchor();
1098};
1099
1100/// This holds information associated with Objective-C methods.
1103
1105
1106 ObjCMethodRecord(RecordKind Kind, StringRef USR, StringRef Name,
1111 bool IsFromSystemHeader)
1112 : APIRecord(Kind, USR, Name, Parent, Loc, std::move(Availability),
1116
1117 virtual ~ObjCMethodRecord() = 0;
1118};
1119
1121 ObjCInstanceMethodRecord(StringRef USR, StringRef Name,
1124 const DocComment &Comment,
1131 static bool classof(const APIRecord *Record) {
1132 return classofKind(Record->getKind());
1133 }
1134 static bool classofKind(RecordKind K) { return K == RK_ObjCInstanceMethod; }
1135
1136private:
1137 virtual void anchor();
1138};
1139
1143 const DocComment &Comment,
1150
1151 static bool classof(const APIRecord *Record) {
1152 return classofKind(Record->getKind());
1153 }
1154 static bool classofKind(RecordKind K) { return K == RK_ObjCClassMethod; }
1155
1156private:
1157 virtual void anchor();
1158};
1159
1166 bool IsFromSystemHeader)
1170
1171 static bool classof(const APIRecord *Record) {
1172 return classofKind(Record->getKind());
1173 }
1174 static bool classofKind(RecordKind K) { return K == RK_StaticField; }
1175};
1176
1177/// The base representation of an Objective-C container record. Holds common
1178/// information associated with Objective-C containers.
1181
1183
1184 ObjCContainerRecord(RecordKind Kind, StringRef USR, StringRef Name,
1187 const DocComment &Comment,
1190 : APIRecord(Kind, USR, Name, Parent, Loc, std::move(Availability),
1193 RecordContext(Kind) {}
1194
1195 virtual ~ObjCContainerRecord() = 0;
1196};
1197
1200
1206 bool IsEmbeddedInVarDeclarator = false)
1207 : RecordRecord(Kind, USR, Name, Parent, Loc, std::move(Availability),
1210
1211 static bool classof(const APIRecord *Record) {
1212 return classofKind(Record->getKind());
1213 }
1214 static bool classofKind(RecordKind K) {
1215 return K == RK_CXXClass || K == RK_ClassTemplate ||
1218 }
1219
1220private:
1221 virtual void anchor();
1222};
1223
1226
1229 const DocComment &Comment,
1235 std::move(Access), IsFromSystemHeader),
1236 Templ(Template) {}
1237
1238 static bool classof(const APIRecord *Record) {
1239 return classofKind(Record->getKind());
1240 }
1241 static bool classofKind(RecordKind K) { return K == RK_ClassTemplate; }
1242};
1243
1246 StringRef USR, StringRef Name, SymbolReference Parent, PresumedLoc Loc,
1253
1254 static bool classof(const APIRecord *Record) {
1255 return classofKind(Record->getKind());
1256 }
1257 static bool classofKind(RecordKind K) {
1259 }
1260};
1261
1265 StringRef USR, StringRef Name, SymbolReference Parent, PresumedLoc Loc,
1273 Templ(Template) {}
1274
1275 static bool classof(const APIRecord *Record) {
1276 return classofKind(Record->getKind());
1277 }
1278 static bool classofKind(RecordKind K) {
1280 }
1281};
1282
1285
1290 bool IsFromSystemHeader)
1294 Templ(Template) {}
1295
1296 static bool classof(const APIRecord *Record) {
1297 return classofKind(Record->getKind());
1298 }
1299 static bool classofKind(RecordKind K) { return K == RK_Concept; }
1300};
1301
1302/// This holds information associated with Objective-C categories.
1305
1308 const DocComment &Comment,
1311 bool IsFromSystemHeader)
1313 std::move(Availability), LinkageInfo::none(),
1317
1318 static bool classof(const APIRecord *Record) {
1319 return classofKind(Record->getKind());
1320 }
1321 static bool classofKind(RecordKind K) { return K == RK_ObjCCategory; }
1322
1323 bool isExtendingExternalModule() const { return !Interface.Source.empty(); }
1324
1325 std::optional<StringRef> getExtendedExternalModule() const {
1327 return {};
1328 return Interface.Source;
1329 }
1330
1331private:
1332 virtual void anchor();
1333};
1334
1335/// This holds information associated with Objective-C interfaces/classes.
1338
1349
1350 static bool classof(const APIRecord *Record) {
1351 return classofKind(Record->getKind());
1352 }
1353 static bool classofKind(RecordKind K) { return K == RK_ObjCInterface; }
1354
1355private:
1356 virtual void anchor();
1357};
1358
1359/// This holds information associated with Objective-C protocols.
1363 const DocComment &Comment,
1367 std::move(Availability), LinkageInfo::none(),
1370
1371 static bool classof(const APIRecord *Record) {
1372 return classofKind(Record->getKind());
1373 }
1374 static bool classofKind(RecordKind K) { return K == RK_ObjCProtocol; }
1375
1376private:
1377 virtual void anchor();
1378};
1379
1380/// This holds information associated with macro definitions.
1385 bool IsFromSystemHeader)
1389
1390 static bool classof(const APIRecord *Record) {
1391 return classofKind(Record->getKind());
1392 }
1393 static bool classofKind(RecordKind K) { return K == RK_MacroDefinition; }
1394
1395private:
1396 virtual void anchor();
1397};
1398
1399/// This holds information associated with typedefs.
1400///
1401/// Note: Typedefs for anonymous enums and structs typically don't get emitted
1402/// by the serializers but still get a TypedefRecord. Instead we use the
1403/// typedef name as a name for the underlying anonymous struct or enum.
1406
1411 bool IsFromSystemHeader)
1416
1417 static bool classof(const APIRecord *Record) {
1418 return classofKind(Record->getKind());
1419 }
1420 static bool classofKind(RecordKind K) { return K == RK_Typedef; }
1421
1422private:
1423 virtual void anchor();
1424};
1425
1426/// APISet holds the set of API records collected from given inputs.
1427class APISet {
1428public:
1429 /// Get the target triple for the ExtractAPI invocation.
1430 const llvm::Triple &getTarget() const { return Target; }
1431
1432 /// Get the language used by the APIs.
1433 Language getLanguage() const { return Lang; }
1434
1435 /// Finds the APIRecord for a given USR.
1436 ///
1437 /// \returns a pointer to the APIRecord associated with that USR or nullptr.
1438 APIRecord *findRecordForUSR(StringRef USR) const;
1439
1440 /// Copy \p String into the Allocator in this APISet.
1441 ///
1442 /// \returns a StringRef of the copied string in APISet::Allocator.
1443 StringRef copyString(StringRef String);
1444
1445 SymbolReference createSymbolReference(StringRef Name, StringRef USR,
1446 StringRef Source = "");
1447
1448 /// Create a subclass of \p APIRecord and store it in the APISet.
1449 ///
1450 /// \returns A pointer to the created record or the already existing record
1451 /// matching this USR.
1452 template <typename RecordTy, typename... CtorArgsContTy>
1453 typename std::enable_if_t<std::is_base_of_v<APIRecord, RecordTy>, RecordTy> *
1454 createRecord(StringRef USR, StringRef Name, CtorArgsContTy &&...CtorArgs);
1455
1457 return TopLevelRecords;
1458 }
1459
1460 void removeRecord(StringRef USR);
1461
1463
1464 APISet(const llvm::Triple &Target, Language Lang,
1465 const std::string &ProductName)
1466 : Target(Target), Lang(Lang), ProductName(ProductName) {}
1467
1468 // Prevent moves and copies
1469 APISet(const APISet &Other) = delete;
1470 APISet &operator=(const APISet &Other) = delete;
1471 APISet(APISet &&Other) = delete;
1473
1474private:
1475 /// BumpPtrAllocator that serves as the memory arena for the allocated objects
1476 llvm::BumpPtrAllocator Allocator;
1477
1478 const llvm::Triple Target;
1479 const Language Lang;
1480
1481 struct APIRecordDeleter {
1482 void operator()(APIRecord *Record) { Record->~APIRecord(); }
1483 };
1484
1485 // Ensure that the destructor of each record is called when the LookupTable is
1486 // destroyed without calling delete operator as the memory for the record
1487 // lives in the BumpPtrAllocator.
1488 using APIRecordStoredPtr = std::unique_ptr<APIRecord, APIRecordDeleter>;
1489 llvm::DenseMap<StringRef, APIRecordStoredPtr> USRBasedLookupTable;
1491
1492public:
1493 const std::string ProductName;
1494};
1495
1496template <typename RecordTy, typename... CtorArgsContTy>
1497typename std::enable_if_t<std::is_base_of_v<APIRecord, RecordTy>, RecordTy> *
1498APISet::createRecord(StringRef USR, StringRef Name,
1499 CtorArgsContTy &&...CtorArgs) {
1500 // Ensure USR refers to a String stored in the allocator.
1501 auto USRString = copyString(USR);
1502 auto Result = USRBasedLookupTable.insert({USRString, nullptr});
1503 RecordTy *Record;
1504
1505 // Create the record if it does not already exist
1506 if (Result.second) {
1507 Record = new (Allocator) RecordTy(
1508 USRString, copyString(Name), std::forward<CtorArgsContTy>(CtorArgs)...);
1509 // Store the record in the record lookup map
1510 Result.first->second = APIRecordStoredPtr(Record);
1511
1512 if (auto *ParentContext =
1513 dyn_cast_if_present<RecordContext>(Record->Parent.Record))
1514 ParentContext->addToRecordChain(Record);
1515 else
1516 TopLevelRecords.push_back(Record);
1517 } else {
1518 Record = dyn_cast<RecordTy>(Result.first->second.get());
1519 }
1520
1521 return Record;
1522}
1523
1524// Helper type for implementing casting to RecordContext pointers.
1525// Selected when FromTy not a known subclass of RecordContext.
1526template <typename FromTy,
1527 bool IsKnownSubType = std::is_base_of_v<RecordContext, FromTy>>
1529 static_assert(std::is_base_of_v<APIRecord, FromTy>,
1530 "Can only cast APIRecord and derived classes to RecordContext");
1531
1532 static bool isPossible(FromTy *From) { return RecordContext::classof(From); }
1533
1534 static RecordContext *doCast(FromTy *From) {
1535 return APIRecord::castToRecordContext(From);
1536 }
1537};
1538
1539// Selected when FromTy is a known subclass of RecordContext.
1540template <typename FromTy> struct ToRecordContextCastInfoWrapper<FromTy, true> {
1541 static_assert(std::is_base_of_v<APIRecord, FromTy>,
1542 "Can only cast APIRecord and derived classes to RecordContext");
1543 static bool isPossible(const FromTy *From) { return true; }
1544 static RecordContext *doCast(FromTy *From) {
1545 return static_cast<RecordContext *>(From);
1546 }
1547};
1548
1549// Helper type for implementing casting to RecordContext pointers.
1550// Selected when ToTy isn't a known subclass of RecordContext
1551template <typename ToTy,
1552 bool IsKnownSubType = std::is_base_of_v<RecordContext, ToTy>>
1554 static_assert(
1555 std::is_base_of_v<APIRecord, ToTy>,
1556 "Can only class RecordContext to APIRecord and derived classes");
1557
1558 static bool isPossible(RecordContext *Ctx) {
1559 return ToTy::classofKind(Ctx->getKind());
1560 }
1561
1562 static ToTy *doCast(RecordContext *Ctx) {
1564 }
1565};
1566
1567// Selected when ToTy is a known subclass of RecordContext.
1568template <typename ToTy> struct FromRecordContextCastInfoWrapper<ToTy, true> {
1569 static_assert(
1570 std::is_base_of_v<APIRecord, ToTy>,
1571 "Can only class RecordContext to APIRecord and derived classes");
1572 static bool isPossible(RecordContext *Ctx) {
1573 return ToTy::classof(Ctx->getKind());
1574 }
1576 return static_cast<ToTy *>(Ctx);
1577 }
1578};
1579
1580} // namespace extractapi
1581} // namespace clang
1582
1583// Implement APIRecord (and derived classes) to and from RecordContext
1584// conversions
1585namespace llvm {
1586
1587template <typename FromTy>
1588struct CastInfo<::clang::extractapi::RecordContext, FromTy *>
1589 : public NullableValueCastFailed<::clang::extractapi::RecordContext *>,
1591 ::clang::extractapi::RecordContext *, FromTy *,
1592 CastInfo<::clang::extractapi::RecordContext, FromTy *>> {
1593 static inline bool isPossible(FromTy *From) {
1594 return ::clang::extractapi::ToRecordContextCastInfoWrapper<
1595 FromTy>::isPossible(From);
1596 }
1597
1598 static inline ::clang::extractapi::RecordContext *doCast(FromTy *From) {
1599 return ::clang::extractapi::ToRecordContextCastInfoWrapper<FromTy>::doCast(
1600 From);
1601 }
1602};
1603
1604template <typename FromTy>
1605struct CastInfo<::clang::extractapi::RecordContext, const FromTy *>
1607 ::clang::extractapi::RecordContext, const FromTy *,
1608 CastInfo<::clang::extractapi::RecordContext, FromTy *>> {};
1609
1610template <typename ToTy>
1611struct CastInfo<ToTy, ::clang::extractapi::RecordContext *>
1612 : public NullableValueCastFailed<ToTy *>,
1614 ToTy *, ::clang::extractapi::RecordContext *,
1615 CastInfo<ToTy, ::clang::extractapi::RecordContext *>> {
1617 return ::clang::extractapi::FromRecordContextCastInfoWrapper<
1618 ToTy>::isPossible(Ctx);
1619 }
1620
1621 static inline ToTy *doCast(::clang::extractapi::RecordContext *Ctx) {
1622 return ::clang::extractapi::FromRecordContextCastInfoWrapper<ToTy>::doCast(
1623 Ctx);
1624 }
1625};
1626
1627template <typename ToTy>
1628struct CastInfo<ToTy, const ::clang::extractapi::RecordContext *>
1630 ToTy, const ::clang::extractapi::RecordContext *,
1631 CastInfo<ToTy, ::clang::extractapi::RecordContext *>> {};
1632
1633} // namespace llvm
1634
1635#endif // LLVM_CLANG_EXTRACTAPI_API_H
enum clang::sema::@1718::IndirectLocalPathEntry::EntryKind Kind
This file defines the Declaration Fragments related classes.
llvm::MachO::Target Target
Definition: MachO.h:51
llvm::MachO::Record Record
Definition: MachO.h:31
SourceLocation Loc
Definition: SemaObjC.cpp:759
Defines the clang::SourceLocation class and associated facilities.
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:399
The base class of the type hierarchy.
Definition: Type.h:1828
APISet holds the set of API records collected from given inputs.
Definition: API.h:1427
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:1498
APISet & operator=(const APISet &Other)=delete
SymbolReference createSymbolReference(StringRef Name, StringRef USR, StringRef Source="")
Definition: API.cpp:134
Language getLanguage() const
Get the language used by the APIs.
Definition: API.h:1433
ArrayRef< const APIRecord * > getTopLevelRecords() const
Definition: API.h:1456
const std::string ProductName
Definition: API.h:1493
APISet(const APISet &Other)=delete
StringRef copyString(StringRef String)
Copy String into the Allocator in this APISet.
Definition: API.cpp:121
APISet(APISet &&Other)=delete
const llvm::Triple & getTarget() const
Get the target triple for the ExtractAPI invocation.
Definition: API.h:1430
APISet & operator=(APISet &&Other)=delete
void removeRecord(StringRef USR)
Definition: API.cpp:139
APIRecord * findRecordForUSR(StringRef USR) const
Finds the APIRecord for a given USR.
Definition: API.cpp:110
APISet(const llvm::Triple &Target, Language Lang, const std::string &ProductName)
Definition: API.h:1464
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:306
void removeFromRecordChain(APIRecord *Record)
Definition: API.cpp:94
record_iterator records_begin() const
Definition: API.h:367
bool records_empty() const
Definition: API.h:369
static bool classof(const RecordContext *Context)
Definition: API.h:316
llvm::iterator_range< record_iterator > record_range
Definition: API.h:363
APIRecord::RecordKind getKind() const
Definition: API.h:326
record_range records() const
Definition: API.h:364
void stealRecordChain(RecordContext &Other)
Append Other children chain into ours and empty out Other's record chain.
Definition: API.cpp:59
record_iterator records_end() const
Definition: API.h:368
static bool classofKind(APIRecord::RecordKind K)
Definition: API.h:311
void addToRecordChain(APIRecord *) const
Definition: API.cpp:82
RecordContext(APIRecord::RecordKind Kind)
Definition: API.h:318
static bool classof(const APIRecord *Record)
Definition: API.h:308
void addTemplateParameter(std::string Type, std::string Name, unsigned int Index, unsigned int Depth, bool IsParameterPack)
Definition: API.h:129
Template(const TemplateDecl *Decl)
Definition: API.h:67
Template(const VarTemplatePartialSpecializationDecl *Decl)
Definition: API.h:103
Template(const ClassTemplatePartialSpecializationDecl *Decl)
Definition: API.h:85
const llvm::SmallVector< TemplateParameter > & getParameters() const
Definition: API.h:121
const llvm::SmallVector< TemplateConstraint > & getConstraints() const
Definition: API.h:125
bool empty() const
Definition: API.h:135
std::vector< RawComment::CommentLine > DocComment
DocComment is a vector of RawComment::CommentLine.
Definition: API.h:151
The JSON file list parser is used to communicate input to InstallAPI.
Linkage
Describes the different kinds of linkage (C++ [basic.link], C99 6.2.2) that an entity may have.
Definition: Linkage.h:24
Language
The language for the input, used to select and validate the language standard and possible actions.
Definition: LangStandard.h:23
@ Parameter
The parameter type of a method or function.
@ Result
The result type of a method or function.
llvm::PointerUnion< TemplateTypeParmDecl *, NonTypeTemplateParmDecl *, TemplateTemplateParmDecl * > TemplateParameter
Stores a template parameter of any kind.
Definition: DeclTemplate.h:65
@ Other
Other implicit parameter.
Diagnostic wrappers for TextAPI types for error reporting.
Definition: Dominators.h:30
#define true
Definition: stdbool.h:25
Storage of availability attributes for a declaration.
Definition: Availability.h:64
The base representation of an API record. Holds common symbol information.
Definition: API.h:185
RecordKind getKind() const
Definition: API.h:274
APIRecord(RecordKind Kind, StringRef USR, StringRef Name)
Definition: API.h:294
DocComment Comment
Documentation comment lines attached to this symbol declaration.
Definition: API.h:244
AvailabilityInfo Availability
Definition: API.h:240
DeclarationFragments Declaration
Declaration fragments of this symbol declaration.
Definition: API.h:247
RecordKind getKindForDisplay() const
Definition: API.h:275
RecordKind KindForDisplay
Definition: API.h:262
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:282
LinkageInfo Linkage
Definition: API.h:241
virtual ~APIRecord()=0
Definition: API.cpp:168
DeclarationFragments SubHeading
SubHeading provides a more detailed representation than the plain declaration name.
Definition: API.h:255
APIRecord * getNextInContext() const
Definition: API.h:272
static APIRecord * castFromRecordContext(const RecordContext *Ctx)
Definition: API.cpp:26
AccessControl Access
Definition: API.h:260
PresumedLoc Location
Definition: API.h:239
static bool classofKind(RecordKind K)
Definition: API.h:300
RecordKind
Discriminator for LLVM-style RTTI (dyn_cast<> et al.)
Definition: API.h:187
@ RK_GlobalFunctionTemplateSpecialization
Definition: API.h:216
@ RK_GlobalVariableTemplatePartialSpecialization
Definition: API.h:212
@ RK_GlobalVariableTemplateSpecialization
Definition: API.h:211
@ RK_ClassTemplatePartialSpecialization
Definition: API.h:203
static RecordContext * castToRecordContext(const APIRecord *Record)
Definition: API.cpp:39
SymbolReference Parent
Definition: API.h:237
static bool classof(const RecordContext *Ctx)
Definition: API.h:301
bool IsFromSystemHeader
Whether the symbol was defined in a system header.
Definition: API.h:258
static bool classof(const APIRecord *Record)
Definition: API.h:299
SmallVector< SymbolReference > Bases
Definition: API.h:1199
static bool classofKind(RecordKind K)
Definition: API.h:1214
static bool classof(const APIRecord *Record)
Definition: API.h:1211
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:1201
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:875
static bool classof(const APIRecord *Record)
Definition: API.h:886
static bool classofKind(RecordKind K)
Definition: API.h:889
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:896
static bool classofKind(RecordKind K)
Definition: API.h:910
static bool classof(const APIRecord *Record)
Definition: API.h:907
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:803
static bool classofKind(RecordKind K)
Definition: API.h:827
static bool classof(const APIRecord *Record)
Definition: API.h:824
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:813
static bool classof(const APIRecord *Record)
Definition: API.h:849
static bool classofKind(RecordKind K)
Definition: API.h:852
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:838
static bool classof(const APIRecord *Record)
Definition: API.h:950
static bool classofKind(RecordKind K)
Definition: API.h:953
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:938
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:860
FunctionSignature Signature
Definition: API.h:856
static bool classofKind(RecordKind K)
Definition: API.h:978
static bool classof(const APIRecord *Record)
Definition: API.h:975
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:962
static bool classof(const APIRecord *Record)
Definition: API.h:993
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:982
static bool classof(const APIRecord *Record)
Definition: API.h:928
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:917
static bool classofKind(RecordKind K)
Definition: API.h:931
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:1264
static bool classof(const APIRecord *Record)
Definition: API.h:1275
static bool classof(const APIRecord *Record)
Definition: API.h:1238
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:1227
static bool classofKind(RecordKind K)
Definition: API.h:1241
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:1245
static bool classof(const APIRecord *Record)
Definition: API.h:1254
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:1286
static bool classof(const APIRecord *Record)
Definition: API.h:1296
static bool classofKind(RecordKind K)
Definition: API.h:1299
This holds information associated with enum constants.
Definition: API.h:583
EnumConstantRecord(StringRef USR, StringRef Name, SymbolReference Parent, PresumedLoc Loc, AvailabilityInfo Availability, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading, bool IsFromSystemHeader)
Definition: API.h:584
static bool classofKind(RecordKind K)
Definition: API.h:596
static bool classof(const APIRecord *Record)
Definition: API.h:593
This holds information associated with enums.
Definition: API.h:645
static bool classof(const APIRecord *Record)
Definition: API.h:656
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:646
static bool classofKind(RecordKind K)
Definition: API.h:660
static RecordContext * doCast(RecordContext *Ctx)
Definition: API.h:1575
static ToTy * doCast(RecordContext *Ctx)
Definition: API.h:1562
static bool isPossible(RecordContext *Ctx)
Definition: API.h:1558
This holds information associated with global functions.
Definition: API.h:400
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:414
static bool classof(const APIRecord *Record)
Definition: API.h:426
static bool classofKind(RecordKind K)
Definition: API.h:429
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:403
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:438
static bool classofKind(RecordKind K)
Definition: API.h:455
static bool classof(const APIRecord *Record)
Definition: API.h:452
static bool classof(const APIRecord *Record)
Definition: API.h:472
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:461
This holds information associated with global functions.
Definition: API.h:481
static bool classof(const APIRecord *Record)
Definition: API.h:503
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:492
static bool classofKind(RecordKind K)
Definition: API.h:506
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:482
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:562
static bool classof(const APIRecord *Record)
Definition: API.h:531
static bool classofKind(RecordKind K)
Definition: API.h:534
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:519
static bool classof(const APIRecord *Record)
Definition: API.h:550
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:540
This holds information associated with macro definitions.
Definition: API.h:1381
static bool classof(const APIRecord *Record)
Definition: API.h:1390
MacroDefinitionRecord(StringRef USR, StringRef Name, SymbolReference Parent, PresumedLoc Loc, DeclarationFragments Declaration, DeclarationFragments SubHeading, bool IsFromSystemHeader)
Definition: API.h:1382
static bool classofKind(RecordKind K)
Definition: API.h:1393
static bool classof(const APIRecord *Record)
Definition: API.h:393
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:383
static bool classofKind(RecordKind K)
Definition: API.h:396
This holds information associated with Objective-C categories.
Definition: API.h:1303
static bool classofKind(RecordKind K)
Definition: API.h:1321
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:1306
std::optional< StringRef > getExtendedExternalModule() const
Definition: API.h:1325
bool isExtendingExternalModule() const
Definition: API.h:1323
static bool classof(const APIRecord *Record)
Definition: API.h:1318
static bool classofKind(RecordKind K)
Definition: API.h:1154
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:1141
static bool classof(const APIRecord *Record)
Definition: API.h:1151
static bool classof(const APIRecord *Record)
Definition: API.h:1069
static bool classofKind(RecordKind K)
Definition: API.h:1072
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:1056
The base representation of an Objective-C container record.
Definition: API.h:1179
SmallVector< SymbolReference > Protocols
Definition: API.h:1180
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:1184
static bool classofKind(RecordKind K)
Definition: API.h:1134
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:1121
static bool classof(const APIRecord *Record)
Definition: API.h:1131
static bool classof(const APIRecord *Record)
Definition: API.h:1046
static bool classofKind(RecordKind K)
Definition: API.h:1049
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:1035
This holds information associated with Objective-C instance variables.
Definition: API.h:1079
static bool classofKind(RecordKind K)
Definition: API.h:1094
ObjCInstanceVariableRecord(StringRef USR, StringRef Name, SymbolReference Parent, PresumedLoc Loc, AvailabilityInfo Availability, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading, bool IsFromSystemHeader)
Definition: API.h:1080
static bool classof(const APIRecord *Record)
Definition: API.h:1091
This holds information associated with Objective-C interfaces/classes.
Definition: API.h:1336
static bool classof(const APIRecord *Record)
Definition: API.h:1350
static bool classofKind(RecordKind K)
Definition: API.h:1353
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:1339
This holds information associated with Objective-C methods.
Definition: API.h:1101
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:1106
FunctionSignature Signature
Definition: API.h:1102
This holds information associated with Objective-C properties.
Definition: API.h:1002
AttributeKind
The attributes associated with an Objective-C property.
Definition: API.h:1004
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:1015
This holds information associated with Objective-C protocols.
Definition: API.h:1360
static bool classof(const APIRecord *Record)
Definition: API.h:1371
static bool classofKind(RecordKind K)
Definition: API.h:1374
ObjCProtocolRecord(StringRef USR, StringRef Name, SymbolReference Parent, PresumedLoc Loc, AvailabilityInfo Availability, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading, bool IsFromSystemHeader)
Definition: API.h:1361
std::forward_iterator_tag iterator_category
Definition: API.h:336
friend bool operator==(record_iterator x, record_iterator y)
Definition: API.h:355
friend bool operator!=(record_iterator x, record_iterator y)
Definition: API.h:358
This holds information associated with struct or union fields fields.
Definition: API.h:667
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:668
static bool classofKind(RecordKind K)
Definition: API.h:681
static bool classof(const APIRecord *Record)
Definition: API.h:678
This holds information associated with structs and unions.
Definition: API.h:689
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:690
static bool classof(const APIRecord *Record)
Definition: API.h:701
static bool classofKind(RecordKind K)
Definition: API.h:704
static bool classof(const APIRecord *Record)
Definition: API.h:1171
static bool classofKind(RecordKind K)
Definition: API.h:1174
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:1161
static bool classof(const APIRecord *Record)
Definition: API.h:737
static bool classofKind(RecordKind K)
Definition: API.h:740
StructFieldRecord(StringRef USR, StringRef Name, SymbolReference Parent, PresumedLoc Loc, AvailabilityInfo Availability, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading, bool IsFromSystemHeader)
Definition: API.h:729
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:747
static bool classof(const APIRecord *Record)
Definition: API.h:756
static bool classofKind(RecordKind K)
Definition: API.h:759
bool empty() const
Determine if this SymbolReference is empty.
Definition: API.h:175
SymbolReference(StringRef Name, StringRef USR, StringRef Source="")
Definition: API.h:168
StringRef Source
The source project/module/product of the referred symbol.
Definition: API.h:162
static bool classof(const APIRecord *Record)
Definition: API.h:615
static bool classofKind(RecordKind K)
Definition: API.h:618
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:603
virtual ~TagRecord()=0
Definition: API.cpp:169
static RecordContext * doCast(FromTy *From)
Definition: API.h:1534
static bool isPossible(FromTy *From)
Definition: API.h:1532
This holds information associated with typedefs.
Definition: API.h:1404
static bool classofKind(RecordKind K)
Definition: API.h:1420
SymbolReference UnderlyingType
Definition: API.h:1405
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:1407
static bool classof(const APIRecord *Record)
Definition: API.h:1417
static bool classofKind(RecordKind K)
Definition: API.h:777
static bool classof(const APIRecord *Record)
Definition: API.h:774
UnionFieldRecord(StringRef USR, StringRef Name, SymbolReference Parent, PresumedLoc Loc, AvailabilityInfo Availability, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading, bool IsFromSystemHeader)
Definition: API.h:766
static bool classof(const APIRecord *Record)
Definition: API.h:793
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:784
static bool classofKind(RecordKind K)
Definition: API.h:796
static ToTy * doCast(::clang::extractapi::RecordContext *Ctx)
Definition: API.h:1621
static bool isPossible(::clang::extractapi::RecordContext *Ctx)
Definition: API.h:1616
static inline ::clang::extractapi::RecordContext * doCast(FromTy *From)
Definition: API.h:1598