[PATCH] D111199: [Clang][LLVM][Attr] support btf_type_tag attribute

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Nov 2 04:07:57 PDT 2021


aaron.ballman added a comment.

In D111199#3101484 <https://reviews.llvm.org/D111199#3101484>, @yonghong-song wrote:

> Just to be sure my understanding is correct. Given an AttributedType node, we do have a way to get the corresponding Attr, is it right? @aaron.ballman

Oh yeah, now I remember what the problem is here! `Type *` is the abstract representation of type information in Clang. e.g. it represents an `int` in general, not a specific use of `int`. For the specific use, you need to ask the declaration for its particular `TypeSourceInfo *` object. So `AttributedType` tracks what KIND of attribute it was, but not the actual attribute itself, which means there's no way to go from an `AttributedType *` to an `Attr *` without first going through a `TypeSourceInfo *`. You can get one of those from various declarations (`DeclaratorDecl` and `TypedefNameDecl`), but the functions where you need to get to the attribute instance from don't always have the declaration handy (it'd be good to check if there are any interfaces that do have the decl handy so we can skip passing the extra argument there). So we need to pass something in some places, either a `TypeSourceInfo *` or a `TypeLoc`. A `TypeLoc` is two pointers wide, so it might make sense to pass the `TypeSourceInfo *` instead, but I don't have strong opinions there.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111199



More information about the cfe-commits mailing list