[cfe-dev] [Static Analyzer] Rules for enforcing smart-ptr usage?
forderud at gmail.com
Tue Dec 3 12:19:09 PST 2013
It would be nice with rules for enforcing smart-pointer usage in C++. I
guess that this can be achieved by disallowing assignment of the
return-value of "new" to a raw pointer. It would also be possible to
disallow "delete" altogether, but might be a bit indirect.
The return-value of "new" should instead be assigned directly to a
auto_ptr/scoped_ptr/unique_ptr/shared_ptr or other user-defined RAII type.
Hopefully, a rule wouldn't need to depend on a "whitelist" of pre-approved
Smart-ptr enforcement is probably not something that everyone would like to
activate, but it could still be very valuable for avoiding memory &
resource leaks if it was an optional checker.
Could this be possible to implement?
Thanks in advance,
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the cfe-dev