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

Benjamin Maxwell via All-commits all-commits at lists.llvm.org
Mon Feb 3 01:37:37 PST 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 692c9b210728323ac499a402ee6eb901f35856f2
      https://github.com/llvm/llvm-project/commit/692c9b210728323ac499a402ee6eb901f35856f2
  Author: Benjamin Maxwell <benjamin.maxwell at arm.com>
  Date:   2025-02-03 (Mon, 03 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).



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