Using the annotate attribute on classes

Hi all

I’m looking for a way to annotate a c++ class and the annotate attribute doesn’t seem to work on class declarations? Is there a special way to do it or is it just not possible?


I think it goes after the class definition.

class C {} attribute(X);

Hi Jonathan

Thanks for your reply. I forgot to mention that I was interested in having the attribute propagate through to the IR (to then later pick up in an IR analysis pass), which it doesn’t appear to be (even when specifying the annotate attribute as you say).

Here is my test program:

class A {
void foo() { }
} attribute((annotate(“hello”)));

int main(int argc, char** argv) {
A a1;;
A* a2 = new A;
return 0;


Hi Khilan,

As far as I know, that information is not propagated to the IR. At least in
your example, and in several other cases, the optimizer may (through inlining)
remove any mention of class A entirely, so you can't always rely on it being
around by the time your analysis pass sees it.

Can you go into more detail of what you need the annotations for? There may
be a better way to do what you want.