diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -268,6 +268,8 @@ functions. `Issue 56154 `_ - Fix handling of unexpanded packs in template argument expressions. `Issue 58679 `_ +- Fix a crash when a ``btf_type_tag`` attribute is applied to the pointee of + a function pointer. Improvements to Clang's diagnostics ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp --- a/clang/lib/Sema/SemaType.cpp +++ b/clang/lib/Sema/SemaType.cpp @@ -6515,6 +6515,9 @@ CurrTL = TL.getNextTypeLoc().getUnqualifiedLoc(); } + while (BTFTagAttributedTypeLoc TL = CurrTL.getAs()) + CurrTL = TL.getNextTypeLoc().getUnqualifiedLoc(); + while (DependentAddressSpaceTypeLoc TL = CurrTL.getAs()) { fillDependentAddressSpaceTypeLoc(TL, D.getTypeObject(i).getAttrs()); diff --git a/clang/test/CodeGen/attr-btf_type_tag-func-ptr.c b/clang/test/CodeGen/attr-btf_type_tag-func-ptr.c new file mode 100644 --- /dev/null +++ b/clang/test/CodeGen/attr-btf_type_tag-func-ptr.c @@ -0,0 +1,15 @@ +// RUN: %clang_cc1 -triple %itanium_abi_triple -debug-info-kind=limited -S -emit-llvm -o - %s | FileCheck %s + +struct t { + int (__attribute__((btf_type_tag("rcu"))) *f)(); + int a; +}; +int foo(struct t *arg) { + return arg->a; +} + +// CHECK: !DIDerivedType(tag: DW_TAG_member, name: "f" +// CHECK-SAME: baseType: ![[L18:[0-9]+]] +// CHECK: ![[L18]] = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: ![[#]], size: [[#]], annotations: ![[L21:[0-9]+]]) +// CHECK: ![[L21]] = !{![[L22:[0-9]+]]} +// CHECK: ![[L22]] = !{!"btf_type_tag", !"rcu"}