[LLVMdev] Adding/checking an attribute to function argument
Philip Reames
listmail at philipreames.com
Tue Jul 14 22:16:09 PDT 2015
On 07/09/2015 07:06 PM, Tarun Prabhu wrote:
> Hello,
>
> I am trying to add custom attributes to function arguments. I can add
> them using Argument->addAttr().
>
> | AttrBuilder attrbuilder;
> | Attribute attr = Attribute::get(context, "attrname", "attrval");
> | attrBuilder.addAttribute(attr);
> | arg->addAttr(AttributeSet::get(context, 0, attrBuilder));
>
> But I can't find a way to check if a Argument has attribute "attrname".
>
> You can do this for functions with addFnAttribute("attrname",
> "attrval"), and then query it with hasFnAttribute("attrname").
>
> Is there a similar API for Arguments which, for some reason, doesn't
> appear in the documentation?
See the discussion happening under the title "String attributes for
function arguments and return values". If I'm reading your question
correctly, that's exactly what you're asking about.
API wise, you need to get the attribute set from the function and look
at the i+1 index to see if the attribute exists. It's a bit of a mess,
but that's the current way to do so.
>
> Thanks,
>
> Tarun
>
>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150714/3ab42b46/attachment.html>
More information about the llvm-dev
mailing list