LLVM 20.0.0git
Public Types | Public Member Functions | List of all members
llvm::dwarf_linker::classic::DeclContext Class Reference

A DeclContext is a named program scope that is used for ODR uniquing of types. More...

#include "llvm/DWARFLinker/Classic/DWARFLinkerDeclContext.h"

Public Types

using Map = DenseSet< DeclContext *, DeclMapInfo >
 

Public Member Functions

 DeclContext ()
 
 DeclContext (unsigned Hash, uint32_t Line, uint32_t ByteSize, uint16_t Tag, StringRef Name, StringRef File, const DeclContext &Parent, DWARFDie LastSeenDIE=DWARFDie(), unsigned CUId=0)
 
uint32_t getQualifiedNameHash () const
 
bool setLastSeenDIE (CompileUnit &U, const DWARFDie &Die)
 Set the last DIE/CU a context was seen in and, possibly invalidate the context if it is ambiguous.
 
void setHasCanonicalDIE ()
 
bool hasCanonicalDIE () const
 
uint32_t getCanonicalDIEOffset () const
 
void setCanonicalDIEOffset (uint32_t Offset)
 
bool isDefinedInClangModule () const
 
void setDefinedInClangModule (bool Val)
 
uint16_t getTag () const
 

Detailed Description

A DeclContext is a named program scope that is used for ODR uniquing of types.

The set of DeclContext for the ODR-subject parts of a Dwarf link is expanded (and uniqued) with each new object file processed. We need to determine the context of each DIE in an linked object file to see if the corresponding type has already been emitted.

The contexts are conceptually organized as a tree (eg. a function scope is contained in a namespace scope that contains other scopes), but storing/accessing them in an actual tree is too inefficient: we need to be able to very quickly query a context for a given child context by name. Storing a StringMap in each DeclContext would be too space inefficient.

The solution here is to give each DeclContext a link to its parent (this allows to walk up the tree), but to query the existence of a specific DeclContext using a separate DenseMap keyed on the hash of the fully qualified name of the context.

Definition at line 80 of file DWARFLinkerDeclContext.h.

Member Typedef Documentation

◆ Map

Definition at line 82 of file DWARFLinkerDeclContext.h.

Constructor & Destructor Documentation

◆ DeclContext() [1/2]

llvm::dwarf_linker::classic::DeclContext::DeclContext ( )
inline

Definition at line 84 of file DWARFLinkerDeclContext.h.

◆ DeclContext() [2/2]

llvm::dwarf_linker::classic::DeclContext::DeclContext ( unsigned  Hash,
uint32_t  Line,
uint32_t  ByteSize,
uint16_t  Tag,
StringRef  Name,
StringRef  File,
const DeclContext Parent,
DWARFDie  LastSeenDIE = DWARFDie(),
unsigned  CUId = 0 
)
inline

Definition at line 86 of file DWARFLinkerDeclContext.h.

Member Function Documentation

◆ getCanonicalDIEOffset()

uint32_t llvm::dwarf_linker::classic::DeclContext::getCanonicalDIEOffset ( ) const
inline

◆ getQualifiedNameHash()

uint32_t llvm::dwarf_linker::classic::DeclContext::getQualifiedNameHash ( ) const
inline

◆ getTag()

uint16_t llvm::dwarf_linker::classic::DeclContext::getTag ( ) const
inline

◆ hasCanonicalDIE()

bool llvm::dwarf_linker::classic::DeclContext::hasCanonicalDIE ( ) const
inline

◆ isDefinedInClangModule()

bool llvm::dwarf_linker::classic::DeclContext::isDefinedInClangModule ( ) const
inline

Definition at line 104 of file DWARFLinkerDeclContext.h.

◆ setCanonicalDIEOffset()

void llvm::dwarf_linker::classic::DeclContext::setCanonicalDIEOffset ( uint32_t  Offset)
inline

Definition at line 102 of file DWARFLinkerDeclContext.h.

References llvm::Offset.

◆ setDefinedInClangModule()

void llvm::dwarf_linker::classic::DeclContext::setDefinedInClangModule ( bool  Val)
inline

Definition at line 105 of file DWARFLinkerDeclContext.h.

◆ setHasCanonicalDIE()

void llvm::dwarf_linker::classic::DeclContext::setHasCanonicalDIE ( )
inline

Definition at line 97 of file DWARFLinkerDeclContext.h.

◆ setLastSeenDIE()

bool llvm::DeclContext::setLastSeenDIE ( CompileUnit U,
const DWARFDie Die 
)

Set the last DIE/CU a context was seen in and, possibly invalidate the context if it is ambiguous.

In the current implementation, we don't handle overloaded functions well, because the argument types are not taken into account when computing the DeclContext tree.

Some of this is mitigated byt using mangled names that do contain the arguments types, but sometimes (e.g. with function templates) we don't have that. In that case, just do not unique anything that refers to the contexts we are not able to distinguish.

If a context that is not a namespace appears twice in the same CU, we know it is ambiguous. Make it invalid.

Definition at line 34 of file DWARFLinkerDeclContext.cpp.

References llvm::DWARFUnit::getDIEIndex().


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