clang 19.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 class  SymbolKind : uint8_t {
  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 , Concept
}
 
enum class  SymbolLanguage : uint8_t { C , ObjC , CXX , Swift }
 
enum class  SymbolSubKind : uint8_t {
  None , CXXCopyConstructor , CXXMoveConstructor , AccessorGetter ,
  AccessorSetter , UsingTypename , UsingValue , UsingEnum
}
 Language specific sub-kinds. More...
 
enum class  SymbolProperty : SymbolPropertySet {
  Generic = 1 << 0 , TemplatePartialSpecialization = 1 << 1 , TemplateSpecialization = 1 << 2 , UnitTest = 1 << 3 ,
  IBAnnotated = 1 << 4 , IBOutletCollection = 1 << 5 , GKInspectable = 1 << 6 , Local = 1 << 7 ,
  ProtocolInterface = 1 << 8
}
 Set of properties that provide additional info about a symbol. More...
 
enum class  SymbolRole : uint32_t {
  Declaration = 1 << 0 , Definition = 1 << 1 , Reference = 1 << 2 , Read = 1 << 3 ,
  Write = 1 << 4 , Call = 1 << 5 , Dynamic = 1 << 6 , AddressOf = 1 << 7 ,
  Implicit = 1 << 8 , Undefinition = 1 << 9 , RelationChildOf = 1 << 10 , RelationBaseOf = 1 << 11 ,
  RelationOverrideOf = 1 << 12 , RelationReceivedBy = 1 << 13 , RelationCalledBy = 1 << 14 , RelationExtendedBy = 1 << 15 ,
  RelationAccessorOf = 1 << 16 , RelationContainedBy = 1 << 17 , RelationIBTypeOf = 1 << 18 , RelationSpecializationOf = 1 << 19 ,
  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).
 
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).
 
void indexASTUnit (ASTUnit &Unit, IndexDataConsumer &DataConsumer, IndexingOptions Opts)
 Recursively indexes all decls in the AST.
 
void indexTopLevelDecls (ASTContext &Ctx, Preprocessor &PP, ArrayRef< const Decl * > Decls, IndexDataConsumer &DataConsumer, IndexingOptions Opts)
 Recursively indexes Decls.
 
std::unique_ptr< PPCallbacksindexMacrosCallback (IndexDataConsumer &Consumer, IndexingOptions Opts)
 Creates a PPCallbacks that indexes macros and feeds macros to Consumer.
 
void indexModuleFile (serialization::ModuleFile &Mod, ASTReader &Reader, IndexDataConsumer &DataConsumer, IndexingOptions Opts)
 Recursively indexes all top-level decls in the module.
 
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.
 
void generateUSRForObjCClass (StringRef Cls, raw_ostream &OS, StringRef ExtSymbolDefinedIn="", StringRef CategoryContextExtSymbolDefinedIn="")
 Generate a USR fragment for an Objective-C class.
 
void generateUSRForObjCCategory (StringRef Cls, StringRef Cat, raw_ostream &OS, StringRef ClsExtSymbolDefinedIn="", StringRef CatExtSymbolDefinedIn="")
 Generate a USR fragment for an Objective-C class category.
 
void generateUSRForObjCIvar (StringRef Ivar, raw_ostream &OS)
 Generate a USR fragment for an Objective-C instance variable.
 
void generateUSRForObjCMethod (StringRef Sel, bool IsInstanceMethod, raw_ostream &OS)
 Generate a USR fragment for an Objective-C method.
 
void generateUSRForObjCProperty (StringRef Prop, bool isClassProp, raw_ostream &OS)
 Generate a USR fragment for an Objective-C property.
 
void generateUSRForObjCProtocol (StringRef Prot, raw_ostream &OS, StringRef ExtSymbolDefinedIn="")
 Generate a USR fragment for an Objective-C protocol.
 
void generateUSRForGlobalEnum (StringRef EnumName, raw_ostream &OS, StringRef ExtSymbolDefinedIn="")
 Generate USR fragment for a global (non-nested) enum.
 
void generateUSRForEnumConstant (StringRef EnumConstantName, raw_ostream &OS)
 Generate a USR fragment for an enum constant.
 
bool generateUSRForMacro (const MacroDefinitionRecord *MD, const SourceManager &SM, SmallVectorImpl< char > &Buf)
 Generate a USR for a macro, including the USR prefix.
 
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.
 
bool generateFullUSRForModule (const Module *Mod, raw_ostream &OS)
 Generate a USR for a module, including the USR prefix.
 
bool generateFullUSRForTopLevelModuleName (StringRef ModName, raw_ostream &OS)
 Generate a USR for a top-level module name, including the USR prefix.
 
bool generateUSRFragmentForModule (const Module *Mod, raw_ostream &OS)
 Generate a USR fragment for a module.
 
bool generateUSRFragmentForModuleName (StringRef ModName, raw_ostream &OS)
 Generate a USR fragment for a module name.
 

Variables

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

Typedef Documentation

◆ SymbolPropertySet

Definition at line 83 of file IndexSymbol.h.

◆ SymbolRoleSet

Definition at line 133 of file IndexSymbol.h.

Enumeration Type Documentation

◆ SymbolKind

enum class 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 
Concept 

Definition at line 23 of file IndexSymbol.h.

◆ SymbolLanguage

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

Definition at line 64 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 85 of file IndexSymbol.h.

◆ SymbolRole

enum class 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 102 of file IndexSymbol.h.

◆ SymbolSubKind

enum class clang::index::SymbolSubKind : uint8_t
strong

Language specific sub-kinds.

Enumerator
None 
CXXCopyConstructor 
CXXMoveConstructor 
AccessorGetter 
AccessorSetter 
UsingTypename 
UsingValue 
UsingEnum 

Definition at line 72 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 449 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, createIndexingASTConsumer(), and clang::index::IndexingOptions::ShouldTraverseDecl.

Referenced by createIndexingASTConsumer().

◆ 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 1231 of file USRGeneration.cpp.

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

Referenced by generateFullUSRForModule().

◆ 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 1240 of file USRGeneration.cpp.

References generateUSRFragmentForModuleName(), and getUSRSpacePrefix().

Referenced by generateFullUSRForModule().

◆ generateUSRForDecl()

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

◆ generateUSRForEnumConstant()

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

Generate a USR fragment for an enum constant.

Definition at line 1163 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 1156 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 1190 of file USRGeneration.cpp.

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

Referenced by generateUSRForMacro(), and clang::extractapi::APISet::recordUSRForMacro().

◆ 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 1126 of file USRGeneration.cpp.

References combineClassAndCategoryExtContainers().

◆ 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 1118 of file USRGeneration.cpp.

References combineClassAndCategoryExtContainers().

◆ 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 1134 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 1138 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 1144 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 1149 of file USRGeneration.cpp.

◆ generateUSRForType()

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

◆ 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 1246 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 1251 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 508 of file IndexSymbol.cpp.

◆ getSymbolLanguageString()

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

Definition at line 560 of file IndexSymbol.cpp.

◆ getSymbolSubKindString()

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

Definition at line 546 of file IndexSymbol.cpp.

◆ 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 490 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 589 of file IndexSymbol.cpp.

References applyForEachSymbolProperty().

◆ printSymbolRoles()

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

Definition at line 457 of file IndexSymbol.cpp.

References applyForEachSymbolRole().

Variable Documentation

◆ SymbolPropertyBitNum

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

Definition at line 97 of file IndexSymbol.h.

◆ SymbolRoleBitNum

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

Definition at line 132 of file IndexSymbol.h.