[cfe-dev] Using the annotate attribute on classes

Peter Collingbourne peter at pcc.me.uk
Mon Mar 30 10:43:44 PDT 2015


On Mon, Mar 30, 2015 at 12:23:56PM +0100, Khilan Gudka wrote:
> 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 {
>   public:
>     void foo() { }
> } __attribute__((annotate("hello")));
> 
> int main(int argc, char** argv) {
>   A a1;
>   a1.foo();
>   A* a2 = new A;
>   a2->foo();
>   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.

Thanks,
-- 
Peter



More information about the cfe-dev mailing list