tag: Introduce tag__is_pointer()
For the usual idiom to ask if a tag is a pointer, removing a bit of DWARFism and shortening the operation. Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
parent
89ce57a02e
commit
45ad545944
|
@ -520,8 +520,7 @@ static struct tag *pointer_filter(struct tag *tag, struct cu *cu,
|
|||
struct tag *ctype = cu__type(cu, pos->tag.type);
|
||||
|
||||
tag__assert_search_result(ctype);
|
||||
if (ctype->tag == DW_TAG_pointer_type &&
|
||||
ctype->type == target_type_id)
|
||||
if (tag__is_pointer(ctype) && ctype->type == target_type_id)
|
||||
return tag;
|
||||
}
|
||||
|
||||
|
@ -712,8 +711,7 @@ static int function__emit_probes(struct function *func, uint32_t function_id,
|
|||
struct tag *type = cu__type(cu, pos->tag.type);
|
||||
|
||||
tag__assert_search_result(type);
|
||||
if (type->tag != DW_TAG_pointer_type ||
|
||||
type->type != target_type_id)
|
||||
if (!tag__is_pointer(type) || type->type != target_type_id)
|
||||
continue;
|
||||
|
||||
if (member != NULL)
|
||||
|
@ -789,7 +787,7 @@ static int cu_emit_pointer_probes_iterator(struct cu *cu, void *cookie)
|
|||
struct tag *ctype = cu__type(cu, pos_member->tag.type);
|
||||
|
||||
tag__assert_search_result(ctype);
|
||||
if (ctype->tag == DW_TAG_pointer_type && ctype->type == target_type_id)
|
||||
if (tag__is_pointer(ctype) && ctype->type == target_type_id)
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -1121,7 +1121,7 @@ int ftype__has_parm_of_type(const struct ftype *ftype, const type_id_t target,
|
|||
ftype__for_each_parameter(ftype, pos) {
|
||||
struct tag *type = cu__type(cu, pos->tag.type);
|
||||
|
||||
if (type != NULL && type->tag == DW_TAG_pointer_type) {
|
||||
if (type != NULL && tag__is_pointer(type)) {
|
||||
if (type->type == target)
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -403,6 +403,11 @@ static inline int tag__is_const(const struct tag *tag)
|
|||
return tag->tag == DW_TAG_const_type;
|
||||
}
|
||||
|
||||
static inline int tag__is_pointer(const struct tag *tag)
|
||||
{
|
||||
return tag->tag == DW_TAG_pointer_type;
|
||||
}
|
||||
|
||||
static inline bool tag__is_variable(const struct tag *tag)
|
||||
{
|
||||
return tag->tag == DW_TAG_variable;
|
||||
|
|
|
@ -575,7 +575,7 @@ static size_t type__fprintf(struct tag *type, const struct cu *cu,
|
|||
if (conf->expand_pointers) {
|
||||
int nr_indirections = 0;
|
||||
|
||||
while (type->tag == DW_TAG_pointer_type && type->type != 0) {
|
||||
while (tag__is_pointer(type) && type->type != 0) {
|
||||
struct tag *ttype = cu__type(cu, type->type);
|
||||
if (ttype == NULL)
|
||||
goto out_type_not_found;
|
||||
|
@ -956,7 +956,7 @@ size_t ftype__fprintf_parms(const struct ftype *ftype,
|
|||
stype = sbf;
|
||||
goto print_it;
|
||||
}
|
||||
if (type->tag == DW_TAG_pointer_type) {
|
||||
if (tag__is_pointer(type)) {
|
||||
if (type->type != 0) {
|
||||
int n;
|
||||
struct tag *ptype = cu__type(cu, type->type);
|
||||
|
|
4
pahole.c
4
pahole.c
|
@ -625,7 +625,7 @@ static void cu__account_nr_methods(struct cu *cu)
|
|||
list_for_each_entry(pos, &pos_function->proto.parms, tag.node) {
|
||||
struct tag *type = cu__type(cu, pos->tag.type);
|
||||
|
||||
if (type == NULL || type->tag != DW_TAG_pointer_type)
|
||||
if (type == NULL || !tag__is_pointer(type))
|
||||
continue;
|
||||
|
||||
type = cu__type(cu, type->type);
|
||||
|
@ -676,7 +676,7 @@ static void print_structs_with_pointer_to(const struct cu *cu, uint32_t type)
|
|||
struct tag *ctype = cu__type(cu, pos_member->tag.type);
|
||||
|
||||
tag__assert_search_result(ctype);
|
||||
if (ctype->tag != DW_TAG_pointer_type || ctype->type != type)
|
||||
if (!tag__is_pointer(ctype) || ctype->type != type)
|
||||
continue;
|
||||
|
||||
if (!looked) {
|
||||
|
|
|
@ -32,7 +32,7 @@ static void emit_tag(struct tag *tag, uint32_t tag_id, struct cu *cu)
|
|||
printf("anonymous base_type\n");
|
||||
else
|
||||
puts(name);
|
||||
} else if (tag->tag == DW_TAG_pointer_type)
|
||||
} else if (tag__is_pointer(tag))
|
||||
printf(" /* pointer to %lld */\n", (unsigned long long)tag->type);
|
||||
else
|
||||
tag__fprintf(tag, cu, &conf, stdout);
|
||||
|
|
2
pfunct.c
2
pfunct.c
|
@ -335,7 +335,7 @@ static int function__emit_type_definitions(struct function *func,
|
|||
if (type == NULL)
|
||||
continue;
|
||||
|
||||
if (type->tag == DW_TAG_pointer_type || tag__is_modifier(type)) {
|
||||
if (tag__is_pointer(type) || tag__is_modifier(type)) {
|
||||
type = cu__type(cu, type->type);
|
||||
goto try_again;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue