[PATCH] D110127: [Clang] Support typedef with btf_decl_tag attributes
Yonghong Song via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sun Oct 17 20:32:38 PDT 2021
yonghong-song updated this revision to Diff 380275.
yonghong-song retitled this revision from "[Clang] Support typedef with btf_tag attributes" to "[Clang] Support typedef with btf_decl_tag attributes".
yonghong-song edited the summary of this revision.
yonghong-song added a comment.
- rebase based on new btf_decl_tag (https://reviews.llvm.org/D111588)
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D110127/new/
https://reviews.llvm.org/D110127
Files:
clang/include/clang/Basic/Attr.td
clang/include/clang/Basic/AttrDocs.td
clang/test/Misc/pragma-attribute-supported-attributes-list.test
clang/test/Sema/attr-btf_tag.c
Index: clang/test/Sema/attr-btf_tag.c
===================================================================
--- clang/test/Sema/attr-btf_tag.c
+++ clang/test/Sema/attr-btf_tag.c
@@ -25,18 +25,26 @@
enum e1 {
E1
-} __tag1; // expected-error {{'btf_decl_tag' attribute only applies to variables, functions, structs, unions, classes, and non-static data members}}
+} __tag1; // expected-error {{'btf_decl_tag' attribute only applies to variables, functions, structs, unions, classes, non-static data members, and typedefs}}
enum e2 {
E2
-} __tag_no_arg; // expected-error {{'btf_decl_tag' attribute only applies to variables, functions, structs, unions, classes, and non-static data members}}
+} __tag_no_arg; // expected-error {{'btf_decl_tag' attribute only applies to variables, functions, structs, unions, classes, non-static data members, and typedefs}}
enum e3 {
E3
-} __tag_2_arg; // expected-error {{'btf_decl_tag' attribute only applies to variables, functions, structs, unions, classes, and non-static data members}}
+} __tag_2_arg; // expected-error {{'btf_decl_tag' attribute only applies to variables, functions, structs, unions, classes, non-static data members, and typedefs}}
int __tag1 __tag2 foo(struct t1 *arg, struct t2 *arg2);
int __tag2 __tag3 foo(struct t1 *arg, struct t2 *arg2);
int __tag1 foo(struct t1 *arg __tag1, struct t2 *arg2) {
return arg->a + arg2->a;
}
+
+typedef unsigned * __u1 __tag1 __tag2;
+typedef struct {
+ int a;
+} __t2 __tag1 __tag2;
+int convert2(__t2 *arg) {
+ return arg->a;
+}
Index: clang/test/Misc/pragma-attribute-supported-attributes-list.test
===================================================================
--- clang/test/Misc/pragma-attribute-supported-attributes-list.test
+++ clang/test/Misc/pragma-attribute-supported-attributes-list.test
@@ -22,7 +22,7 @@
// CHECK-NEXT: Assumption (SubjectMatchRule_function, SubjectMatchRule_objc_method)
// CHECK-NEXT: Availability ((SubjectMatchRule_record, SubjectMatchRule_enum, SubjectMatchRule_enum_constant, SubjectMatchRule_field, SubjectMatchRule_function, SubjectMatchRule_namespace, SubjectMatchRule_objc_category, SubjectMatchRule_objc_implementation, SubjectMatchRule_objc_interface, SubjectMatchRule_objc_method, SubjectMatchRule_objc_property, SubjectMatchRule_objc_protocol, SubjectMatchRule_record, SubjectMatchRule_type_alias, SubjectMatchRule_variable))
// CHECK-NEXT: BPFPreserveAccessIndex (SubjectMatchRule_record)
-// CHECK-NEXT: BTFDeclTag (SubjectMatchRule_variable, SubjectMatchRule_function, SubjectMatchRule_record, SubjectMatchRule_field)
+// CHECK-NEXT: BTFDeclTag (SubjectMatchRule_variable, SubjectMatchRule_function, SubjectMatchRule_record, SubjectMatchRule_field, SubjectMatchRule_type_alias)
// CHECK-NEXT: BuiltinAlias (SubjectMatchRule_function)
// CHECK-NEXT: CFAuditedTransfer (SubjectMatchRule_function)
// CHECK-NEXT: CFConsumed (SubjectMatchRule_variable_is_parameter)
Index: clang/include/clang/Basic/AttrDocs.td
===================================================================
--- clang/include/clang/Basic/AttrDocs.td
+++ clang/include/clang/Basic/AttrDocs.td
@@ -2016,9 +2016,10 @@
let Content = [{
Clang supports the ``__attribute__((btf_decl_tag("ARGUMENT")))`` attribute for
all targets. This attribute may be attached to a struct/union, struct/union
-field, function, function parameter or variable declaration. If -g is specified,
-the ``ARGUMENT`` info will be preserved in IR and be emitted to dwarf.
-For BPF targets, the ``ARGUMENT`` info will be emitted to .BTF ELF section too.
+field, function, function parameter, variable or typedef declaration. If -g is
+specified, the ``ARGUMENT`` info will be preserved in IR and be emitted to
+dwarf. For BPF targets, the ``ARGUMENT`` info will be emitted to .BTF ELF
+section too.
}];
}
Index: clang/include/clang/Basic/Attr.td
===================================================================
--- clang/include/clang/Basic/Attr.td
+++ clang/include/clang/Basic/Attr.td
@@ -1839,7 +1839,8 @@
def BTFDeclTag : InheritableAttr {
let Spellings = [Clang<"btf_decl_tag">];
let Args = [StringArgument<"BTFDeclTag">];
- let Subjects = SubjectList<[Var, Function, Record, Field], ErrorDiag>;
+ let Subjects = SubjectList<[Var, Function, Record, Field, TypedefName],
+ ErrorDiag>;
let Documentation = [BTFDeclTagDocs];
let LangOpts = [COnly];
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D110127.380275.patch
Type: text/x-patch
Size: 4425 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20211018/3c24d726/attachment-0001.bin>
More information about the cfe-commits
mailing list