Custom function attributes in FunctionPass

Hi,

I hope this is the right list for this question.

I wrote a Clang/LLVM plugin as a function pass to do some application specific optimazations on my C/C++ code.

To exclude functions from this optimazation pass I want to use C++11 custom function attributes and want to set “plugin_do_not_optimize” like this. I want to check it in my pass and if it is set, simply skip the pass.

void
foo( void ) __attribute__(( plugin_do_not_optimize ))
{
    printf( "Hello world. \n" );
}

I found the AttributBuilder in the docs but cant get rid of it, catching my attribute.

I already tried

f.hasFnAttribute("plugin_do_not_optimize");

but it does not return true on the function above and I get the following error:

test.cpp:4:28: warning: unknown attribute 'plugin_do_not_optimize' ignored [-Wunknown-attributes]

How to declare my attribute in clang and get the information if it is set in my pass?

Best regards,

Shixin Wang