clang  14.0.0git
Classes | Typedefs | Enumerations | Functions | Variables
clang::index Namespace Reference

Classes

class  CommentToXMLConverter
 
struct  DeclOccurrence
 
class  FileIndexRecord
 Stores the declaration occurrences seen in a particular source or header file of a translation unit. More...
 
class  IndexDataConsumer
 
class  IndexingContext
 
struct  IndexingOptions
 
class  PathPool
 Pool of filesystem paths backed by a StringPool. More...
 
class  SerializablePathCollection
 Stores file paths and produces serialization-friendly representation. More...
 
class  StringPool
 Pool of strings. More...
 
struct  SymbolInfo
 
struct  SymbolRelation
 Represents a relation to another symbol for a symbol occurrence. More...
 

Typedefs

typedef uint16_t SymbolPropertySet
 
typedef unsigned SymbolRoleSet
 

Enumerations

enum  SymbolKind : uint8_t {
  SymbolKind::Unknown, SymbolKind::Module, SymbolKind::Namespace, SymbolKind::NamespaceAlias,
  SymbolKind::Macro, SymbolKind::Enum, SymbolKind::Struct, SymbolKind::Class,
  SymbolKind::Protocol, SymbolKind::Extension, SymbolKind::Union, SymbolKind::TypeAlias,
  SymbolKind::Function, SymbolKind::Variable, SymbolKind::Field, SymbolKind::EnumConstant,
  SymbolKind::InstanceMethod, SymbolKind::ClassMethod, SymbolKind::StaticMethod, SymbolKind::InstanceProperty,
  SymbolKind::ClassProperty, SymbolKind::StaticProperty, SymbolKind::Constructor, SymbolKind::Destructor,
  SymbolKind::ConversionFunction, SymbolKind::Parameter, SymbolKind::Using, SymbolKind::TemplateTypeParm,
  SymbolKind::TemplateTemplateParm, SymbolKind::NonTypeTemplateParm
}
 
enum  SymbolLanguage : uint8_t { SymbolLanguage::C, SymbolLanguage::ObjC, SymbolLanguage::CXX, SymbolLanguage::Swift }
 
enum  SymbolSubKind : uint8_t {
  SymbolSubKind::None, SymbolSubKind::CXXCopyConstructor, SymbolSubKind::CXXMoveConstructor, SymbolSubKind::AccessorGetter,
  SymbolSubKind::AccessorSetter, SymbolSubKind::UsingTypename, SymbolSubKind::UsingValue, SymbolSubKind::UsingEnum
}
 Language specific sub-kinds. More...
 
enum  SymbolProperty : SymbolPropertySet {
  SymbolProperty::Generic = 1 << 0, SymbolProperty::TemplatePartialSpecialization = 1 << 1, SymbolProperty::TemplateSpecialization = 1 << 2, SymbolProperty::UnitTest = 1 << 3,
  SymbolProperty::IBAnnotated = 1 << 4, SymbolProperty::IBOutletCollection = 1 << 5, SymbolProperty::GKInspectable = 1 << 6, SymbolProperty::Local = 1 << 7,
  SymbolProperty::ProtocolInterface = 1 << 8
}
 Set of properties that provide additional info about a symbol. More...
 
enum  SymbolRole : uint32_t {
  SymbolRole::Declaration = 1 << 0, SymbolRole::Definition = 1 << 1, SymbolRole::Reference = 1 << 2, SymbolRole::Read = 1 << 3,
  SymbolRole::Write = 1 << 4, SymbolRole::Call = 1 << 5, SymbolRole::Dynamic = 1 << 6, SymbolRole::AddressOf = 1 << 7,
  SymbolRole::Implicit = 1 << 8, SymbolRole::Undefinition = 1 << 9, SymbolRole::RelationChildOf = 1 << 10, SymbolRole::RelationBaseOf = 1 << 11,
  SymbolRole::RelationOverrideOf = 1 << 12, SymbolRole::RelationReceivedBy = 1 << 13, SymbolRole::RelationCalledBy = 1 << 14, SymbolRole::RelationExtendedBy = 1 << 15,
  SymbolRole::RelationAccessorOf = 1 << 16, SymbolRole::RelationContainedBy = 1 << 17, SymbolRole::RelationIBTypeOf = 1 << 18, SymbolRole::RelationSpecializationOf = 1 << 19,
  SymbolRole::NameReference = 1 << 20
}
 Set of roles that are attributed to symbol occurrences. More...
 

