Add support for references in MM::ref_name

Add an AO_DEREFERENCE ADDRESS_NODE to R->address_path and dereference the
address for REF2->address
This commit is contained in:
Derek Bankieris 2021-02-10 16:06:07 -06:00
parent 8e3726eb98
commit c428bce49d
2 changed files with 17 additions and 0 deletions

View File

@ -63,6 +63,14 @@ bool PrintFileContentsBase::isPrintable( ClassValues * c , FieldDescription * fd
if ( fdes->isSTL() and fdes->getNumDims() ) {
return false;
}
/**
* It is not possible to take the address of a reference as the referred-to variable's address
* is always returned. As such, the init_attr function cannot obtain the absolute address for
* static reference variables.
*/
if ( fdes->isStatic() && fdes->isReference() ) {
return false;
}
if ( fdes->getAccess() == clang::AS_public || (!fdes->isStatic() && !global_compat15 && !c->isCompat15())) {
return true;
}

View File

@ -99,6 +99,15 @@ int Trick::MemoryManager::ref_name(REF2 * R, char *name) {
}
}
if (attr->mods & 1) {
ADDRESS_NODE * address_node = new ADDRESS_NODE ;
address_node->operator_ = AO_DEREFERENCE ;
address_node->operand.address = NULL ;
DLL_AddTail(address_node , R->address_path) ;
addr = *(char**)addr;
}
/* Save the address and next attributes in the REF structure.
If the attributes are dynamically-allocated, reference attributes
then free them so we don't leak memory.