[PATCH] D110127: [Clang] Support typedef with btf_tag attributes

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Sep 21 06:15:49 PDT 2021


aaron.ballman added a comment.

> First, to build linux kernel with btf_tag annotated user pointer, we have
>
> #define __user __attribute__((btf_tag("user")))
> and the linux kernel contains code like below ([2])
>
> typedef __signalfn_t __user *__sighandler_t;
> and the user attribute applies to typedef type sighandler_t.
> So clang needs to support btf_tag attribute with typedef type
> to avoid compilation error.

I want to make sure we're clear on the semantics here. That defines `__sighandler_t` to be the type `__signalfn_t __user *`, so you expect this to annotate the type, not the declaration of the typedef. So this is about allowing `btf_tag` on types in addition to declarations?

> typedef struct { ... } target_type __btf_tag

Similar here -- this applies the __btf_tag to the type, not to the declaration of the typedef, right?

I'm asking because this raises other questions. For example:

  void func(int i);
  void func(int __attribute__((btf_tag("__user"))) i);

Is the second a valid redeclaration of the first? Additionally:

  __attribute__((overloadable)) void func(int i) { puts("one"); }
  __attribute__((overloadable)) void func(int __attribute__((btf_tag("__user"))) i) { puts("two"); }

Is this a valid overload set because of the type attribute? Along the same lines, does adding this attribute to the type cause any ABI differences in how the type is passed?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D110127/new/

https://reviews.llvm.org/D110127



More information about the cfe-commits mailing list