Functions

std::unique_ptr< ASTConsumercreateIndexingASTConsumer (std::shared_ptr< IndexDataConsumer > DataConsumer, const IndexingOptions &Opts, std::shared_ptr< Preprocessor > PP)
 Creates an ASTConsumer that indexes all symbols (macros and AST decls). More...
 
std::unique_ptr< ASTConsumercreateIndexingASTConsumer (std::shared_ptr< IndexDataConsumer > DataConsumer, const IndexingOptions &Opts, std::shared_ptr< Preprocessor > PP, std::function< bool(const Decl *)> ShouldSkipFunctionBody)
 
std::unique_ptr< FrontendActioncreateIndexingAction (std::shared_ptr< IndexDataConsumer > DataConsumer, const IndexingOptions &Opts)
 Creates a frontend action that indexes all symbols (macros and AST decls). More...
 
void indexASTUnit (ASTUnit &Unit, IndexDataConsumer &DataConsumer, IndexingOptions Opts)
 Recursively indexes all decls in the AST. More...
 
void indexTopLevelDecls (ASTContext &Ctx, Preprocessor &PP, ArrayRef< const Decl * > Decls, IndexDataConsumer &DataConsumer, IndexingOptions Opts)
 Recursively indexes Decls. More...
 
std::unique_ptr< PPCallbacksindexMacrosCallback (IndexDataConsumer &Consumer, IndexingOptions Opts)
 Creates a PPCallbacks that indexes macros and feeds macros to Consumer. More...
 
void indexModuleFile (serialization::ModuleFile &Mod, ASTReader &Reader, IndexDataConsumer &DataConsumer, IndexingOptions Opts)
 Recursively indexes all top-level decls in the module. More...
 
SymbolInfo getSymbolInfo (const Decl *D)
 
SymbolInfo getSymbolInfoForMacro (const MacroInfo &MI)
 
bool isFunctionLocalSymbol (const Decl *D)
 
void applyForEachSymbolRole (SymbolRoleSet Roles, llvm::function_ref< void(SymbolRole)> Fn)
 
bool applyForEachSymbolRoleInterruptible (SymbolRoleSet Roles, llvm::function_ref< bool(SymbolRole)> Fn)
 
void printSymbolRoles (SymbolRoleSet Roles, raw_ostream &OS)
 
bool printSymbolName (const Decl *D, const LangOptions &LO, raw_ostream &OS)
 
StringRef getSymbolKindString (SymbolKind K)
 
StringRef getSymbolSubKindString (SymbolSubKind K)
 
StringRef getSymbolLanguageString (SymbolLanguage K)
 
void applyForEachSymbolProperty (SymbolPropertySet Props, llvm::function_ref< void(SymbolProperty)> Fn)
 
void printSymbolProperties (SymbolPropertySet Props, raw_ostream &OS)
 
static StringRef getUSRSpacePrefix ()
 
bool generateUSRForDecl (const Decl *D, SmallVectorImpl< char > &Buf)
 Generate a USR for a Decl, including the USR prefix. More...
 
void generateUSRForObjCClass (StringRef Cls, raw_ostream &OS, StringRef ExtSymbolDefinedIn="", StringRef CategoryContextExtSymbolDefinedIn="")
 Generate a USR fragment for an Objective-C class. More...
 
void generateUSRForObjCCategory (StringRef Cls, StringRef Cat, raw_ostream &OS, StringRef ClsExtSymbolDefinedIn="", StringRef CatExtSymbolDefinedIn="")
 Generate a USR fragment for an Objective-C class category. More...
 
void generateUSRForObjCIvar (StringRef Ivar, raw_ostream &OS)
 Generate a USR fragment for an Objective-C instance variable. More...
 
