This is an archive of the discontinued LLVM Phabricator instance.

[clang-tidy] cert-err58-cpp should not apply to function scope objects
ClosedPublic

Authored by malcolm.parsons on Sep 23 2016, 2:45 PM.

Details

Summary

https://www.securecoding.cert.org/confluence/display/cplusplus/ERR58-CPP.+Constructors+of+objects+with+static+or+thread+storage+duration+must+not+throw+exceptions says:
Exceptions thrown in destructors of objects with static storage duration or in
constructors of namespace scope objects with static storage duration are not
caught by a function-try-block on main() . Exceptions thrown in destructors of
objects with thread storage duration or in constructors of namespace-scope
objects with thread storage duration are not caught by a function-try-block on
the initial function of the thread.

Function scope static objects are constructed when required by the function, so
exceptions can be caught from main().

Change cert-err58-cpp check to not apply to function/method scope objects.
Update tests.

Diff Detail

Event Timeline

malcolm.parsons retitled this revision from to [clang-tidy] cert-err58-cpp should not apply to function scope objects.
malcolm.parsons updated this object.
aaron.ballman accepted this revision.Sep 26 2016, 7:36 AM
aaron.ballman edited edge metadata.

LGTM!

Good catch, I will fix up the CERT rule to match the check accordingly. Thank you for this!

This revision is now accepted and ready to land.Sep 26 2016, 7:36 AM

I don't have commit access, so please commit it for me.
Thanks.

aaron.ballman closed this revision.Sep 26 2016, 8:10 AM

Commit in r282409