Skip to contentSkip to conversation

add helpers is_struct_type() & is_union_type()

PATCH New Luc Van Oostenryck 1 participant 1 message Oct 7, 2020 Sparse checker

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 add helpers is_struct_type() & is_union_type()

From: Ilya Maximets <[email protected]>

---
 symbol.h | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
symbol.h +14 -0
index e1f5392600ef..e75ea3abfcd3 100644
@@ -425,6 +425,20 @@ static inline int is_array_type(struct symbol *type)
 	return type->type == SYM_ARRAY;
 }
 
+static inline int is_struct_type(struct symbol *type)
+{
+	if (type->type == SYM_NODE)
+		type = type->ctype.base_type;
+	return type->type == SYM_STRUCT;
+}
+
+static inline int is_union_type(struct symbol *type)
+{
+	if (type->type == SYM_NODE)
+		type = type->ctype.base_type;
+	return type->type == SYM_UNION;
+}
+
 static inline int is_float_type(struct symbol *type)
 {
 	if (type->type == SYM_NODE)
Signature · 1 line
2.28.0