forked from Imagelibrary/binutils-gdb
libctf: decl, types: revise ctf_decl*, ctf_type_*name
These all need fairly trivial revisions for prefix types. While we're at it, we can add explicit handling of nonrepresentable types, returning CTF_K_UNKNOWN for such types rather than throwing an error, so that type printing prints (nonrepresentable type) for such types as it always intended to.
This commit is contained in:
@@ -853,8 +853,12 @@ ctf_type_aname (ctf_dict_t *fp, ctf_id_t type)
|
||||
cdp != NULL; cdp = ctf_list_next (cdp))
|
||||
{
|
||||
ctf_dict_t *rfp = fp;
|
||||
const ctf_type_t *tp = ctf_lookup_by_id (&rfp, cdp->cd_type);
|
||||
const char *name = ctf_strptr (rfp, tp->ctt_name);
|
||||
const ctf_type_t *tp = NULL;
|
||||
const char *name;
|
||||
|
||||
ctf_lookup_by_id (&rfp, cdp->cd_type, &tp);
|
||||
assert (tp);
|
||||
name = ctf_strptr (rfp, tp->ctt_name);
|
||||
|
||||
if (k != CTF_K_POINTER && k != CTF_K_ARRAY)
|
||||
ctf_decl_sprintf (&cd, " ");
|
||||
@@ -976,6 +980,7 @@ ctf_type_aname (ctf_dict_t *fp, ctf_id_t type)
|
||||
case CTF_K_RESTRICT:
|
||||
ctf_decl_sprintf (&cd, "restrict");
|
||||
break;
|
||||
|
||||
case CTF_K_UNKNOWN:
|
||||
if (name[0] == '\0')
|
||||
ctf_decl_sprintf (&cd, _("(nonrepresentable type)"));
|
||||
@@ -1050,7 +1055,7 @@ ctf_type_name_raw (ctf_dict_t *fp, ctf_id_t type)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if ((tp = ctf_lookup_by_id (&fp, type)) == NULL)
|
||||
if (ctf_lookup_by_id (&fp, type, &tp) == NULL)
|
||||
return NULL; /* errno is set for us. */
|
||||
|
||||
if (tp->ctt_name == 0)
|
||||
|
||||
Reference in New Issue
Block a user