39using namespace ast_matchers;
43const char * RunLoopBind =
"NSRunLoopM";
44const char * RunLoopRunBind =
"RunLoopRunM";
45const char * OtherMsgBind =
"OtherMessageSentM";
46const char * AutoreleasePoolBind =
"AutoreleasePoolM";
47const char * OtherStmtAutoreleasePoolBind =
"OtherAutoreleasePoolM";
49class RunLoopAutoreleaseLeakChecker :
public Checker<check::ASTCodeBody> {
52 void checkASTCodeBody(
const Decl *
D,
84 const RunLoopAutoreleaseLeakChecker *
Checker) {
98 bool HasAutoreleasePool = (AP !=
nullptr);
102 assert(RLR &&
"Run loop launch not found");
109 if (HasAutoreleasePool && (OAP != AP))
117 "Memory leak inside autorelease pool",
120 (Twine(
"Temporary objects allocated in the") +
121 " autorelease pool " +
122 (HasAutoreleasePool ?
"" :
"of last resort ") +
123 "followed by the launch of " +
124 (RL ?
"main run loop " :
"xpc_main ") +
125 "may never get released; consider moving them to a "
126 "separate autorelease pool")
134 hasReceiverType(asString(
"NSRunLoop")),
139 hasReceiver(MainRunLoopM),
140 Extra).bind(RunLoopRunBind);
144 return anyOf(MainRunLoopRunM, XPCRunM);
149 equalsBoundNode(RunLoopRunBind))),
156 const RunLoopAutoreleaseLeakChecker *Chkr) {
175 const RunLoopAutoreleaseLeakChecker *Chkr) {
195void RunLoopAutoreleaseLeakChecker::checkASTCodeBody(
const Decl *
D,
202void ento::registerRunLoopAutoreleaseLeakChecker(
CheckerManager &mgr) {
206bool ento::shouldRegisterRunLoopAutoreleaseLeakChecker(
const CheckerManager &mgr) {