clang 17.0.0git
Public Types | Public Member Functions | Public Attributes | List of all members
clang::extractapi::APISet Class Reference

APISet holds the set of API records collected from given inputs. More...

#include "clang/ExtractAPI/API.h"

Collaboration diagram for clang::extractapi::APISet:
Collaboration graph
[legend]

Public Types

template<typename RecordTy , typename = std::enable_if_t<std::is_base_of<APIRecord, RecordTy>::value>>
using RecordMap = llvm::MapVector< StringRef, std::unique_ptr< RecordTy > >
 A mapping type to store a set of APIRecords with the USR as the key.
 

Public Member Functions

GlobalVariableRecordaddGlobalVar (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.
 
GlobalFunctionRecordaddGlobalFunction (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.
 
EnumConstantRecordaddEnumConstant (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.
 
EnumRecordaddEnum (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.
 
StructFieldRecordaddStructField (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.
 
StructRecordaddStruct (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.
 
ObjCCategoryRecordaddObjCCategory (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.
 
ObjCInterfaceRecordaddObjCInterface (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.
 
ObjCMethodRecordaddObjCMethod (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.
 
ObjCPropertyRecordaddObjCProperty (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.
 
ObjCInstanceVariableRecordaddObjCInstanceVariable (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.
 
ObjCProtocolRecordaddObjCProtocol (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.
 
MacroDefinitionRecordaddMacroDefinition (StringRef Name, StringRef USR, PresumedLoc Loc, DeclarationFragments Declaration, DeclarationFragments SubHeading, bool IsFromSystemHeader)
 Create a macro definition record into the API set.
 
TypedefRecordaddTypedef (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.
 
const llvm::Triple & getTarget () const
 Get the target triple for the ExtractAPI invocation.
 
Language getLanguage () const
 Get the language used by the APIs.
 
const RecordMap< GlobalFunctionRecord > & getGlobalFunctions () const
 
const RecordMap< GlobalVariableRecord > & getGlobalVariables () const
 
const RecordMap< EnumRecord > & getEnums () const
 
const RecordMap< StructRecord > & getStructs () const
 
const RecordMap< ObjCCategoryRecord > & getObjCCategories () const
 
const RecordMap< ObjCInterfaceRecord > & getObjCInterfaces () const
 
const RecordMap< ObjCProtocolRecord > & getObjCProtocols () const
 
const RecordMap< MacroDefinitionRecord > & getMacros () const
 
const RecordMap< TypedefRecord > & getTypedefs () const
 
APIRecordfindRecordForUSR (StringRef USR) const
 Finds the APIRecord for a given USR.
 
StringRef recordUSR (const Decl *D)
 Generate and store the USR of declaration D.
 
StringRef recordUSRForMacro (StringRef Name, SourceLocation SL, const SourceManager &SM)
 Generate and store the USR for a macro Name.
 
StringRef copyString (StringRef String)
 Copy String into the Allocator in this APISet.
 
 APISet (const llvm::Triple &Target, Language Lang, const std::string &ProductName)
 

Public Attributes

const std::string ProductName
 

Detailed Description

APISet holds the set of API records collected from given inputs.

Definition at line 596 of file API.h.

Member Typedef Documentation

◆ RecordMap

template<typename RecordTy , typename = std::enable_if_t<std::is_base_of<APIRecord, RecordTy>::value>>
using clang::extractapi::APISet::RecordMap = llvm::MapVector<StringRef, std::unique_ptr<RecordTy> >

A mapping type to store a set of APIRecords with the USR as the key.

Definition at line 779 of file API.h.

Constructor & Destructor Documentation

◆ APISet()

clang::extractapi::APISet::APISet ( const llvm::Triple &  Target,
Language  Lang,
const std::string &  ProductName 
)
inline

Definition at line 832 of file API.h.

References clang::Target.

Member Function Documentation

◆ addEnum()

EnumRecord * APISet::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.

Note: the caller is responsible for keeping the StringRef Name and USR alive. APISet::copyString provides a way to copy strings into APISet itself, and APISet::recordUSR(const Decl *D) is a helper method to generate the USR for D and keep it alive in APISet.

Definition at line 85 of file API.cpp.

References clang::Declaration.

Referenced by clang::extractapi::ExtractAPIVisitor::VisitEnumDecl().

◆ addEnumConstant()

EnumConstantRecord * APISet::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.

Note: the caller is responsible for keeping the StringRef Name and USR alive. APISet::copyString provides a way to copy strings into APISet itself, and APISet::recordUSR(const Decl *D) is a helper method to generate the USR for D and keep it alive in APISet.

Definition at line 69 of file API.cpp.

References clang::Declaration, and Enum.

◆ addGlobalFunction()

GlobalFunctionRecord * APISet::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.

Note: the caller is responsible for keeping the StringRef Name and USR alive. APISet::copyString provides a way to copy strings into APISet itself, and APISet::recordUSR(const Decl *D) is a helper method to generate the USR for D and keep it alive in APISet.

Definition at line 57 of file API.cpp.

Referenced by clang::extractapi::ExtractAPIVisitor::VisitFunctionDecl().

◆ addGlobalVar()

GlobalVariableRecord * APISet::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.

Note: the caller is responsible for keeping the StringRef Name and USR alive. APISet::copyString provides a way to copy strings into APISet itself, and APISet::recordUSR(const Decl *D) is a helper method to generate the USR for D and keep it alive in APISet.

Definition at line 48 of file API.cpp.

Referenced by clang::extractapi::ExtractAPIVisitor::VisitVarDecl().

◆ addMacroDefinition()

MacroDefinitionRecord * APISet::addMacroDefinition ( StringRef  Name,
StringRef  USR,
PresumedLoc  Loc,
DeclarationFragments  Declaration,
DeclarationFragments  SubHeading,
bool  IsFromSystemHeader 
)

Create a macro definition record into the API set.

Note: the caller is responsible for keeping the StringRef Name and USR alive. APISet::copyString provides a way to copy strings into APISet itself, and APISet::recordUSRForMacro(StringRef Name, SourceLocation SL, const SourceManager &SM) is a helper method to generate the USR for the macro and keep it alive in APISet.

Definition at line 229 of file API.cpp.

References clang::Declaration.

◆ addObjCCategory()

ObjCCategoryRecord * APISet::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.

Note: the caller is responsible for keeping the StringRef Name and USR alive. APISet::copyString provides a way to copy strings into APISet itself, and APISet::recordUSR(const Decl *D) is a helper method to generate the USR for D and keep it alive in APISet.

Definition at line 123 of file API.cpp.

References clang::Declaration, and clang::extractapi::SymbolReference::USR.

Referenced by clang::extractapi::ExtractAPIVisitor::VisitObjCCategoryDecl().

◆ addObjCInstanceVariable()

ObjCInstanceVariableRecord * APISet::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.

Note: the caller is responsible for keeping the StringRef Name and USR alive. APISet::copyString provides a way to copy strings into APISet itself, and APISet::recordUSR(const Decl *D) is a helper method to generate the USR for D and keep it alive in APISet.

Definition at line 202 of file API.cpp.

References clang::Declaration.

◆ addObjCInterface()

ObjCInterfaceRecord * APISet::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.

Note: the caller is responsible for keeping the StringRef Name and USR alive. APISet::copyString provides a way to copy strings into APISet itself, and APISet::recordUSR(const Decl *D) is a helper method to generate the USR for D and keep it alive in APISet.

Definition at line 144 of file API.cpp.

References clang::Declaration.

Referenced by clang::extractapi::ExtractAPIVisitor::VisitObjCInterfaceDecl().

◆ addObjCMethod()

ObjCMethodRecord * APISet::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.

Note: the caller is responsible for keeping the StringRef Name and USR alive. APISet::copyString provides a way to copy strings into APISet itself, and APISet::recordUSR(const Decl *D) is a helper method to generate the USR for D and keep it alive in APISet.

Definition at line 156 of file API.cpp.

References clang::Declaration.

◆ addObjCProperty()

ObjCPropertyRecord * APISet::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.

Note: the caller is responsible for keeping the StringRef Name and USR alive. APISet::copyString provides a way to copy strings into APISet itself, and APISet::recordUSR(const Decl *D) is a helper method to generate the USR for D and keep it alive in APISet.

Definition at line 178 of file API.cpp.

References clang::Declaration.

◆ addObjCProtocol()

ObjCProtocolRecord * APISet::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.

Note: the caller is responsible for keeping the StringRef Name and USR alive. APISet::copyString provides a way to copy strings into APISet itself, and APISet::recordUSR(const Decl *D) is a helper method to generate the USR for D and keep it alive in APISet.

Definition at line 216 of file API.cpp.

References clang::Declaration.

Referenced by clang::extractapi::ExtractAPIVisitor::VisitObjCProtocolDecl().

◆ addStruct()

StructRecord * APISet::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.

Note: the caller is responsible for keeping the StringRef Name and USR alive. APISet::copyString provides a way to copy strings into APISet itself, and APISet::recordUSR(const Decl *D) is a helper method to generate the USR for D and keep it alive in APISet.

Definition at line 112 of file API.cpp.

References clang::Declaration.

Referenced by clang::extractapi::ExtractAPIVisitor::VisitRecordDecl().

◆ addStructField()

StructFieldRecord * APISet::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.

Note: the caller is responsible for keeping the StringRef Name and USR alive. APISet::copyString provides a way to copy strings into APISet itself, and APISet::recordUSR(const Decl *D) is a helper method to generate the USR for D and keep it alive in APISet.

Definition at line 96 of file API.cpp.

References clang::Declaration.

◆ addTypedef()

TypedefRecord * APISet::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.

Note: the caller is responsible for keeping the StringRef Name and USR alive. APISet::copyString provides a way to copy strings into APISet itself, and APISet::recordUSR(const Decl *D) is a helper method to generate the USR for D and keep it alive in APISet.

Definition at line 238 of file API.cpp.

References clang::Declaration.

Referenced by clang::extractapi::ExtractAPIVisitor::VisitTypedefNameDecl().

◆ copyString()

StringRef APISet::copyString ( StringRef  String)

Copy String into the Allocator in this APISet.

Returns
a StringRef of the copied string in APISet::Allocator.

Definition at line 271 of file API.cpp.

References memcpy().

Referenced by clang::extractapi::TypedefUnderlyingTypeResolver::getSymbolReferenceForType(), recordUSR(), recordUSRForMacro(), and clang::extractapi::ExtractAPIVisitor::VisitEnumDecl().

◆ findRecordForUSR()

APIRecord * APISet::findRecordForUSR ( StringRef  USR) const

Finds the APIRecord for a given USR.

Returns
a pointer to the APIRecord associated with that USR or nullptr.

Definition at line 248 of file API.cpp.

Referenced by clang::extractapi::SymbolGraphSerializer::serializeSingleSymbolSGF().

◆ getEnums()

const RecordMap< EnumRecord > & clang::extractapi::APISet::getEnums ( ) const
inline

Definition at line 793 of file API.h.

Referenced by clang::extractapi::SymbolGraphSerializer::serialize().

◆ getGlobalFunctions()

const RecordMap< GlobalFunctionRecord > & clang::extractapi::APISet::getGlobalFunctions ( ) const
inline

Definition at line 787 of file API.h.

Referenced by clang::extractapi::SymbolGraphSerializer::serialize().

◆ getGlobalVariables()

const RecordMap< GlobalVariableRecord > & clang::extractapi::APISet::getGlobalVariables ( ) const
inline

Definition at line 790 of file API.h.

Referenced by clang::extractapi::SymbolGraphSerializer::serialize().

◆ getLanguage()

Language clang::extractapi::APISet::getLanguage ( ) const
inline

Get the language used by the APIs.

Definition at line 785 of file API.h.

Referenced by clang::extractapi::SymbolGraphSerializer::serializeSingleSymbolSGF().

◆ getMacros()

const RecordMap< MacroDefinitionRecord > & clang::extractapi::APISet::getMacros ( ) const
inline

Definition at line 804 of file API.h.

Referenced by clang::extractapi::SymbolGraphSerializer::serialize().

◆ getObjCCategories()

const RecordMap< ObjCCategoryRecord > & clang::extractapi::APISet::getObjCCategories ( ) const
inline

Definition at line 795 of file API.h.

◆ getObjCInterfaces()

const RecordMap< ObjCInterfaceRecord > & clang::extractapi::APISet::getObjCInterfaces ( ) const
inline

Definition at line 798 of file API.h.

Referenced by clang::extractapi::SymbolGraphSerializer::serialize().

◆ getObjCProtocols()

const RecordMap< ObjCProtocolRecord > & clang::extractapi::APISet::getObjCProtocols ( ) const
inline

Definition at line 801 of file API.h.

Referenced by clang::extractapi::SymbolGraphSerializer::serialize().

◆ getStructs()

const RecordMap< StructRecord > & clang::extractapi::APISet::getStructs ( ) const
inline

Definition at line 794 of file API.h.

Referenced by clang::extractapi::SymbolGraphSerializer::serialize().

◆ getTarget()

const llvm::Triple & clang::extractapi::APISet::getTarget ( ) const
inline

Get the target triple for the ExtractAPI invocation.

Definition at line 782 of file API.h.

◆ getTypedefs()

const RecordMap< TypedefRecord > & clang::extractapi::APISet::getTypedefs ( ) const
inline

Definition at line 805 of file API.h.

Referenced by clang::extractapi::SymbolGraphSerializer::serialize().

◆ recordUSR()

StringRef APISet::recordUSR ( const Decl D)

◆ recordUSRForMacro()

StringRef APISet::recordUSRForMacro ( StringRef  Name,
SourceLocation  SL,
const SourceManager SM 
)

Generate and store the USR for a macro Name.

Note: The USR string is stored in and owned by Allocator.

Returns
a StringRef to the generate USR string.

Definition at line 264 of file API.cpp.

References copyString(), clang::index::generateUSRForMacro(), and SM.

Member Data Documentation

◆ ProductName

const std::string clang::extractapi::APISet::ProductName

The documentation for this class was generated from the following files: