[PATCH] D26589: Add static analyzer checker for finding infinite recursion
Krzysztof Wiśniewski via cfe-commits
cfe-commits at lists.llvm.org
Sun Nov 13 08:01:30 PST 2016
k-wisniewski created this revision.
k-wisniewski added reviewers: zaks.anna, dcoughlin, dergachev.a.
k-wisniewski added a subscriber: cfe-commits.
Herald added a subscriber: mgorny.
This is the very first version of a checker that aims to find cases of infinite recursion. It relies on Add LocationContext to members of check::RegionChanges <https://reviews.llvm.org/D26588>.
What it does:
- it registers on check::PreCall and check::RegionChanges events
- in checkPreCall digs through the call stack searching for invocation of currently encountered function/method with exactly the same arguments (meaning same SVals of them)
- in checkRegionChanges makes all the frames on the call stack invalid by adding them to the set of dirty frames
- if the frame encountered by the search in checkPreCall is in the set of dirty frames the search stops
Obviously this has lots of both false negatives and false positives, but I plan to improve it by decreasing the number of frame invalidations and only taking into account changes that affect whether the recursive call happens or not. The support for Obj-C method calls is also on the way.
I welcome any ideas on how to make it better!
PS. This is one of my first patches submitted here - sorry if it doesn't comply with some conventions you might have here!
https://reviews.llvm.org/D26589
Files:
include/clang/StaticAnalyzer/Checkers/Checkers.td
lib/StaticAnalyzer/Checkers/CMakeLists.txt
lib/StaticAnalyzer/Checkers/RecursionChecker.cpp
test/Analysis/misc-ps-region-store.cpp
test/Analysis/recursion.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D26589.77746.patch
Type: text/x-patch
Size: 10486 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20161113/565fcb31/attachment.bin>
More information about the cfe-commits
mailing list