void generateUSRForObjCMethod (StringRef Sel, bool IsInstanceMethod, raw_ostream &OS)
 Generate a USR fragment for an Objective-C method. More...
 
void generateUSRForObjCProperty (StringRef Prop, bool isClassProp, raw_ostream &OS)
 Generate a USR fragment for an Objective-C property. More...
 
void generateUSRForObjCProtocol (StringRef Prot, raw_ostream &OS, StringRef ExtSymbolDefinedIn="")
 Generate a USR fragment for an Objective-C protocol. More...
 
void generateUSRForGlobalEnum (StringRef EnumName, raw_ostream &OS, StringRef ExtSymbolDefinedIn="")
 Generate USR fragment for a global (non-nested) enum. More...
 
void generateUSRForEnumConstant (StringRef EnumConstantName, raw_ostream &OS)
 Generate a USR fragment for an enum constant. More...
 
bool generateUSRForMacro (const MacroDefinitionRecord *MD, const SourceManager &SM, SmallVectorImpl< char > &Buf)
 Generate a USR for a macro, including the USR prefix. More...
 
bool generateUSRForMacro (StringRef MacroName, SourceLocation Loc, const SourceManager &SM, SmallVectorImpl< char > &Buf)
 
bool generateUSRForType (QualType T, ASTContext &Ctx, SmallVectorImpl< char > &Buf)
 Generates a USR for a type. More...
 
bool generateFullUSRForModule (const Module *Mod, raw_ostream &OS)
 Generate a USR for a module, including the USR prefix. More...
 
bool generateFullUSRForTopLevelModuleName (StringRef ModName, raw_ostream &OS)
 Generate a USR for a top-level module name, including the USR prefix. More...
 
bool generateUSRFragmentForModule (const Module *Mod, raw_ostream &OS)
 Generate a USR fragment for a module. More...
 
bool generateUSRFragmentForModuleName (StringRef ModName, raw_ostream &OS)
 Generate a USR fragment for a module name. More...
 

Variables

static const unsigned SymbolPropertyBitNum = 9
 
static const unsigned SymbolRoleBitNum = 21
 

Typedef Documentation

◆ SymbolPropertySet

Definition at line 81 of file IndexSymbol.h.

◆ SymbolRoleSet

Definition at line 131 of file IndexSymbol.h.

Enumeration Type Documentation

◆ SymbolKind

enum clang::index::SymbolKind : uint8_t
strong
Enumerator
Unknown 
Module 
Namespace 
NamespaceAlias 
Macro 
Enum 
Struct 
Class 
Protocol 
Extension 
Union 
TypeAlias 
Function 
Variable 
Field 
EnumConstant 
InstanceMethod 
ClassMethod 
StaticMethod 
InstanceProperty 
ClassProperty 
StaticProperty 
Constructor 
Destructor 
ConversionFunction 
Parameter 
Using 
TemplateTypeParm 
TemplateTemplateParm 
NonTypeTemplateParm 

Definition at line 23 of file IndexSymbol.h.

◆ SymbolLanguage

enum clang::index::SymbolLanguage : uint8_t
strong
Enumerator
ObjC 
CXX 
Swift 

Definition at line 62 of file IndexSymbol.h.

◆ SymbolProperty

Set of properties that provide additional info about a symbol.

Enumerator
Generic 
TemplatePartialSpecialization 
TemplateSpecialization 
UnitTest 
IBAnnotated 
IBOutletCollection 
GKInspectable 
Local 
ProtocolInterface 

Symbol is part of a protocol interface.

Definition at line 83 of file IndexSymbol.h.

◆ SymbolRole

enum clang::index::SymbolRole : uint32_t
strong

Set of roles that are attributed to symbol occurrences.

Low 9 bits of clang-c/include/Index.h CXSymbolRole mirrors this enum.

