[cfe-dev] How to retrieve a user defined attribute from a DeclGroup?
Marcel Schaible via cfe-dev
cfe-dev at lists.llvm.org
Tue Jul 18 08:05:07 PDT 2017
Hi,
I am struggling with a propably stupid simple problem:
In my plugin I have attributted the ast for a function decl with my own
attribute:
Something like that:
class AnnotateFunctionsConsumer : public ASTConsumer {
public:
bool HandleTopLevelDecl(DeclGroupRef DG) override {
for (auto D : DG)
if (FunctionDecl *FD = dyn_cast<FunctionDecl>(D))
FD->addAttr(AnnotateAttr::CreateImplicit(FD->getASTContext(),
"MyOwnAttr"));
return true;
}
};
In another part of my tool I want to retrieve this attribute inside of a
AstConsumer and perform some transformations.
What is the proper way for doing this? Is FD->getAttr the intended
function for this and if yes how to call in the above mentiond example?
Thanks
Marcel
More information about the cfe-dev
mailing list