|
LLVM 24.0.0git
|
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. | |
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.
|
inline |
Definition at line 47 of file SyntheticTypeNameBuilder.h.
References TypePoolRef.
|
protected |
Add array type dimension.
Definition at line 38 of file SyntheticTypeNameBuilder.cpp.
References llvm::dwarf_linker::parallel::UnitEntryPairTy::CU, llvm::dwarf_linker::parallel::UnitEntryPairTy::DieEntry, llvm::dwarf_linker::parallel::CompileUnit::find(), llvm::DWARFDebugInfoEntry::getAbbreviationDeclarationPtr(), llvm::dwarf_linker::parallel::CompileUnit::getFirstChildEntry(), llvm::dwarf_linker::parallel::CompileUnit::getSiblingEntry(), and SyntheticName.
Referenced by addTypeName(), and addUnqualifiedTypeName().
|
protected |
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().
|
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().
|
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().
|
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().
|
protected |
Add names of parent dies to the built name.
Definition at line 198 of file SyntheticTypeNameBuilder.cpp.
References addDIETypeName(), llvm::dwarf_linker::parallel::UnitEntryPairTy::getParent(), getTypeDeduplicationCandidate(), llvm::reverse(), llvm::Error::success(), and SyntheticName.
Referenced by addDIETypeName().
|
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().
|
protected |
Add signature( entry type plus type of parameters plus type of template parameters(if addTemplateParameters is true).
Definition at line 64 of file SyntheticTypeNameBuilder.cpp.
References addParamNames(), addReferencedODRDies(), addTemplateParamNames(), llvm::dwarf_linker::parallel::UnitEntryPairTy::CU, llvm::dwarf_linker::parallel::UnitEntryPairTy::DieEntry, llvm::DWARFDebugInfoEntry::getAbbreviationDeclarationPtr(), llvm::dwarf_linker::parallel::CompileUnit::getFirstChildEntry(), llvm::dwarf_linker::parallel::CompileUnit::getSiblingEntry(), llvm::SmallVectorTemplateBase< T, bool >::push_back(), llvm::Error::success(), SyntheticName, and TypeAttr.
Referenced by addTypeName().
|
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().
|
protected |
Add type name to the built name.
Definition at line 332 of file SyntheticTypeNameBuilder.cpp.
References addArrayDimension(), addDieNameFromDeclFileAndDeclLine(), addReferencedODRDies(), addSignature(), addUnnamedTypeContents(), addValueName(), llvm::dwarf_linker::parallel::UnitEntryPairTy::CU, llvm::dwarf_linker::parallel::UnitEntryPairTy::DieEntry, llvm::dwarf_linker::parallel::CompileUnit::find(), llvm::dwarf_linker::parallel::getODRAttributes(), llvm::DWARFDebugInfoEntry::getTag(), llvm::Error::success(), SyntheticName, and llvm::dwarf::toStringRef().
Referenced by addDIETypeName().
|
protected |
Add type prefix to the built name.
Definition at line 533 of file SyntheticTypeNameBuilder.cpp.
References llvm::DWARFDebugInfoEntry::getTag(), llvm::dwarf_linker::isStaticDataMember(), llvm_unreachable, SyntheticName, and llvm::utohexstr().
Referenced by addDIETypeName(), addUnnamedTypeContents(), and addUnqualifiedTypeName().
|
protected |
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.
Definition at line 458 of file SyntheticTypeNameBuilder.cpp.
References addTypePrefix(), addUnqualifiedTypeName(), llvm::arrayRefFromStringRef(), ContentsDigests, llvm::dwarf_linker::parallel::UnitEntryPairTy::CU, llvm::dwarf_linker::parallel::UnitEntryPairTy::DieEntry, llvm::DWARFDebugInfoEntry::getTag(), llvm::XXH128_hash_t::high64, llvm::dwarf_linker::isIdentifiedByChildren(), llvm::dwarf_linker::isIdentifyingChild(), llvm::XXH128_hash_t::low64, llvm::Error::success(), SyntheticName, llvm::dwarf::toStringRef(), llvm::utohexstr(), and llvm::xxh3_128bits().
Referenced by addTypeName(), and addUnqualifiedTypeName().
|
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().
|
protected |
Add value name to the built name.
Definition at line 267 of file SyntheticTypeNameBuilder.cpp.
References llvm::dwarf_linker::parallel::UnitEntryPairTy::CU, llvm::dwarf_linker::parallel::UnitEntryPairTy::DieEntry, llvm::dwarf_linker::parallel::CompileUnit::find(), and SyntheticName.
Referenced by addTypeName().
| 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.
|
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().
|
protected |
Resolve the DIE that Attr of InputUnitEntryPair refers to.
Definition at line 282 of file SyntheticTypeNameBuilder.cpp.
References llvm::createStringError(), llvm::dwarf_linker::parallel::UnitEntryPairTy::CU, llvm::dwarf_linker::parallel::UnitEntryPairTy::DieEntry, llvm::dwarf_linker::parallel::CompileUnit::find(), llvm::dwarf_linker::parallel::Resolve, and llvm::dwarf_linker::parallel::CompileUnit::resolveDIEReference().
Referenced by addReferencedODRDies(), and addUnqualifiedTypeName().
|
protected |
Digests of the contents of unnamed types, by DIE.
Definition at line 136 of file SyntheticTypeNameBuilder.h.
Referenced by addUnnamedTypeContents().
|
staticconstexprprotected |
Bounds RecursionDepth, which malformed input can make unbounded.
Definition at line 142 of file SyntheticTypeNameBuilder.h.
Referenced by incrementRecursionDepth().
|
protected |
Recursion counter.
Definition at line 139 of file SyntheticTypeNameBuilder.h.
Referenced by addReferencedODRDies(), addUnqualifiedTypeName(), assignName(), and incrementRecursionDepth().
|
protected |
Buffer keeping bult name.
Definition at line 133 of file SyntheticTypeNameBuilder.h.
Referenced by addArrayDimension(), addDieNameFromDeclFileAndDeclLine(), addDIETypeName(), addOrderedName(), addParamNames(), addParentName(), addReferencedODRDies(), addSignature(), addTemplateParamNames(), addTypeName(), addTypePrefix(), addUnnamedTypeContents(), addUnqualifiedTypeName(), addValueName(), and assignName().
|
protected |
Type pool.
Definition at line 145 of file SyntheticTypeNameBuilder.h.
Referenced by addDIETypeName(), and SyntheticTypeNameBuilder().