Enumerator
Declaration 
Definition 
Reference 
Read 
Write 
Call 
Dynamic 
AddressOf 
Implicit 
Undefinition 
RelationChildOf 
RelationBaseOf 
RelationOverrideOf 
RelationReceivedBy 
RelationCalledBy 
RelationExtendedBy 
RelationAccessorOf 
RelationContainedBy 
RelationIBTypeOf 
RelationSpecializationOf 
NameReference 

Definition at line 100 of file IndexSymbol.h.

◆ SymbolSubKind

enum clang::index::SymbolSubKind : uint8_t
strong

Language specific sub-kinds.

Enumerator
None 
CXXCopyConstructor 
CXXMoveConstructor 
AccessorGetter 
AccessorSetter 
UsingTypename 
UsingValue 
UsingEnum 

Definition at line 70 of file IndexSymbol.h.

Function Documentation

◆ applyForEachSymbolProperty()

void clang::index::applyForEachSymbolProperty ( SymbolPropertySet  Props,
llvm::function_ref< void(SymbolProperty)>  Fn 
)

◆ applyForEachSymbolRole()

void clang::index::applyForEachSymbolRole ( SymbolRoleSet  Roles,
llvm::function_ref< void(SymbolRole)>  Fn 
)

Definition at line 446 of file IndexSymbol.cpp.

References applyForEachSymbolRoleInterruptible().

Referenced by printSymbolRoles().

◆ applyForEachSymbolRoleInterruptible()

bool clang::index::applyForEachSymbolRoleInterruptible ( SymbolRoleSet  Roles,
llvm::function_ref< bool(SymbolRole)>  Fn 
)

◆ createIndexingAction()

std::unique_ptr< FrontendAction > clang::index::createIndexingAction ( std::shared_ptr< IndexDataConsumer DataConsumer,
const IndexingOptions Opts 
)

Creates a frontend action that indexes all symbols (macros and AST decls).

Definition at line 195 of file IndexingAction.cpp.

◆ createIndexingASTConsumer() [1/2]

std::unique_ptr< ASTConsumer > clang::index::createIndexingASTConsumer ( std::shared_ptr< IndexDataConsumer DataConsumer,
const IndexingOptions Opts,
std::shared_ptr< Preprocessor PP 
)

Creates an ASTConsumer that indexes all symbols (macros and AST decls).

Definition at line 179 of file IndexingAction.cpp.

References bool, and clang::index::IndexingOptions::ShouldTraverseDecl.

◆ createIndexingASTConsumer() [2/2]

std::unique_ptr< ASTConsumer > clang::index::createIndexingASTConsumer ( std::shared_ptr< IndexDataConsumer DataConsumer,
const IndexingOptions Opts,
std::shared_ptr< Preprocessor PP,
std::function< bool(const Decl *)>  ShouldSkipFunctionBody 
)

Definition at line 171 of file IndexingAction.cpp.

◆ generateFullUSRForModule()

bool clang::index::generateFullUSRForModule ( const Module Mod,
raw_ostream &  OS 
)

Generate a USR for a module, including the USR prefix.

Returns
true on error, false on success.

Definition at line 1135 of file USRGeneration.cpp.

References generateFullUSRForTopLevelModuleName(), generateUSRFragmentForModule(), clang::Module::Name, and clang::Module::Parent.

◆ generateFullUSRForTopLevelModuleName()

bool clang::index::generateFullUSRForTopLevelModuleName ( StringRef  ModName,
raw_ostream &  OS 
)

Generate a USR for a top-level module name, including the USR prefix.

Returns
true on error, false on success.

Definition at line 1144 of file USRGeneration.cpp.

References generateUSRFragmentForModuleName(), and getUSRSpacePrefix().

Referenced by generateFullUSRForModule().

◆ generateUSRForDecl()

bool clang::index::generateUSRForDecl ( const Decl D,
SmallVectorImpl< char > &  Buf 
)

Generate a USR for a Decl, including the USR prefix.

Returns
true if the results should be ignored, false otherwise.

Definition at line 1081 of file USRGeneration.cpp.

References Implicit.

Referenced by clang::cross_tu::CrossTranslationUnitContext::getLookupName(), and clang::tooling::getUSRForDecl().

