LLVM 20.0.0git
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
llvm::dwarf_linker::parallel::SyntheticTypeNameBuilder Class Reference

The helper class to build type name based on DIE properties. More...

#include "DWARFLinker/Parallel/SyntheticTypeNameBuilder.h"

Public Member Functions

 SyntheticTypeNameBuilder (TypePool &TypePoolRef)
 
Error assignName (UnitEntryPairTy InputUnitEntryPair, std::optional< std::pair< size_t, size_t > > ChildIndex)
 Create synthetic name for the specified DIE InputUnitEntryPair and assign created name to the DIE type info.
 

Protected Member Functions

void addArrayDimension (UnitEntryPairTy InputUnitEntryPair)
 Add array type dimension.
 
Error addSignature (UnitEntryPairTy InputUnitEntryPair, bool addTemplateParameters)
 Add signature( entry type plus type of parameters plus type of template parameters(if addTemplateParameters is true).
 
Error addParamNames (CompileUnit &CU, SmallVector< const DWARFDebugInfoEntry *, 20 > &FunctionParameters)
 Add specified FunctionParameters to the built name.
 
Error addTemplateParamNames (CompileUnit &CU, SmallVector< const DWARFDebugInfoEntry *, 10 > &TemplateParameters)
 Add specified TemplateParameters to the built name.
 
void addOrderedName (CompileUnit &CU, const DWARFDebugInfoEntry *DieEntry)
 Add ordered name to the built name.
 
Error addReferencedODRDies (UnitEntryPairTy InputUnitEntryPair, bool AssignNameToTypeDescriptor, ArrayRef< dwarf::Attribute > ODRAttrs)
 Analyze InputUnitEntryPair's ODR attributes and put names of the referenced type dies to the built name.
 
Error addParentName (UnitEntryPairTy &InputUnitEntryPair)
 Add names of parent dies to the built name.
 
void addDieNameFromDeclFileAndDeclLine (UnitEntryPairTy &InputUnitEntryPair, bool &HasDeclFileName)
 
void addTypePrefix (const DWARFDebugInfoEntry *DieEntry)
 Add type prefix to the built name.
 
Error addTypeName (UnitEntryPairTy InputUnitEntryPair, bool AddParentNames)
 Add type name to the built name.
 
Error addDIETypeName (UnitEntryPairTy InputUnitEntryPair, std::optional< std::pair< size_t, size_t > > ChildIndex, bool AssignNameToTypeDescriptor)
 Analyze InputUnitEntryPair for the type name and possibly assign built type name to the DIE's type info.
 
void addOrderedName (std::pair< size_t, size_t > ChildIdx)
 Add ordered name to the built name.
 
void addValueName (UnitEntryPairTy InputUnitEntryPair, dwarf::Attribute Attr)
 Add value name to the built name.
 

Protected Attributes

SmallString< 1000 > SyntheticName
 Buffer keeping bult name.
 
size_t RecursionDepth = 0
 Recursion counter.
 
TypePoolTypePoolRef
 Type pool.
 

Detailed Description

The helper class to build type name based on DIE properties.

It builds synthetic name based on explicit attributes: DW_AT_name, DW_AT_linkage_name or based on implicit attributes(DW_AT_decl*). Names for specific DIEs(like subprograms, template classes...) include additional attributes: subprogram parameters, template parameters, array ranges. Examples of built name:

class A { } : {8}A

namspace llvm { class A { } } : {1}llvm{8}A

template <int> structure B { } : {F}B<{0}int>

void foo ( int p1, float p3 ) : {a}void foo({0}int, {0}int)

int *ptr; : {c}ptr {0}int

int var; : {d}var

These names is used to refer DIEs describing types.

Definition at line 46 of file SyntheticTypeNameBuilder.h.

Constructor & Destructor Documentation

◆ SyntheticTypeNameBuilder()

llvm::dwarf_linker::parallel::SyntheticTypeNameBuilder::SyntheticTypeNameBuilder ( TypePool TypePoolRef)
inline

Definition at line 48 of file SyntheticTypeNameBuilder.h.

Member Function Documentation

◆ addArrayDimension()

void SyntheticTypeNameBuilder::addArrayDimension ( UnitEntryPairTy  InputUnitEntryPair)
protected

◆ addDieNameFromDeclFileAndDeclLine()

void SyntheticTypeNameBuilder::addDieNameFromDeclFileAndDeclLine ( UnitEntryPairTy InputUnitEntryPair,
bool HasDeclFileName 
)
protected
Returns
synthetic name of the specified DieEntry. The name is constructed from the dwarf::DW_AT_decl_file and dwarf::DW_AT_decl_line attributes.

Definition at line 239 of file SyntheticTypeNameBuilder.cpp.

References llvm::dwarf_linker::parallel::UnitEntryPairTy::CU, llvm::dwarf_linker::parallel::UnitEntryPairTy::DieEntry, llvm::dwarf_linker::parallel::CompileUnit::find(), llvm::dwarf_linker::parallel::CompileUnit::getDirAndFilenameFromLineTable(), SyntheticName, and llvm::dwarf::toUnsigned().

Referenced by addTypeName().

◆ addDIETypeName()

Error SyntheticTypeNameBuilder::addDIETypeName ( UnitEntryPairTy  InputUnitEntryPair,
std::optional< std::pair< size_t, size_t > >  ChildIndex,
bool  AssignNameToTypeDescriptor 
)
protected

Analyze InputUnitEntryPair for the type name and possibly assign built type name to the DIE's type info.

NOTE: while analyzing types we may create different kind of names for the same type depending on whether the type is part of another type. f.e. DW_TAG_formal_parameter would receive "{02}01" name when examined alone. Or "{0}int" name when it is a part of a function name: {a}void foo({0}int). The AssignNameToTypeDescriptor tells whether the type name is part of another type name and then should not be assigned to DIE type descriptor.

Definition at line 393 of file SyntheticTypeNameBuilder.cpp.

References addOrderedName(), addParentName(), addTypeName(), addTypePrefix(), llvm::dwarf_linker::parallel::UnitEntryPairTy::CU, llvm::dwarf_linker::parallel::UnitEntryPairTy::DieEntry, llvm::dwarf_linker::parallel::CompileUnit::getDieTypeEntry(), llvm::StringMapEntry< ValueTy >::getKey(), getTypeDeduplicationCandidate(), llvm::dwarf_linker::parallel::TypePool::insert(), llvm::dwarf_linker::parallel::CompileUnit::setDieTypeEntry(), llvm::SmallVectorBase< Size_T >::size(), llvm::SmallString< InternalLen >::substr(), llvm::Error::success(), SyntheticName, and TypePoolRef.

Referenced by addParentName(), addReferencedODRDies(), and assignName().

◆ addOrderedName() [1/2]

void llvm::dwarf_linker::parallel::SyntheticTypeNameBuilder::addOrderedName ( CompileUnit CU,
const DWARFDebugInfoEntry DieEntry 
)
protected

Add ordered name to the built name.

Referenced by addDIETypeName().

◆ addOrderedName() [2/2]

void SyntheticTypeNameBuilder::addOrderedName ( std::pair< size_t, size_t >  ChildIdx)
protected

Add ordered name to the built name.

Definition at line 158 of file SyntheticTypeNameBuilder.cpp.

References llvm::format_hex_no_prefix(), Name, and SyntheticName.

◆ addParamNames()

Error SyntheticTypeNameBuilder::addParamNames ( CompileUnit CU,
SmallVector< const DWARFDebugInfoEntry *, 20 > &  FunctionParameters 
)
protected

Add specified FunctionParameters to the built name.

Definition at line 112 of file SyntheticTypeNameBuilder.cpp.

References addReferencedODRDies(), llvm::SmallVectorTemplateCommon< T, typename >::back(), llvm::Error::success(), SyntheticName, llvm::dwarf::toUnsigned(), and TypeAttr.

Referenced by addSignature().

◆ addParentName()

Error SyntheticTypeNameBuilder::addParentName ( UnitEntryPairTy InputUnitEntryPair)
protected

◆ addReferencedODRDies()

Error SyntheticTypeNameBuilder::addReferencedODRDies ( UnitEntryPairTy  InputUnitEntryPair,
bool  AssignNameToTypeDescriptor,
ArrayRef< dwarf::Attribute ODRAttrs 
)
protected

◆ addSignature()

Error SyntheticTypeNameBuilder::addSignature ( UnitEntryPairTy  InputUnitEntryPair,
bool  addTemplateParameters 
)
protected

◆ addTemplateParamNames()

Error SyntheticTypeNameBuilder::addTemplateParamNames ( CompileUnit CU,
SmallVector< const DWARFDebugInfoEntry *, 10 > &  TemplateParameters 
)
protected

◆ addTypeName()

Error SyntheticTypeNameBuilder::addTypeName ( UnitEntryPairTy  InputUnitEntryPair,
bool  AddParentNames 
)
protected

◆ addTypePrefix()

void SyntheticTypeNameBuilder::addTypePrefix ( const DWARFDebugInfoEntry DieEntry)
protected

Add type prefix to the built name.

Definition at line 432 of file SyntheticTypeNameBuilder.cpp.

References llvm::DWARFDebugInfoEntry::getTag(), llvm_unreachable, and SyntheticName.

Referenced by addDIETypeName().

◆ addValueName()

void SyntheticTypeNameBuilder::addValueName ( UnitEntryPairTy  InputUnitEntryPair,
dwarf::Attribute  Attr 
)
protected

◆ assignName()

Error SyntheticTypeNameBuilder::assignName ( UnitEntryPairTy  InputUnitEntryPair,
std::optional< std::pair< size_t, size_t > >  ChildIndex 
)

Create synthetic name for the specified DIE InputUnitEntryPair and assign created name to the DIE type info.

ChildIndex is used to create name for ordered DIEs(function arguments f.e.).

Definition at line 19 of file SyntheticTypeNameBuilder.cpp.

References addDIETypeName(), assert(), llvm::dwarf_linker::parallel::UnitEntryPairTy::CU, llvm::dwarf_linker::parallel::UnitEntryPairTy::DieEntry, llvm::dwarf_linker::parallel::CompileUnit::getDIEInfo(), llvm::dwarf_linker::parallel::CompileUnit::getDieTypeEntry(), Info, RecursionDepth, llvm::SmallVectorImpl< T >::resize(), llvm::Error::success(), and SyntheticName.

Member Data Documentation

◆ RecursionDepth

size_t llvm::dwarf_linker::parallel::SyntheticTypeNameBuilder::RecursionDepth = 0
protected

Recursion counter.

Definition at line 122 of file SyntheticTypeNameBuilder.h.

Referenced by addReferencedODRDies(), and assignName().

◆ SyntheticName

SmallString<1000> llvm::dwarf_linker::parallel::SyntheticTypeNameBuilder::SyntheticName
protected

◆ TypePoolRef

TypePool& llvm::dwarf_linker::parallel::SyntheticTypeNameBuilder::TypePoolRef
protected

Type pool.

Definition at line 125 of file SyntheticTypeNameBuilder.h.

Referenced by addDIETypeName().


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