This is an archive of the discontinued LLVM Phabricator instance.

[PATCH] Add checker discouraging use of setjmp/longjmp in C++
ClosedPublic

Authored by aaron.ballman on Oct 8 2015, 11:13 AM.

Details

Reviewers
alexfh
sbenza
Summary

setjmp and longjmp facilities in C++ are unsafe due to the likelihood of triggering undefined behavior with nontrivial type destruction, etc. Instead, exception handling facilities are a better choice. This patch adds a checker that discourages the use of setjmp and longjmp in C++.

This patch corresponds to CERT C++ Coding Standard rule: https://www.securecoding.cert.org/confluence/pages/viewpage.action?pageId=1834

Diff Detail

Event Timeline

aaron.ballman retitled this revision from to [PATCH] Add checker discouraging use of setjmp/longjmp in C++.
aaron.ballman updated this object.
aaron.ballman added reviewers: alexfh, sbenza.
aaron.ballman added a subscriber: cfe-commits.
sbenza added inline comments.Oct 8 2015, 12:47 PM
clang-tidy/cert/SetLongJmpCheck.cpp
32

Why do you pass one as a pointer and one as a reference?

aaron.ballman marked an inline comment as done.

Corrected a simple copy-paste error.

sbenza accepted this revision.Oct 8 2015, 12:54 PM
sbenza edited edge metadata.
This revision is now accepted and ready to land.Oct 8 2015, 12:54 PM
aaron.ballman closed this revision.Oct 8 2015, 12:56 PM

Thank you for the fast turn-around! I've commit in r249727.

~Aaron