C++11 attributes attached to a statement

Hi all,

I’m adding some new non-standard C++ attributes in clang. I’m using this link


I added an C++11 attribute in clang attached to a Function,

  • include/clang/Basic/Attr.td

def CXX11MYOWNAttr : InheritableAttr {
let Spellings = [CXX11<“my”,“ownattr”, 201412>];
let Subjects = SubjectList<[Function], ErrorDiag>;
let Documentation = [Undocumented];


  • lib/Sema/SemaDeclAttr.cpp

in ProcessDeclAttribute function:

case AttributeList::AT_CXX11MYOWNAttr:
handleSimpleAttribute<CXX11MYOWNAttr>(S, D, Attr);

however, I would like to include this to a statement.

Any help?



I the easiest way for you to add a C++11 attribute to a statement is to follow the LoopHint attribute through the code.

The attribute is handled in ./lib/Sema/SemaStmtAttr.cpp

Michael Haidl

LoopHint isn't quite the one I would model after since that's a
pragma. FallThrough, however, is a good statement attribute to model
after. And the semantic handling for statement attributes is in
SemaStmtAttr.cpp, as Michael points out.