Index: lib/StaticAnalyzer/Checkers/RunLoopAutoreleaseLeakChecker.cpp =================================================================== --- lib/StaticAnalyzer/Checkers/RunLoopAutoreleaseLeakChecker.cpp +++ lib/StaticAnalyzer/Checkers/RunLoopAutoreleaseLeakChecker.cpp @@ -46,8 +46,7 @@ const char * OtherMsgBind = "OtherMessageSentM"; const char * AutoreleasePoolBind = "AutoreleasePoolM"; -class RunLoopAutoreleaseLeakChecker : public Checker< - check::ASTCodeBody> { +class RunLoopAutoreleaseLeakChecker : public Checker { public: void checkASTCodeBody(const Decl *D, @@ -66,6 +65,8 @@ seenBeforeRec(const Stmt *Parent, const Stmt *A, const Stmt *B, MemoizationMapTy &Memoization) { for (const Stmt *C : Parent->children()) { + if (!C) continue; + if (C == A) return true; Index: test/Analysis/Checkers/RunLoopAutoreleaseLeakChecker.m =================================================================== --- test/Analysis/Checkers/RunLoopAutoreleaseLeakChecker.m +++ test/Analysis/Checkers/RunLoopAutoreleaseLeakChecker.m @@ -43,7 +43,7 @@ NSObject *object2 = [[NSObject alloc] init]; // no-warning, warning on the first one is enough. (void) object; (void) object2; - [[NSRunLoop mainRunLoop] run]; + [[NSRunLoop mainRunLoop] run]; } } @@ -61,6 +61,15 @@ } } +void no_crash_on_empty_children() { + @autoreleasepool { + for (;;) {} + NSObject *object = [[NSObject alloc] init]; // expected-warning{{Temporary objects allocated in the autorelease pool followed by the launch of main run loop may never get released; consider moving them to a separate autorelease pool}} + [[NSRunLoop mainRunLoop] run]; + (void) object; + } +} + #endif #ifdef AP1