◆ generateUSRForEnumConstant()

void clang::index::generateUSRForEnumConstant ( StringRef  EnumConstantName,
raw_ostream &  OS 
)

Generate a USR fragment for an enum constant.

Definition at line 1076 of file USRGeneration.cpp.

◆ generateUSRForGlobalEnum()

void clang::index::generateUSRForGlobalEnum ( StringRef  EnumName,
raw_ostream &  OS,
StringRef  ExtSymbolDefinedIn = "" 
)

Generate USR fragment for a global (non-nested) enum.

Definition at line 1069 of file USRGeneration.cpp.

◆ generateUSRForMacro() [1/2]

bool clang::index::generateUSRForMacro ( const MacroDefinitionRecord MD,
const SourceManager SM,
SmallVectorImpl< char > &  Buf 
)

Generate a USR for a macro, including the USR prefix.

Returns
true on error, false on success.

Definition at line 1094 of file USRGeneration.cpp.

References clang::MacroDefinitionRecord::getLocation(), clang::MacroDefinitionRecord::getName(), clang::IdentifierInfo::getName(), and SM.

◆ generateUSRForMacro() [2/2]

bool clang::index::generateUSRForMacro ( StringRef  MacroName,
SourceLocation  Loc,
const SourceManager SM,
SmallVectorImpl< char > &  Buf 
)

◆ generateUSRForObjCCategory()

void clang::index::generateUSRForObjCCategory ( StringRef  Cls,
StringRef  Cat,
raw_ostream &  OS,
StringRef  ClsExtSymbolDefinedIn = "",
StringRef  CatExtSymbolDefinedIn = "" 
)

Generate a USR fragment for an Objective-C class category.

Definition at line 1039 of file USRGeneration.cpp.

◆ generateUSRForObjCClass()

void clang::index::generateUSRForObjCClass ( StringRef  Cls,
raw_ostream &  OS,
StringRef  ExtSymbolDefinedIn = "",
StringRef  CategoryContextExtSymbolDefinedIn = "" 
)

Generate a USR fragment for an Objective-C class.

Definition at line 1031 of file USRGeneration.cpp.

◆ generateUSRForObjCIvar()

void clang::index::generateUSRForObjCIvar ( StringRef  Ivar,
raw_ostream &  OS 
)

Generate a USR fragment for an Objective-C instance variable.

The complete USR can be created by concatenating the USR for the encompassing class with this USR fragment.

Definition at line 1047 of file USRGeneration.cpp.

◆ generateUSRForObjCMethod()

void clang::index::generateUSRForObjCMethod ( StringRef  Sel,
bool  IsInstanceMethod,
raw_ostream &  OS 
)

Generate a USR fragment for an Objective-C method.

Definition at line 1051 of file USRGeneration.cpp.

◆ generateUSRForObjCProperty()

void clang::index::generateUSRForObjCProperty ( StringRef  Prop,
bool  isClassProp,
raw_ostream &  OS 
)

Generate a USR fragment for an Objective-C property.

Definition at line 1057 of file USRGeneration.cpp.

◆ generateUSRForObjCProtocol()

void clang::index::generateUSRForObjCProtocol ( StringRef  Prot,
raw_ostream &  OS,
StringRef  ExtSymbolDefinedIn = "" 
)

Generate a USR fragment for an Objective-C protocol.

Definition at line 1062 of file USRGeneration.cpp.

◆ generateUSRForType()

bool clang::index::generateUSRForType ( QualType  T,
ASTContext Ctx,
SmallVectorImpl< char > &  Buf 
)

Generates a USR for a type.

Returns
true on error, false on success.

Definition at line 1124 of file USRGeneration.cpp.

References clang::QualType::getCanonicalType(), and clang::QualType::isNull().

◆ generateUSRFragmentForModule()

bool clang::index::generateUSRFragmentForModule ( const Module Mod,
raw_ostream &  OS 
)

Generate a USR fragment for a module.

Returns
true on error, false on success.

Definition at line 1150 of file USRGeneration.cpp.

