[all-commits] [llvm/llvm-project] d8cec6: [clang] Support member function poiners in Decl::g...

Benjamin Maxwell via All-commits all-commits at lists.llvm.org
Wed Feb 5 16:30:58 PST 2025


  Branch: refs/heads/release/20.x
  Home:   https://github.com/llvm/llvm-project
  Commit: d8cec6dfe6abee77a802b48588bec8747777eaea
      https://github.com/llvm/llvm-project/commit/d8cec6dfe6abee77a802b48588bec8747777eaea
  Author: Benjamin Maxwell <benjamin.maxwell at arm.com>
  Date:   2025-02-05 (Wed, 05 Feb 2025)

  Changed paths:
    M clang/include/clang/AST/DeclBase.h
    M clang/include/clang/Basic/Attr.td
    M clang/lib/AST/DeclBase.cpp
    M clang/test/AST/attr-print-emit.cpp
    A clang/test/CodeGen/AArch64/sme-attributes-member-function-pointer.cpp
    A clang/test/CodeGen/xfail-alloc-align-fn-pointers.cpp

  Log Message:
  -----------
  [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).

(cherry picked from commit 692c9b210728323ac499a402ee6eb901f35856f2)



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list