[cfe-dev] Attributes on function calls
Aaron Ballman via cfe-dev
cfe-dev at lists.llvm.org
Wed Sep 21 05:59:34 PDT 2016
On Tue, Sep 20, 2016 at 9:21 PM, Riyaz Puthiyapurayil via cfe-dev
<cfe-dev at lists.llvm.org> wrote:
> For a custom clang-tidy check, I need to be able to add an attribute to a function call (not function declaration). I have never added an attribute before. Does clang support attributes on function calls?
Sort of. Clang parses C++11-style attributes on expression statements,
but we do not currently have any attributes that appertain to an
> I see that CallExpr derives from DStmt<Expr> in StmtNodes.td and the documentation on adding attributes states that SubjectList of an attribute can be a statement node. Before I attempt this, can anyone tell me if this is even going to work?
It will with C++11-style attributes, but it won't with GNU-style attributes.
> Will this involve making changes in parser (which I would really like to avoid)? Ideally, I want to be able to add the attribute in Attr.td and then be able to query it in the check. Is there an existing attribute that I can model this after?
You shouldn't have to change the parser for this. Instead, you would
add the attribute to Attr.td as a StmtAttr, and then add the logic to
convert the parsed attribute into a semantic attribute in
SemaStmtAttr.cpp. There are some other statement attributes that you
can sort of model this after, but none of them appertain to
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
More information about the cfe-dev