Commit ffeb0f6
committed
[alpha.webkit.RetainPtrCtorAdoptChecker] An assortment of small enhancements
This PR implements various small enhancements to alpha.webkit.RetainPtrCtorAdoptChecker:
- Detect leaks from [[X alloc] init] when ARC is disabled.
- Detect leaks from calling Create, Copy, and other +1 CF functions.
- Recognize [allocX() init] pattern where allocX is a C/C++ function.
- Recognize _init in addition to init as an init function.
- Recognize [[[X alloc] init] autorelease].
- Recognize CFBridgingRelease.
- Support CF_RETRUNS_RETAINED on out arguments of a C function.
- Support returning +1 object in Create, Copy, and other +1 functions or +1 selectors.
- Support variadic Create, Copy, and other +1 C/C++ functions.
To make these enhancements, this PR introduces new visit functions for ObjCMessageExpr,
ReturnStmt, VarDecl, and BinaryOperator. These functions look for a specific construct
mentioned above and adds an expression such as [[X alloc] init] or CreateX to a DenseSet
CreateOrCopyFnCall when the expression does not result in leaks. When the code to detect
leaks such as the one in visitObjCMessageExpr later encounters this expression, it can
bail out early if the expression is in the set.1 parent 0816c7a commit ffeb0f6
File tree
4 files changed
+648
-36
lines changed- clang
- lib/StaticAnalyzer/Checkers/WebKit
- test/Analysis/Checkers/WebKit
4 files changed
+648
-36
lines changed
0 commit comments