[cfe-dev] Check assignment attributes compatibility

Reid Kleckner via cfe-dev cfe-dev at lists.llvm.org
Tue Jul 11 10:11:23 PDT 2017


Attributes are not reflected in the canonical type. They may only appear on
the fully-sugared type, which isn't always available. Some attributes, like
calling convention attributes, noreturn, regparm, and some other misc
things, are embedded in the canonical FunctionProtoType, but this is only
implemented on a case-by-case basis as required by overload resolution and
other language extension rules.

I think your best path forward is to embed the attributes you care about in
FunctionProtoType::ExtProtoInfo.

On Sun, Jul 2, 2017 at 7:05 AM, Marc-André Lureau via cfe-dev <
cfe-dev at lists.llvm.org> wrote:

> Hi,
>
> I am new to clang development, and I would like to have some warnings if
> an assignment of function pointer doesn't match the LHS attributes: void
> __attribute__((Attrs)) (*func)() = foo should warn if foo doesn't have
> Attrs.
>
> I have started adding some code around Sema::
> CheckSingleAssignmentConstraints. I can get the attrs from the LHS,
> LHSType.getTypePtr() / ->getAs<TypedefType>() if necessary / ->getDecl()
> and use attribute getters. However, I have more trouble with the RHS for
> some reason, RHS.get()->getType() is a FunctionProtoType. How can I get the
> associated attributes from there?
>
> thanks a lot
> --
> Marc-André Lureau
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20170711/33db4447/attachment.html>


More information about the cfe-dev mailing list