[cfe-dev] cleanup attribute for variables

Alex Regueiro alexreg at gmail.com
Wed Jun 3 09:27:23 PDT 2015

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?

More information about the cfe-dev mailing list