clang 17.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
21#include "clang/AST/Decl.h"
22#include "clang/AST/DeclObjC.h"
27#include "llvm/ADT/MapVector.h"
28#include "llvm/ADT/StringRef.h"
29#include "llvm/Support/Allocator.h"
30#include "llvm/Support/Casting.h"
31#include "llvm/TargetParser/Triple.h"
32#include <memory>
33#include <type_traits>
34
35namespace clang {
36namespace extractapi {
37
38/// DocComment is a vector of RawComment::CommentLine.
39///
40/// Each line represents one line of striped documentation comment,
41/// with source range information. This simplifies calculating the source
42/// location of a character in the doc comment for pointing back to the source
43/// file.
44/// e.g.
45/// \code
46/// /// This is a documentation comment
47/// ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~' First line.
48/// /// with multiple lines.
49/// ^~~~~~~~~~~~~~~~~~~~~~~' Second line.
50/// \endcode
51using DocComment = std::vector<RawComment::CommentLine>;
52
53// Classes deriving from APIRecord need to have USR be the first constructor
54// argument. This is so that they are compatible with `addTopLevelRecord`
55// defined in API.cpp
56/// The base representation of an API record. Holds common symbol information.
57struct APIRecord {
58 /// Discriminator for LLVM-style RTTI (dyn_cast<> et al.)
77 };
78
79 /// Stores information about the context of the declaration of this API.
80 /// This is roughly analogous to the DeclContext hierarchy for an AST Node.
82 /// The USR of the parent API.
83 StringRef ParentUSR;
84 /// The name of the parent API.
85 StringRef ParentName;
86 /// The record kind of the parent API.
88 /// A pointer to the parent APIRecord if known.
90
93 RecordKind Kind, APIRecord *ParentRecord = nullptr)
96
97 bool empty() const {
98 return ParentUSR.empty() && ParentName.empty() &&
99 ParentKind == RK_Unknown && ParentRecord == nullptr;
100 }
101 };
102
103 StringRef USR;
104 StringRef Name;
108
109 /// Documentation comment lines attached to this symbol declaration.
111
112 /// Declaration fragments of this symbol declaration.
114
115 /// SubHeading provides a more detailed representation than the plain
116 /// declaration name.
117 ///
118 /// SubHeading is an array of declaration fragments of tagged declaration
119 /// name, with potentially more tokens (for example the \c +/- symbol for
120 /// Objective-C class/instance methods).
122
123 /// Information about the parent record of this record.
125
126 /// Whether the symbol was defined in a system header.
128
129private:
130 const RecordKind Kind;
131
132public:
133 RecordKind getKind() const { return Kind; }
134
135 APIRecord() = delete;
136
137 APIRecord(RecordKind Kind, StringRef USR, StringRef Name,
146
147 // Pure virtual destructor to make APIRecord abstract
148 virtual ~APIRecord() = 0;
149};
150
151/// This holds information associated with global functions.
154
155 GlobalFunctionRecord(StringRef USR, StringRef Name, PresumedLoc Loc,
157 const DocComment &Comment,
165
166 static bool classof(const APIRecord *Record) {
167 return Record->getKind() == RK_GlobalFunction;
168 }
169
170private:
171 virtual void anchor();
172};
173
174/// This holds information associated with global functions.
176 GlobalVariableRecord(StringRef USR, StringRef Name, PresumedLoc Loc,
178 const DocComment &Comment,
184
185 static bool classof(const APIRecord *Record) {
186 return Record->getKind() == RK_GlobalVariable;
187 }
188
189private:
190 virtual void anchor();
191};
192
193/// This holds information associated with enum constants.
195 EnumConstantRecord(StringRef USR, StringRef Name, PresumedLoc Loc,
202
203 static bool classof(const APIRecord *Record) {
204 return Record->getKind() == RK_EnumConstant;
205 }
206
207private:
208 virtual void anchor();
209};
210
211/// This holds information associated with enums.
214
215 EnumRecord(StringRef USR, StringRef Name, PresumedLoc Loc,
219 : APIRecord(RK_Enum, USR, Name, Loc, std::move(Availabilities),
222
223 static bool classof(const APIRecord *Record) {
224 return Record->getKind() == RK_Enum;
225 }
226
227private:
228 virtual void anchor();
229};
230
231/// This holds information associated with struct fields.
233 StructFieldRecord(StringRef USR, StringRef Name, PresumedLoc Loc,
240
241 static bool classof(const APIRecord *Record) {
242 return Record->getKind() == RK_StructField;
243 }
244
245private:
246 virtual void anchor();
247};
248
249/// This holds information associated with structs.
252
253 StructRecord(StringRef USR, StringRef Name, PresumedLoc Loc,
257 : APIRecord(RK_Struct, USR, Name, Loc, std::move(Availabilities),
260
261 static bool classof(const APIRecord *Record) {
262 return Record->getKind() == RK_Struct;
263 }
264
265private:
266 virtual void anchor();
267};
268
269/// This holds information associated with Objective-C properties.
271 /// The attributes associated with an Objective-C property.
272 enum AttributeKind : unsigned {
275 Dynamic = 1 << 2,
276 };
277
279 StringRef GetterName;
280 StringRef SetterName;
282
283 ObjCPropertyRecord(RecordKind Kind, StringRef USR, StringRef Name,
285 const DocComment &Comment,
288 StringRef GetterName, StringRef SetterName,
290 : APIRecord(Kind, USR, Name, Loc, std::move(Availabilities),
295
296 bool isReadOnly() const { return Attributes & ReadOnly; }
297 bool isDynamic() const { return Attributes & Dynamic; }
298
299 virtual ~ObjCPropertyRecord() = 0;
300};
301
305 const DocComment &Comment,
309 StringRef SetterName, bool IsOptional,
315
316 static bool classof(const APIRecord *Record) {
317 return Record->getKind() == RK_ObjCInstanceProperty;
318 }
319
320private:
321 virtual void anchor();
322};
323
325 ObjCClassPropertyRecord(StringRef USR, StringRef Name, PresumedLoc Loc,
327 const DocComment &Comment,
331 StringRef SetterName, bool IsOptional,
337
338 static bool classof(const APIRecord *Record) {
339 return Record->getKind() == RK_ObjCClassProperty;
340 }
341
342private:
343 virtual void anchor();
344};
345
346/// This holds information associated with Objective-C instance variables.
350
353 const DocComment &Comment,
360 Access(Access) {}
361
362 static bool classof(const APIRecord *Record) {
363 return Record->getKind() == RK_ObjCIvar;
364 }
365
366private:
367 virtual void anchor();
368};
369
370/// This holds information associated with Objective-C methods.
373
375
376 ObjCMethodRecord(RecordKind Kind, StringRef USR, StringRef Name,
381 : APIRecord(Kind, USR, Name, Loc, std::move(Availabilities),
385
386 virtual ~ObjCMethodRecord() = 0;
387};
388
390 ObjCInstanceMethodRecord(StringRef USR, StringRef Name, PresumedLoc Loc,
392 const DocComment &Comment,
399 static bool classof(const APIRecord *Record) {
400 return Record->getKind() == RK_ObjCInstanceMethod;
401 }
402
403private:
404 virtual void anchor();
405};
406
408 ObjCClassMethodRecord(StringRef USR, StringRef Name, PresumedLoc Loc,
410 const DocComment &Comment,
417
418 static bool classof(const APIRecord *Record) {
419 return Record->getKind() == RK_ObjCClassMethod;
420 }
421
422private:
423 virtual void anchor();
424};
425
426/// This represents a reference to another symbol that might come from external
427/// sources.
429 StringRef Name;
430 StringRef USR;
431
432 /// The source project/module/product of the referred symbol.
433 StringRef Source;
434
435 SymbolReference() = default;
436 SymbolReference(StringRef Name, StringRef USR = "", StringRef Source = "")
437 : Name(Name), USR(USR), Source(Source) {}
439 : Name(Record.Name), USR(Record.USR) {}
440
441 /// Determine if this SymbolReference is empty.
442 ///
443 /// \returns true if and only if all \c Name, \c USR, and \c Source is empty.
444 bool empty() const { return Name.empty() && USR.empty() && Source.empty(); }
445};
446
447/// The base representation of an Objective-C container record. Holds common
448/// information associated with Objective-C containers.
454
456
457 ObjCContainerRecord(RecordKind Kind, StringRef USR, StringRef Name,
462 : APIRecord(Kind, USR, Name, Loc, std::move(Availabilities), Linkage,
464
465 virtual ~ObjCContainerRecord() = 0;
466};
467
468/// This holds information associated with Objective-C categories.
471
472 ObjCCategoryRecord(StringRef USR, StringRef Name, PresumedLoc Loc,
478 std::move(Availabilities), LinkageInfo::none(),
482
483 static bool classof(const APIRecord *Record) {
484 return Record->getKind() == RK_ObjCCategory;
485 }
486
487private:
488 virtual void anchor();
489};
490
491/// This holds information associated with Objective-C interfaces/classes.
494 // ObjCCategoryRecord%s are stored in and owned by APISet.
496
497 ObjCInterfaceRecord(StringRef USR, StringRef Name, PresumedLoc Loc,
499 const DocComment &Comment,
507
508 static bool classof(const APIRecord *Record) {
509 return Record->getKind() == RK_ObjCInterface;
510 }
511
512private:
513 virtual void anchor();
514};
515
516/// This holds information associated with Objective-C protocols.
518 ObjCProtocolRecord(StringRef USR, StringRef Name, PresumedLoc Loc,
523 std::move(Availabilities), LinkageInfo::none(),
526
527 static bool classof(const APIRecord *Record) {
528 return Record->getKind() == RK_ObjCProtocol;
529 }
530
531private:
532 virtual void anchor();
533};
534
535/// This holds information associated with macro definitions.
537 MacroDefinitionRecord(StringRef USR, StringRef Name, PresumedLoc Loc,
544
545 static bool classof(const APIRecord *Record) {
546 return Record->getKind() == RK_MacroDefinition;
547 }
548
549private:
550 virtual void anchor();
551};
552
553/// This holds information associated with typedefs.
554///
555/// Note: Typedefs for anonymous enums and structs typically don't get emitted
556/// by the serializers but still get a TypedefRecord. Instead we use the
557/// typedef name as a name for the underlying anonymous struct or enum.
560
561 TypedefRecord(StringRef USR, StringRef Name, PresumedLoc Loc,
570
571 static bool classof(const APIRecord *Record) {
572 return Record->getKind() == RK_Typedef;
573 }
574
575private:
576 virtual void anchor();
577};
578
579/// Check if a record type has a function signature mixin.
580///
581/// This is denoted by the record type having a ``Signature`` field of type
582/// FunctionSignature.
583template <typename RecordTy>
584struct has_function_signature : public std::false_type {};
585template <>
586struct has_function_signature<GlobalFunctionRecord> : public std::true_type {};
587template <>
588struct has_function_signature<ObjCMethodRecord> : public std::true_type {};
589template <>
591 : public std::true_type {};
592template <>
593struct has_function_signature<ObjCClassMethodRecord> : public std::true_type {};
594
595/// APISet holds the set of API records collected from given inputs.
596class APISet {
597public:
598 /// Create and add a global variable record into the API set.
599 ///
600 /// Note: the caller is responsible for keeping the StringRef \p Name and
601 /// \p USR alive. APISet::copyString provides a way to copy strings into
602 /// APISet itself, and APISet::recordUSR(const Decl *D) is a helper method
603 /// to generate the USR for \c D and keep it alive in APISet.
605 addGlobalVar(StringRef Name, StringRef USR, PresumedLoc Loc,
606 AvailabilitySet Availability, LinkageInfo Linkage,
608 DeclarationFragments SubHeadin, bool IsFromSystemHeaderg);
609
610 /// Create and add a function record into the API set.
611 ///
612 /// Note: the caller is responsible for keeping the StringRef \p Name and
613 /// \p USR alive. APISet::copyString provides a way to copy strings into
614 /// APISet itself, and APISet::recordUSR(const Decl *D) is a helper method
615 /// to generate the USR for \c D and keep it alive in APISet.
617 addGlobalFunction(StringRef Name, StringRef USR, PresumedLoc Loc,
618 AvailabilitySet Availability, LinkageInfo Linkage,
620 DeclarationFragments SubHeading,
621 FunctionSignature Signature, bool IsFromSystemHeader);
622
623 /// Create and add an enum constant record into the API set.
624 ///
625 /// Note: the caller is responsible for keeping the StringRef \p Name and
626 /// \p USR alive. APISet::copyString provides a way to copy strings into
627 /// APISet itself, and APISet::recordUSR(const Decl *D) is a helper method
628 /// to generate the USR for \c D and keep it alive in APISet.
630 addEnumConstant(EnumRecord *Enum, StringRef Name, StringRef USR,
631 PresumedLoc Loc, AvailabilitySet Availability,
633 DeclarationFragments SubHeading, bool IsFromSystemHeader);
634
635 /// Create and add an enum record into the API set.
636 ///
637 /// Note: the caller is responsible for keeping the StringRef \p Name and
638 /// \p USR alive. APISet::copyString provides a way to copy strings into
639 /// APISet itself, and APISet::recordUSR(const Decl *D) is a helper method
640 /// to generate the USR for \c D and keep it alive in APISet.
641 EnumRecord *addEnum(StringRef Name, StringRef USR, PresumedLoc Loc,
642 AvailabilitySet Availability, const DocComment &Comment,
644 DeclarationFragments SubHeading, bool IsFromSystemHeader);
645
646 /// Create and add a struct field record into the API set.
647 ///
648 /// Note: the caller is responsible for keeping the StringRef \p Name and
649 /// \p USR alive. APISet::copyString provides a way to copy strings into
650 /// APISet itself, and APISet::recordUSR(const Decl *D) is a helper method
651 /// to generate the USR for \c D and keep it alive in APISet.
653 addStructField(StructRecord *Struct, StringRef Name, StringRef USR,
654 PresumedLoc Loc, AvailabilitySet Availability,
656 DeclarationFragments SubHeading, bool IsFromSystemHeader);
657
658 /// Create and add a struct record into the API set.
659 ///
660 /// Note: the caller is responsible for keeping the StringRef \p Name and
661 /// \p USR alive. APISet::copyString provides a way to copy strings into
662 /// APISet itself, and APISet::recordUSR(const Decl *D) is a helper method
663 /// to generate the USR for \c D and keep it alive in APISet.
664 StructRecord *addStruct(StringRef Name, StringRef USR, PresumedLoc Loc,
665 AvailabilitySet Availability,
666 const DocComment &Comment,
668 DeclarationFragments SubHeading,
669 bool IsFromSystemHeader);
670
671 /// Create and add an Objective-C category record into the API set.
672 ///
673 /// Note: the caller is responsible for keeping the StringRef \p Name and
674 /// \p USR alive. APISet::copyString provides a way to copy strings into
675 /// APISet itself, and APISet::recordUSR(const Decl *D) is a helper method
676 /// to generate the USR for \c D and keep it alive in APISet.
678 addObjCCategory(StringRef Name, StringRef USR, PresumedLoc Loc,
679 AvailabilitySet Availability, const DocComment &Comment,
681 DeclarationFragments SubHeading, SymbolReference Interface,
682 bool IsFromSystemHeader);
683
684 /// Create and add an Objective-C interface record into the API set.
685 ///
686 /// Note: the caller is responsible for keeping the StringRef \p Name and
687 /// \p USR alive. APISet::copyString provides a way to copy strings into
688 /// APISet itself, and APISet::recordUSR(const Decl *D) is a helper method
689 /// to generate the USR for \c D and keep it alive in APISet.
691 addObjCInterface(StringRef Name, StringRef USR, PresumedLoc Loc,
692 AvailabilitySet Availability, LinkageInfo Linkage,
694 DeclarationFragments SubHeading, SymbolReference SuperClass,
695 bool IsFromSystemHeader);
696
697 /// Create and add an Objective-C method record into the API set.
698 ///
699 /// Note: the caller is responsible for keeping the StringRef \p Name and
700 /// \p USR alive. APISet::copyString provides a way to copy strings into
701 /// APISet itself, and APISet::recordUSR(const Decl *D) is a helper method
702 /// to generate the USR for \c D and keep it alive in APISet.
704 addObjCMethod(ObjCContainerRecord *Container, StringRef Name, StringRef USR,
705 PresumedLoc Loc, AvailabilitySet Availability,
707 DeclarationFragments SubHeading, FunctionSignature Signature,
708 bool IsInstanceMethod, bool IsFromSystemHeader);
709
710 /// Create and add an Objective-C property record into the API set.
711 ///
712 /// Note: the caller is responsible for keeping the StringRef \p Name and
713 /// \p USR alive. APISet::copyString provides a way to copy strings into
714 /// APISet itself, and APISet::recordUSR(const Decl *D) is a helper method
715 /// to generate the USR for \c D and keep it alive in APISet.
717 addObjCProperty(ObjCContainerRecord *Container, StringRef Name, StringRef USR,
718 PresumedLoc Loc, AvailabilitySet Availability,
720 DeclarationFragments SubHeading,
722 StringRef GetterName, StringRef SetterName, bool IsOptional,
723 bool IsInstanceProperty, bool IsFromSystemHeader);
724
725 /// Create and add an Objective-C instance variable record into the API set.
726 ///
727 /// Note: the caller is responsible for keeping the StringRef \p Name and
728 /// \p USR alive. APISet::copyString provides a way to copy strings into
729 /// APISet itself, and APISet::recordUSR(const Decl *D) is a helper method
730 /// to generate the USR for \c D and keep it alive in APISet.
732 ObjCContainerRecord *Container, StringRef Name, StringRef USR,
733 PresumedLoc Loc, AvailabilitySet Availability, const DocComment &Comment,
736 bool IsFromSystemHeader);
737
738 /// Create and add an Objective-C protocol record into the API set.
739 ///
740 /// Note: the caller is responsible for keeping the StringRef \p Name and
741 /// \p USR alive. APISet::copyString provides a way to copy strings into
742 /// APISet itself, and APISet::recordUSR(const Decl *D) is a helper method
743 /// to generate the USR for \c D and keep it alive in APISet.
745 addObjCProtocol(StringRef Name, StringRef USR, PresumedLoc Loc,
746 AvailabilitySet Availability, const DocComment &Comment,
748 DeclarationFragments SubHeading, bool IsFromSystemHeader);
749
750 /// Create a macro definition record into the API set.
751 ///
752 /// Note: the caller is responsible for keeping the StringRef \p Name and
753 /// \p USR alive. APISet::copyString provides a way to copy strings into
754 /// APISet itself, and APISet::recordUSRForMacro(StringRef Name,
755 /// SourceLocation SL, const SourceManager &SM) is a helper method to generate
756 /// the USR for the macro and keep it alive in APISet.
757 MacroDefinitionRecord *addMacroDefinition(StringRef Name, StringRef USR,
758 PresumedLoc Loc,
760 DeclarationFragments SubHeading,
761 bool IsFromSystemHeader);
762
763 /// Create a typedef record into the API set.
764 ///
765 /// Note: the caller is responsible for keeping the StringRef \p Name and
766 /// \p USR alive. APISet::copyString provides a way to copy strings into
767 /// APISet itself, and APISet::recordUSR(const Decl *D) is a helper method
768 /// to generate the USR for \c D and keep it alive in APISet.
770 addTypedef(StringRef Name, StringRef USR, PresumedLoc Loc,
771 AvailabilitySet Availability, const DocComment &Comment,
773 SymbolReference UnderlyingType, bool IsFromSystemHeader);
774
775 /// A mapping type to store a set of APIRecord%s with the USR as the key.
776 template <typename RecordTy,
777 typename =
778 std::enable_if_t<std::is_base_of<APIRecord, RecordTy>::value>>
779 using RecordMap = llvm::MapVector<StringRef, std::unique_ptr<RecordTy>>;
780
781 /// Get the target triple for the ExtractAPI invocation.
782 const llvm::Triple &getTarget() const { return Target; }
783
784 /// Get the language used by the APIs.
785 Language getLanguage() const { return Lang; }
786
788 return GlobalFunctions;
789 }
791 return GlobalVariables;
792 }
793 const RecordMap<EnumRecord> &getEnums() const { return Enums; }
794 const RecordMap<StructRecord> &getStructs() const { return Structs; }
796 return ObjCCategories;
797 }
799 return ObjCInterfaces;
800 }
802 return ObjCProtocols;
803 }
804 const RecordMap<MacroDefinitionRecord> &getMacros() const { return Macros; }
805 const RecordMap<TypedefRecord> &getTypedefs() const { return Typedefs; }
806
807 /// Finds the APIRecord for a given USR.
808 ///
809 /// \returns a pointer to the APIRecord associated with that USR or nullptr.
810 APIRecord *findRecordForUSR(StringRef USR) const;
811
812 /// Generate and store the USR of declaration \p D.
813 ///
814 /// Note: The USR string is stored in and owned by Allocator.
815 ///
816 /// \returns a StringRef of the generated USR string.
817 StringRef recordUSR(const Decl *D);
818
819 /// Generate and store the USR for a macro \p Name.
820 ///
821 /// Note: The USR string is stored in and owned by Allocator.
822 ///
823 /// \returns a StringRef to the generate USR string.
824 StringRef recordUSRForMacro(StringRef Name, SourceLocation SL,
825 const SourceManager &SM);
826
827 /// Copy \p String into the Allocator in this APISet.
828 ///
829 /// \returns a StringRef of the copied string in APISet::Allocator.
830 StringRef copyString(StringRef String);
831
832 APISet(const llvm::Triple &Target, Language Lang,
833 const std::string &ProductName)
834 : Target(Target), Lang(Lang), ProductName(ProductName) {}
835
836private:
837 /// BumpPtrAllocator to store generated/copied strings.
838 ///
839 /// Note: The main use for this is being able to deduplicate strings.
840 llvm::BumpPtrAllocator StringAllocator;
841
842 const llvm::Triple Target;
843 const Language Lang;
844
845 llvm::DenseMap<StringRef, APIRecord *> USRBasedLookupTable;
846 RecordMap<GlobalFunctionRecord> GlobalFunctions;
847 RecordMap<GlobalVariableRecord> GlobalVariables;
848 RecordMap<EnumRecord> Enums;
849 RecordMap<StructRecord> Structs;
850 RecordMap<ObjCCategoryRecord> ObjCCategories;
851 RecordMap<ObjCInterfaceRecord> ObjCInterfaces;
852 RecordMap<ObjCProtocolRecord> ObjCProtocols;
853 RecordMap<MacroDefinitionRecord> Macros;
854 RecordMap<TypedefRecord> Typedefs;
855
856public:
857 const std::string ProductName;
858};
859
860} // namespace extractapi
861} // namespace clang
862
863#endif // LLVM_CLANG_EXTRACTAPI_API_H
This file defines the AvailabilityInfo struct that collects availability attributes of a symbol.
#define SM(sm)
Definition: Cuda.cpp:80
This file defines the Declaration Fragments related classes.
Defines the clang::SourceLocation class and associated facilities.
Decl - This represents one declaration (or definition), e.g.
Definition: DeclBase.h:83
Represents an unpacked "presumed" location which can be presented to the user.
Encodes a location in the source.
This class handles loading and caching of source files into memory.
APISet holds the set of API records collected from given inputs.
Definition: API.h:596
ObjCMethodRecord * addObjCMethod(ObjCContainerRecord *Container, StringRef Name, StringRef USR, PresumedLoc Loc, AvailabilitySet Availability, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading, FunctionSignature Signature, bool IsInstanceMethod, bool IsFromSystemHeader)
Create and add an Objective-C method record into the API set.
Definition: API.cpp:156
Language getLanguage() const
Get the language used by the APIs.
Definition: API.h:785
ObjCPropertyRecord * addObjCProperty(ObjCContainerRecord *Container, StringRef Name, StringRef USR, PresumedLoc Loc, AvailabilitySet Availability, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading, ObjCPropertyRecord::AttributeKind Attributes, StringRef GetterName, StringRef SetterName, bool IsOptional, bool IsInstanceProperty, bool IsFromSystemHeader)
Create and add an Objective-C property record into the API set.
Definition: API.cpp:178
const std::string ProductName
Definition: API.h:857
StringRef copyString(StringRef String)
Copy String into the Allocator in this APISet.
Definition: API.cpp:271
TypedefRecord * addTypedef(StringRef Name, StringRef USR, PresumedLoc Loc, AvailabilitySet Availability, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading, SymbolReference UnderlyingType, bool IsFromSystemHeader)
Create a typedef record into the API set.
Definition: API.cpp:238
GlobalVariableRecord * addGlobalVar(StringRef Name, StringRef USR, PresumedLoc Loc, AvailabilitySet Availability, LinkageInfo Linkage, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeadin, bool IsFromSystemHeaderg)
Create and add a global variable record into the API set.
Definition: API.cpp:48
StructFieldRecord * addStructField(StructRecord *Struct, StringRef Name, StringRef USR, PresumedLoc Loc, AvailabilitySet Availability, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading, bool IsFromSystemHeader)
Create and add a struct field record into the API set.
Definition: API.cpp:96
const RecordMap< EnumRecord > & getEnums() const
Definition: API.h:793
const llvm::Triple & getTarget() const
Get the target triple for the ExtractAPI invocation.
Definition: API.h:782
ObjCProtocolRecord * addObjCProtocol(StringRef Name, StringRef USR, PresumedLoc Loc, AvailabilitySet Availability, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading, bool IsFromSystemHeader)
Create and add an Objective-C protocol record into the API set.
Definition: API.cpp:216
ObjCInstanceVariableRecord * addObjCInstanceVariable(ObjCContainerRecord *Container, StringRef Name, StringRef USR, PresumedLoc Loc, AvailabilitySet Availability, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading, ObjCInstanceVariableRecord::AccessControl Access, bool IsFromSystemHeader)
Create and add an Objective-C instance variable record into the API set.
Definition: API.cpp:202
const RecordMap< TypedefRecord > & getTypedefs() const
Definition: API.h:805
ObjCCategoryRecord * addObjCCategory(StringRef Name, StringRef USR, PresumedLoc Loc, AvailabilitySet Availability, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading, SymbolReference Interface, bool IsFromSystemHeader)
Create and add an Objective-C category record into the API set.
Definition: API.cpp:123
ObjCInterfaceRecord * addObjCInterface(StringRef Name, StringRef USR, PresumedLoc Loc, AvailabilitySet Availability, LinkageInfo Linkage, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading, SymbolReference SuperClass, bool IsFromSystemHeader)
Create and add an Objective-C interface record into the API set.
Definition: API.cpp:144
const RecordMap< GlobalVariableRecord > & getGlobalVariables() const
Definition: API.h:790
GlobalFunctionRecord * addGlobalFunction(StringRef Name, StringRef USR, PresumedLoc Loc, AvailabilitySet Availability, LinkageInfo Linkage, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading, FunctionSignature Signature, bool IsFromSystemHeader)
Create and add a function record into the API set.
Definition: API.cpp:57
const RecordMap< MacroDefinitionRecord > & getMacros() const
Definition: API.h:804
const RecordMap< ObjCCategoryRecord > & getObjCCategories() const
Definition: API.h:795
MacroDefinitionRecord * addMacroDefinition(StringRef Name, StringRef USR, PresumedLoc Loc, DeclarationFragments Declaration, DeclarationFragments SubHeading, bool IsFromSystemHeader)
Create a macro definition record into the API set.
Definition: API.cpp:229
const RecordMap< ObjCProtocolRecord > & getObjCProtocols() const
Definition: API.h:801
EnumConstantRecord * addEnumConstant(EnumRecord *Enum, StringRef Name, StringRef USR, PresumedLoc Loc, AvailabilitySet Availability, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading, bool IsFromSystemHeader)
Create and add an enum constant record into the API set.
Definition: API.cpp:69
StringRef recordUSR(const Decl *D)
Generate and store the USR of declaration D.
Definition: API.cpp:258
StringRef recordUSRForMacro(StringRef Name, SourceLocation SL, const SourceManager &SM)
Generate and store the USR for a macro Name.
Definition: API.cpp:264
const RecordMap< ObjCInterfaceRecord > & getObjCInterfaces() const
Definition: API.h:798
const RecordMap< GlobalFunctionRecord > & getGlobalFunctions() const
Definition: API.h:787
StructRecord * addStruct(StringRef Name, StringRef USR, PresumedLoc Loc, AvailabilitySet Availability, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading, bool IsFromSystemHeader)
Create and add a struct record into the API set.
Definition: API.cpp:112
APIRecord * findRecordForUSR(StringRef USR) const
Finds the APIRecord for a given USR.
Definition: API.cpp:248
llvm::MapVector< StringRef, std::unique_ptr< RecordTy > > RecordMap
A mapping type to store a set of APIRecords with the USR as the key.
Definition: API.h:779
const RecordMap< StructRecord > & getStructs() const
Definition: API.h:794
EnumRecord * addEnum(StringRef Name, StringRef USR, PresumedLoc Loc, AvailabilitySet Availability, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading, bool IsFromSystemHeader)
Create and add an enum record into the API set.
Definition: API.cpp:85
APISet(const llvm::Triple &Target, Language Lang, const std::string &ProductName)
Definition: API.h:832
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.
std::vector< RawComment::CommentLine > DocComment
DocComment is a vector of RawComment::CommentLine.
Definition: API.h:51
Linkage
Describes the different kinds of linkage (C++ [basic.link], C99 6.2.2) that an entity may have.
Definition: Linkage.h:23
Language
The language for the input, used to select and validate the language standard and possible actions.
Definition: LangStandard.h:23
Definition: Format.h:4756
Stores information about the context of the declaration of this API.
Definition: API.h:81
RecordKind ParentKind
The record kind of the parent API.
Definition: API.h:87
APIRecord * ParentRecord
A pointer to the parent APIRecord if known.
Definition: API.h:89
HierarchyInformation(StringRef ParentUSR, StringRef ParentName, RecordKind Kind, APIRecord *ParentRecord=nullptr)
Definition: API.h:92
StringRef ParentName
The name of the parent API.
Definition: API.h:85
StringRef ParentUSR
The USR of the parent API.
Definition: API.h:83
The base representation of an API record. Holds common symbol information.
Definition: API.h:57
RecordKind getKind() const
Definition: API.h:133
DocComment Comment
Documentation comment lines attached to this symbol declaration.
Definition: API.h:110
AvailabilitySet Availabilities
Definition: API.h:106
DeclarationFragments Declaration
Declaration fragments of this symbol declaration.
Definition: API.h:113
LinkageInfo Linkage
Definition: API.h:107
virtual ~APIRecord()=0
Definition: API.cpp:284
DeclarationFragments SubHeading
SubHeading provides a more detailed representation than the plain declaration name.
Definition: API.h:121
APIRecord(RecordKind Kind, StringRef USR, StringRef Name, PresumedLoc Location, AvailabilitySet Availabilities, LinkageInfo Linkage, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading, bool IsFromSystemHeader)
Definition: API.h:137
PresumedLoc Location
Definition: API.h:105
HierarchyInformation ParentInformation
Information about the parent record of this record.
Definition: API.h:124
RecordKind
Discriminator for LLVM-style RTTI (dyn_cast<> et al.)
Definition: API.h:59
bool IsFromSystemHeader
Whether the symbol was defined in a system header.
Definition: API.h:127
This holds information associated with enum constants.
Definition: API.h:194
static bool classof(const APIRecord *Record)
Definition: API.h:203
EnumConstantRecord(StringRef USR, StringRef Name, PresumedLoc Loc, AvailabilitySet Availabilities, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading, bool IsFromSystemHeader)
Definition: API.h:195
This holds information associated with enums.
Definition: API.h:212
static bool classof(const APIRecord *Record)
Definition: API.h:223
EnumRecord(StringRef USR, StringRef Name, PresumedLoc Loc, AvailabilitySet Availabilities, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading, bool IsFromSystemHeader)
Definition: API.h:215
SmallVector< std::unique_ptr< EnumConstantRecord > > Constants
Definition: API.h:213
This holds information associated with global functions.
Definition: API.h:152
static bool classof(const APIRecord *Record)
Definition: API.h:166
GlobalFunctionRecord(StringRef USR, StringRef Name, PresumedLoc Loc, AvailabilitySet Availabilities, LinkageInfo Linkage, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading, FunctionSignature Signature, bool IsFromSystemHeader)
Definition: API.h:155
This holds information associated with global functions.
Definition: API.h:175
static bool classof(const APIRecord *Record)
Definition: API.h:185
GlobalVariableRecord(StringRef USR, StringRef Name, PresumedLoc Loc, AvailabilitySet Availabilities, LinkageInfo Linkage, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading, bool IsFromSystemHeader)
Definition: API.h:176
This holds information associated with macro definitions.
Definition: API.h:536
static bool classof(const APIRecord *Record)
Definition: API.h:545
MacroDefinitionRecord(StringRef USR, StringRef Name, PresumedLoc Loc, DeclarationFragments Declaration, DeclarationFragments SubHeading, bool IsFromSystemHeader)
Definition: API.h:537
This holds information associated with Objective-C categories.
Definition: API.h:469
ObjCCategoryRecord(StringRef USR, StringRef Name, PresumedLoc Loc, AvailabilitySet Availabilities, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading, SymbolReference Interface, bool IsFromSystemHeader)
Definition: API.h:472
static bool classof(const APIRecord *Record)
Definition: API.h:483
static bool classof(const APIRecord *Record)
Definition: API.h:418
ObjCClassMethodRecord(StringRef USR, StringRef Name, PresumedLoc Loc, AvailabilitySet Availabilities, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading, FunctionSignature Signature, bool IsFromSystemHeader)
Definition: API.h:408
static bool classof(const APIRecord *Record)
Definition: API.h:338
ObjCClassPropertyRecord(StringRef USR, StringRef Name, PresumedLoc Loc, AvailabilitySet Availabilities, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading, AttributeKind Attributes, StringRef GetterName, StringRef SetterName, bool IsOptional, bool IsFromSystemHeader)
Definition: API.h:325
The base representation of an Objective-C container record.
Definition: API.h:449
ObjCContainerRecord(RecordKind Kind, StringRef USR, StringRef Name, PresumedLoc Loc, AvailabilitySet Availabilities, LinkageInfo Linkage, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading, bool IsFromSystemHeader)
Definition: API.h:457
SmallVector< SymbolReference > Protocols
Definition: API.h:453
SmallVector< std::unique_ptr< ObjCInstanceVariableRecord > > Ivars
Definition: API.h:452
SmallVector< std::unique_ptr< ObjCMethodRecord > > Methods
Definition: API.h:450
SmallVector< std::unique_ptr< ObjCPropertyRecord > > Properties
Definition: API.h:451
static bool classof(const APIRecord *Record)
Definition: API.h:399
ObjCInstanceMethodRecord(StringRef USR, StringRef Name, PresumedLoc Loc, AvailabilitySet Availabilities, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading, FunctionSignature Signature, bool IsFromSystemHeader)
Definition: API.h:390
ObjCInstancePropertyRecord(StringRef USR, StringRef Name, PresumedLoc Loc, AvailabilitySet Availabilities, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading, AttributeKind Attributes, StringRef GetterName, StringRef SetterName, bool IsOptional, bool IsFromSystemHeader)
Definition: API.h:303
static bool classof(const APIRecord *Record)
Definition: API.h:316
This holds information associated with Objective-C instance variables.
Definition: API.h:347
static bool classof(const APIRecord *Record)
Definition: API.h:362
ObjCInstanceVariableRecord(StringRef USR, StringRef Name, PresumedLoc Loc, AvailabilitySet Availabilities, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading, AccessControl Access, bool IsFromSystemHeader)
Definition: API.h:351
This holds information associated with Objective-C interfaces/classes.
Definition: API.h:492
static bool classof(const APIRecord *Record)
Definition: API.h:508
SmallVector< ObjCCategoryRecord * > Categories
Definition: API.h:495
ObjCInterfaceRecord(StringRef USR, StringRef Name, PresumedLoc Loc, AvailabilitySet Availabilities, LinkageInfo Linkage, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading, SymbolReference SuperClass, bool IsFromSystemHeader)
Definition: API.h:497
This holds information associated with Objective-C methods.
Definition: API.h:371
ObjCMethodRecord(RecordKind Kind, StringRef USR, StringRef Name, PresumedLoc Loc, AvailabilitySet Availabilities, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading, FunctionSignature Signature, bool IsFromSystemHeader)
Definition: API.h:376
FunctionSignature Signature
Definition: API.h:372
This holds information associated with Objective-C properties.
Definition: API.h:270
ObjCPropertyRecord(RecordKind Kind, StringRef USR, StringRef Name, PresumedLoc Loc, AvailabilitySet Availabilities, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading, AttributeKind Attributes, StringRef GetterName, StringRef SetterName, bool IsOptional, bool IsFromSystemHeader)
Definition: API.h:283
AttributeKind
The attributes associated with an Objective-C property.
Definition: API.h:272
This holds information associated with Objective-C protocols.
Definition: API.h:517
ObjCProtocolRecord(StringRef USR, StringRef Name, PresumedLoc Loc, AvailabilitySet Availabilities, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading, bool IsFromSystemHeader)
Definition: API.h:518
static bool classof(const APIRecord *Record)
Definition: API.h:527
This holds information associated with struct fields.
Definition: API.h:232
StructFieldRecord(StringRef USR, StringRef Name, PresumedLoc Loc, AvailabilitySet Availabilities, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading, bool IsFromSystemHeader)
Definition: API.h:233
static bool classof(const APIRecord *Record)
Definition: API.h:241
This holds information associated with structs.
Definition: API.h:250
StructRecord(StringRef USR, StringRef Name, PresumedLoc Loc, AvailabilitySet Availabilities, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading, bool IsFromSystemHeader)
Definition: API.h:253
static bool classof(const APIRecord *Record)
Definition: API.h:261
SmallVector< std::unique_ptr< StructFieldRecord > > Fields
Definition: API.h:251
This represents a reference to another symbol that might come from external sources.
Definition: API.h:428
bool empty() const
Determine if this SymbolReference is empty.
Definition: API.h:444
SymbolReference(const APIRecord &Record)
Definition: API.h:438
StringRef Source
The source project/module/product of the referred symbol.
Definition: API.h:433
SymbolReference(StringRef Name, StringRef USR="", StringRef Source="")
Definition: API.h:436
This holds information associated with typedefs.
Definition: API.h:558
SymbolReference UnderlyingType
Definition: API.h:559
TypedefRecord(StringRef USR, StringRef Name, PresumedLoc Loc, AvailabilitySet Availabilities, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading, SymbolReference UnderlyingType, bool IsFromSystemHeader)
Definition: API.h:561
static bool classof(const APIRecord *Record)
Definition: API.h:571
Check if a record type has a function signature mixin.
Definition: API.h:584