[cfe-dev] cleanup attribute for variables

Aaron Ballman aaron at aaronballman.com
Wed Jun 3 09:39:47 PDT 2015


On Wed, Jun 3, 2015 at 12:27 PM, Alex Regueiro <alexreg at gmail.com> wrote:
> GNU (gcc) has the variable attribute 'cleanup' (`__attribute__ ((cleanup(f))`) for freeing memory and cleaning up when a variable goes out of scope. It’s extremely useful, as it enables the use of smart pointers (e.g. http://snaipe.me/c/c-smart-pointers/) and other forms of automatic memory management.
>
> Any chance this could be implemented in clang?

I believe it is already. Are you finding instances where it does not work?

~Aaron




More information about the cfe-dev mailing list