[PATCH] D14824: [PATCH] Add clang-tidy check for static or thread_local objects where construction may throw
Aaron Ballman via cfe-commits
cfe-commits at lists.llvm.org
Thu Nov 19 09:01:50 PST 2015
aaron.ballman created this revision.
aaron.ballman added reviewers: alexfh, sbenza.
aaron.ballman added a subscriber: cfe-commits.
Throwing an exception from the constructor of an object being used with static or thread_local storage duration is a dangerous operation. The exception thrown for an object with static storage duration cannot be caught, even by function-try-blocks in main, and the exception thrown for an object with thread_local storage duration cannot be caught by a function-try-block of the initial thread. This patch adds a checker to flag such constructs.
This check corresponds to the CERT secure coding rule: https://www.securecoding.cert.org/confluence/display/cplusplus/ERR58-CPP.+Constructors+of+objects+with+static+or+thread+storage+duration+must+not+throw+exceptions
http://reviews.llvm.org/D14824
Files:
clang-tidy/cert/CERTTidyModule.cpp
clang-tidy/cert/CMakeLists.txt
clang-tidy/cert/StaticObjectExceptionCheck.cpp
clang-tidy/cert/StaticObjectExceptionCheck.h
docs/clang-tidy/checks/cert-static-object-exception.rst
docs/clang-tidy/checks/list.rst
test/clang-tidy/cert-static-object-exception.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D14824.40660.patch
Type: text/x-patch
Size: 8338 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20151119/53177206/attachment.bin>
More information about the cfe-commits
mailing list