Author: george.karpenkov Date: Mon Jul 30 14:44:15 2018 New Revision: 338312
URL: http://llvm.org/viewvc/llvm-project?rev=338312&view=rev Log: [analyzer] Fix crash in RunLoopAutoreleaseChecker on empty children Differential Revision: https://reviews.llvm.org/D50012 Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/RunLoopAutoreleaseLeakChecker.cpp cfe/trunk/test/Analysis/Checkers/RunLoopAutoreleaseLeakChecker.m Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/RunLoopAutoreleaseLeakChecker.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/RunLoopAutoreleaseLeakChecker.cpp?rev=338312&r1=338311&r2=338312&view=diff ============================================================================== --- cfe/trunk/lib/StaticAnalyzer/Checkers/RunLoopAutoreleaseLeakChecker.cpp (original) +++ cfe/trunk/lib/StaticAnalyzer/Checkers/RunLoopAutoreleaseLeakChecker.cpp Mon Jul 30 14:44:15 2018 @@ -46,8 +46,7 @@ const char * RunLoopRunBind = "RunLoopRu const char * OtherMsgBind = "OtherMessageSentM"; const char * AutoreleasePoolBind = "AutoreleasePoolM"; -class RunLoopAutoreleaseLeakChecker : public Checker< - check::ASTCodeBody> { +class RunLoopAutoreleaseLeakChecker : public Checker<check::ASTCodeBody> { public: void checkASTCodeBody(const Decl *D, @@ -66,6 +65,8 @@ static TriBoolTy 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; Modified: cfe/trunk/test/Analysis/Checkers/RunLoopAutoreleaseLeakChecker.m URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/Checkers/RunLoopAutoreleaseLeakChecker.m?rev=338312&r1=338311&r2=338312&view=diff ============================================================================== --- cfe/trunk/test/Analysis/Checkers/RunLoopAutoreleaseLeakChecker.m (original) +++ cfe/trunk/test/Analysis/Checkers/RunLoopAutoreleaseLeakChecker.m Mon Jul 30 14:44:15 2018 @@ -43,7 +43,7 @@ void runloop_init_before_two_objects() { NSObject *object2 = [[NSObject alloc] init]; // no-warning, warning on the first one is enough. (void) object; (void) object2; - [[NSRunLoop mainRunLoop] run]; + [[NSRunLoop mainRunLoop] run]; } } @@ -60,6 +60,15 @@ void runloop_init_after() { // No warnin (void) object; } } + +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 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits