LLVM 24.0.0git
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.
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.
Expected< std::optional< UnitEntryPairTy > > resolveReference (UnitEntryPairTy InputUnitEntryPair, dwarf::Attribute Attr)
 Resolve the DIE that Attr of InputUnitEntryPair refers to.
Error incrementRecursionDepth ()
 Count a referenced DIE toward the recursion limit.
Error addParentName (UnitEntryPairTy &InputUnitEntryPair)
 Add names of parent dies to the built name.
void addDieNameFromDeclFileAndDeclLine (UnitEntryPairTy &InputUnitEntryPair, bool &HasDeclFileName)
Error addUnnamedTypeContents (UnitEntryPairTy InputUnitEntryPair)
 Add a fixed-size digest of the contents of the unnamed type InputUnitEntryPair, so the names of the types referring to it do not grow with its size or nesting depth.
Error addUnqualifiedTypeName (UnitEntryPairTy InputUnitEntryPair)
 Add the type InputUnitEntryPair refers to, without parent scopes.
void addTypePrefix (CompileUnit &CU, 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

TypeKey SyntheticName
 Buffer keeping bult name.
DenseMap< const DWARFDebugInfoEntry *, std::string > ContentsDigests
 Digests of the contents of unnamed types, by DIE.
size_t RecursionDepth = 0
 Recursion counter.
TypePool & TypePoolRef
 Type pool.

Static Protected Attributes

static constexpr size_t MaxRecursionDepth = 1000
 Bounds RecursionDepth, which malformed input can make unbounded.

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 45 of file SyntheticTypeNameBuilder.h.

Constructor & Destructor Documentation

◆ SyntheticTypeNameBuilder()

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

Definition at line 47 of file SyntheticTypeNameBuilder.h.

References TypePoolRef.

Member Function Documentation

◆ addArrayDimension()

◆ 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 243 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, llvm::dwarf::toUnsigned(), and llvm::utohexstr().

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 417 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(), getTypeDeduplicationCandidate(), llvm::dwarf_linker::parallel::CompileUnit::setDieTypeEntry(), llvm::Error::success(), SyntheticName, and TypePoolRef.

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

◆ addOrderedName()

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

Add ordered name to the built name.

Definition at line 162 of file SyntheticTypeNameBuilder.cpp.

References llvm::format_hex_no_prefix(), and SyntheticName.

Referenced by addDIETypeName().

◆ addParamNames()

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

Add specified FunctionParameters to the built name.

Definition at line 114 of file SyntheticTypeNameBuilder.cpp.

References addReferencedODRDies(), 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

Analyze InputUnitEntryPair's ODR attributes and put names of the referenced type dies to the built name.

Definition at line 305 of file SyntheticTypeNameBuilder.cpp.

References addDIETypeName(), incrementRecursionDepth(), RecursionDepth, resolveReference(), llvm::Error::success(), SyntheticName, and llvm::Expected< T >::takeError().

Referenced by addParamNames(), addSignature(), addTemplateParamNames(), and addTypeName().

◆ addSignature()

◆ addTemplateParamNames()

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

Add specified TemplateParameters to the built name.

Definition at line 133 of file SyntheticTypeNameBuilder.cpp.

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

Referenced by addSignature().

◆ addTypeName()

◆ addTypePrefix()

void SyntheticTypeNameBuilder::addTypePrefix ( CompileUnit & CU,
const DWARFDebugInfoEntry * DieEntry )
protected

◆ addUnnamedTypeContents()

◆ addUnqualifiedTypeName()

Error SyntheticTypeNameBuilder::addUnqualifiedTypeName ( UnitEntryPairTy InputUnitEntryPair)
protected

Add the type InputUnitEntryPair refers to, without parent scopes.

A type nested in an unnamed type would need the name being built.

Definition at line 502 of file SyntheticTypeNameBuilder.cpp.

References addArrayDimension(), addTypePrefix(), addUnnamedTypeContents(), addUnqualifiedTypeName(), incrementRecursionDepth(), RecursionDepth, resolveReference(), llvm::Error::success(), SyntheticName, llvm::Expected< T >::takeError(), and llvm::dwarf::toStringRef().

Referenced by addUnnamedTypeContents(), and addUnqualifiedTypeName().

◆ 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 21 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(), RecursionDepth, llvm::Error::success(), and SyntheticName.

◆ incrementRecursionDepth()

Error SyntheticTypeNameBuilder::incrementRecursionDepth ( )
protected

Count a referenced DIE toward the recursion limit.

Callers decrement RecursionDepth once they are done with it.

Definition at line 298 of file SyntheticTypeNameBuilder.cpp.

References llvm::createStringError(), MaxRecursionDepth, RecursionDepth, and llvm::Error::success().

Referenced by addReferencedODRDies(), and addUnqualifiedTypeName().

◆ resolveReference()

Expected< std::optional< UnitEntryPairTy > > SyntheticTypeNameBuilder::resolveReference ( UnitEntryPairTy InputUnitEntryPair,
dwarf::Attribute Attr )
protected

Member Data Documentation

◆ ContentsDigests

DenseMap<const DWARFDebugInfoEntry *, std::string> llvm::dwarf_linker::parallel::SyntheticTypeNameBuilder::ContentsDigests
protected

Digests of the contents of unnamed types, by DIE.

Definition at line 136 of file SyntheticTypeNameBuilder.h.

Referenced by addUnnamedTypeContents().

◆ MaxRecursionDepth

size_t llvm::dwarf_linker::parallel::SyntheticTypeNameBuilder::MaxRecursionDepth = 1000
staticconstexprprotected

Bounds RecursionDepth, which malformed input can make unbounded.

Definition at line 142 of file SyntheticTypeNameBuilder.h.

Referenced by incrementRecursionDepth().

◆ RecursionDepth

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

Recursion counter.

Definition at line 139 of file SyntheticTypeNameBuilder.h.

Referenced by addReferencedODRDies(), addUnqualifiedTypeName(), assignName(), and incrementRecursionDepth().

◆ SyntheticName

◆ TypePoolRef

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

Type pool.

Definition at line 145 of file SyntheticTypeNameBuilder.h.

Referenced by addDIETypeName(), and SyntheticTypeNameBuilder().


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