[cfe-dev] How to retrieve a custom annotation in an ASTVisitor?
Aaron Ballman via cfe-dev
cfe-dev at lists.llvm.org
Wed Aug 2 09:59:35 PDT 2017
On Wed, Aug 2, 2017 at 12:43 PM, Marcel Schaible
<marcel at schaible-consulting.de> wrote:
> Thanks Aaron, works for one annotation.
>
> If I have multiple annotations per function declaration how can I iterate
> over them or can I use something like funcdecl->getAttr("SomeAttr")?
You can use the specific_attrs<> function to get a range, like:
for (const auto *A : functionDecl->specific_attrs<AnnotateAttr>()) {
}
(There is also specific_attr_begin<>() and specific_attr_end<>() if
you want iterators instead of a range.)
~Aaron
More information about the cfe-dev
mailing list