-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[clang] Support member function poiners in Decl::getFunctionType() (#…
…125077) This seems consistent with the documentation, which claims it: ``` /// Looks through the Decl's underlying type to extract a FunctionType /// when possible. Will return null if the type underlying the Decl does not /// have a FunctionType. const FunctionType *getFunctionType(bool BlocksToo = true) const; ``` Note: This patch rewords this doc comment to clarify it includes various function pointer types. Without this, attaching attributes (which use `HasFunctionProto`) to member function pointers errors with: ``` error: '<attr>' only applies to non-K&R-style functions ``` ...which does not really make sense, since member functions are not K&C functions. With this change the Arm SME TypeAttrs work correctly on member function pointers. Note, however, that not all attributes work correctly when applied to function pointers or member function pointers. For example, `alloc_align` crashes when applied to a function pointer (on truck): https://godbolt.org/z/YvMhnhKfx (as it only expects a `FunctionDecl` not a `ParmVarDecl`). The same crash applies to member function pointers (for the same reason).
- Loading branch information
Showing
6 changed files
with
60 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
clang/test/CodeGen/AArch64/sme-attributes-member-function-pointer.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// RUN: %clang_cc1 -triple aarch64 -target-feature +sme -target-feature +sme2 -x c++ -std=c++20 -emit-llvm -o - %s | FileCheck %s --check-prefixes=CHECK | ||
|
||
struct TestStruct; | ||
|
||
__arm_new("za", "zt0") void test(TestStruct& TS, | ||
void (TestStruct::*streaming_member_ptr)() __arm_streaming, | ||
void (TestStruct::*streaming_compat_member)() __arm_streaming_compatible, | ||
void (TestStruct::*arm_in_member)() __arm_in("za", "zt0"), | ||
void (TestStruct::*arm_inout_member)() __arm_inout("za", "zt0"), | ||
void (TestStruct::*arm_preserves_member)() __arm_preserves("za", "zt0"), | ||
void (TestStruct::*arm_agnostic_member)() __arm_agnostic("sme_za_state")) { | ||
|
||
// CHECK: call void %{{.*}} [[STREAMING_MEMBER_CALL_ATTRS:#.+]] | ||
(TS.*streaming_member_ptr)(); | ||
|
||
// CHECK: call void %{{.*}} [[STREAMING_COMPAT_MEMBER_CALL_ATTRS:#.+]] | ||
(TS.*streaming_compat_member)(); | ||
|
||
// CHECK: call void %{{.*}} [[ARM_IN_MEMBER_CALL_ATTRS:#.+]] | ||
(TS.*arm_in_member)(); | ||
|
||
// CHECK: call void %{{.*}} [[ARM_INOUT_MEMBER_CALL_ATTRS:#.+]] | ||
(TS.*arm_inout_member)(); | ||
|
||
// CHECK: call void %{{.*}} [[ARM_PRESERVES_MEMBER_CALL_ATTRS:#.+]] | ||
(TS.*arm_preserves_member)(); | ||
|
||
// CHECK: call void %{{.*}} [[ARM_AGNOSTIC_MEMBER_CALL_ATTRS:#.+]] | ||
(TS.*arm_agnostic_member)(); | ||
} | ||
|
||
// CHECK: attributes [[STREAMING_MEMBER_CALL_ATTRS]] = { "aarch64_pstate_sm_enabled" } | ||
// CHECK: attributes [[STREAMING_COMPAT_MEMBER_CALL_ATTRS]] = { "aarch64_pstate_sm_compatible" } | ||
// CHECK: attributes [[ARM_IN_MEMBER_CALL_ATTRS]] = { "aarch64_in_za" "aarch64_in_zt0" } | ||
// CHECK: attributes [[ARM_INOUT_MEMBER_CALL_ATTRS]] = { "aarch64_inout_za" "aarch64_inout_zt0" } | ||
// CHECK: attributes [[ARM_PRESERVES_MEMBER_CALL_ATTRS]] = { "aarch64_preserves_za" "aarch64_preserves_zt0" } | ||
// CHECK: attributes [[ARM_AGNOSTIC_MEMBER_CALL_ATTRS]] = { "aarch64_za_state_agnostic" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
|
||
// RUN: %clang_cc1 %s | ||
|
||
// FIXME: These should not crash! | ||
// XFAIL: * | ||
|
||
void aa_fn_ptr(char* (*member)(char*) __attribute__((alloc_align(1)))); | ||
|
||
struct Test; | ||
void aa_member_fn_ptr(char* (Test::*member)(char*) __attribute__((alloc_align(1)))); |