References generateUSRFragmentForModuleName(), and clang::Module::Name.

Referenced by generateFullUSRForModule().

◆ generateUSRFragmentForModuleName()

bool clang::index::generateUSRFragmentForModuleName ( StringRef  ModName,
raw_ostream &  OS 
)

Generate a USR fragment for a module name.

Returns
true on error, false on success.

Definition at line 1155 of file USRGeneration.cpp.

Referenced by generateFullUSRForTopLevelModuleName(), and generateUSRFragmentForModule().

◆ getSymbolInfo()

SymbolInfo clang::index::getSymbolInfo ( const Decl D)

◆ getSymbolInfoForMacro()

SymbolInfo clang::index::getSymbolInfoForMacro ( const MacroInfo MI)

◆ getSymbolKindString()

StringRef clang::index::getSymbolKindString ( SymbolKind  K)

Definition at line 505 of file IndexSymbol.cpp.

References clang::prec::Unknown.

◆ getSymbolLanguageString()

StringRef clang::index::getSymbolLanguageString ( SymbolLanguage  K)

Definition at line 556 of file IndexSymbol.cpp.

References AttributeLangSupport::C, and AttributeLangSupport::ObjC.

◆ getSymbolSubKindString()

StringRef clang::index::getSymbolSubKindString ( SymbolSubKind  K)

Definition at line 541 of file IndexSymbol.cpp.

References clang::XRayInstrKind::None.

◆ getUSRSpacePrefix()

static StringRef clang::index::getUSRSpacePrefix ( )
inlinestatic

Definition at line 26 of file USRGeneration.h.

Referenced by generateFullUSRForTopLevelModuleName(), and generateUSRForMacro().

◆ indexASTUnit()

void clang::index::indexASTUnit ( ASTUnit Unit,
IndexDataConsumer DataConsumer,
IndexingOptions  Opts 
)

◆ indexMacrosCallback()

std::unique_ptr< PPCallbacks > clang::index::indexMacrosCallback ( IndexDataConsumer Consumer,
IndexingOptions  Opts 
)

Creates a PPCallbacks that indexes macros and feeds macros to Consumer.

The caller is responsible for calling Consumer.setPreprocessor().

Definition at line 291 of file IndexingAction.cpp.

◆ indexModuleFile()

void clang::index::indexModuleFile ( serialization::ModuleFile Mod,
ASTReader Reader,
IndexDataConsumer DataConsumer,
IndexingOptions  Opts 
)

◆ indexTopLevelDecls()

void clang::index::indexTopLevelDecls ( ASTContext Ctx,
Preprocessor PP,
ArrayRef< const Decl * >  Decls,
IndexDataConsumer DataConsumer,
IndexingOptions  Opts 
)

◆ isFunctionLocalSymbol()

bool clang::index::isFunctionLocalSymbol ( const Decl D)

◆ printSymbolName()

bool clang::index::printSymbolName ( const Decl D,
const LangOptions LO,
raw_ostream &  OS 
)
Returns
true if no name was printed, false otherwise.

Definition at line 487 of file IndexSymbol.cpp.

References clang::DeclarationName::isEmpty(), clang::DeclarationName::print(), and clang::PrintingPolicy::SuppressTemplateArgsInCXXConstructors.

◆ printSymbolProperties()

void clang::index::printSymbolProperties ( SymbolPropertySet  Props,
raw_ostream &  OS 
)

Definition at line 585 of file IndexSymbol.cpp.

References applyForEachSymbolProperty().

◆ printSymbolRoles()

void clang::index::printSymbolRoles ( SymbolRoleSet  Roles,
raw_ostream &  OS 
)

Definition at line 454 of file IndexSymbol.cpp.

References applyForEachSymbolRole(), and Write.

Variable Documentation

◆ SymbolPropertyBitNum

const unsigned clang::index::SymbolPropertyBitNum = 9
static

Definition at line 95 of file IndexSymbol.h.

◆ SymbolRoleBitNum

const unsigned clang::index::SymbolRoleBitNum = 21
static

Definition at line 130 of file IndexSymbol.h.