LLVM 20.0.0git
|
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 |
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.
Definition at line 82 of file DWARFLinkerDeclContext.h.
|
inline |
Definition at line 84 of file DWARFLinkerDeclContext.h.
|
inline |
Definition at line 86 of file DWARFLinkerDeclContext.h.
|
inline |
Definition at line 101 of file DWARFLinkerDeclContext.h.
Referenced by llvm::dwarf_linker::classic::CompileUnit::fixupForwardReferences().
|
inline |
Definition at line 93 of file DWARFLinkerDeclContext.h.
Referenced by llvm::dwarf_linker::classic::DeclContextTree::getChildDeclContext().
|
inline |
Definition at line 107 of file DWARFLinkerDeclContext.h.
Referenced by llvm::dwarf_linker::classic::DeclContextTree::getChildDeclContext().
|
inline |
Definition at line 99 of file DWARFLinkerDeclContext.h.
Referenced by llvm::dwarf_linker::classic::CompileUnit::fixupForwardReferences().
|
inline |
Definition at line 104 of file DWARFLinkerDeclContext.h.
|
inline |
Definition at line 102 of file DWARFLinkerDeclContext.h.
References llvm::Offset.
|
inline |
Definition at line 105 of file DWARFLinkerDeclContext.h.
|
inline |
Definition at line 97 of file DWARFLinkerDeclContext.h.
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().