[PATCH 1/9] c-family: add btf_decl_tag attribute
David Faust
david.faust@oracle.com
Tue Jul 11 21:57:08 GMT 2023
Add the "btf_decl_tag" attribute to the attribute table, along with
a simple handler for it.
gcc/c-family/
* c-attribs.cc (c_common_attribute_table): Add btf_decl_tag.
(handle_btf_decl_tag_attribute): Handle new attribute.
---
gcc/c-family/c-attribs.cc | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/gcc/c-family/c-attribs.cc b/gcc/c-family/c-attribs.cc
index e2792ca6898..0a3de3ea307 100644
--- a/gcc/c-family/c-attribs.cc
+++ b/gcc/c-family/c-attribs.cc
@@ -178,6 +178,8 @@ static tree handle_signed_bool_precision_attribute (tree *, tree, tree, int,
static tree handle_retain_attribute (tree *, tree, tree, int, bool *);
static tree handle_fd_arg_attribute (tree *, tree, tree, int, bool *);
+static tree handle_btf_decl_tag_attribute (tree *, tree, tree, int, bool *);
+
/* Helper to define attribute exclusions. */
#define ATTR_EXCL(name, function, type, variable) \
{ name, function, type, variable }
@@ -569,6 +571,9 @@ const struct attribute_spec c_common_attribute_table[] =
handle_fd_arg_attribute, NULL},
{ "fd_arg_write", 1, 1, false, true, true, false,
handle_fd_arg_attribute, NULL},
+ { "btf_decl_tag", 1, 1, true, false, false, false,
+ handle_btf_decl_tag_attribute, NULL },
+
{ NULL, 0, 0, false, false, false, false, NULL, NULL }
};
@@ -5988,6 +5993,24 @@ handle_tainted_args_attribute (tree *node, tree name, tree, int,
return NULL_TREE;
}
+/* Handle a "btf_decl_tag" attribute; arguments as in
+ struct attribute_spec.handler. */
+
+static tree
+handle_btf_decl_tag_attribute (tree *, tree name, tree args, int,
+ bool *no_add_attrs)
+{
+ if (!args)
+ *no_add_attrs = true;
+ else if (TREE_CODE (TREE_VALUE (args)) != STRING_CST)
+ {
+ error ("%qE attribute requires a string", name);
+ *no_add_attrs = true;
+ }
+
+ return NULL_TREE;
+}
+
/* Attempt to partially validate a single attribute ATTR as if
it were to be applied to an entity OPER. */
--
2.40.1
More information about the Gcc-patches
mailing list