summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--clang/lib/StaticAnalyzer/Checkers/RunLoopAutoreleaseLeakChecker.cpp5
-rw-r--r--clang/test/Analysis/Checkers/RunLoopAutoreleaseLeakChecker.m11
2 files changed, 13 insertions, 3 deletions
diff --git a/clang/lib/StaticAnalyzer/Checkers/RunLoopAutoreleaseLeakChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/RunLoopAutoreleaseLeakChecker.cpp
index 64b61a0213d..5c578544191 100644
--- a/clang/lib/StaticAnalyzer/Checkers/RunLoopAutoreleaseLeakChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/RunLoopAutoreleaseLeakChecker.cpp
@@ -46,8 +46,7 @@ const char * RunLoopRunBind = "RunLoopRunM";
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;
diff --git a/clang/test/Analysis/Checkers/RunLoopAutoreleaseLeakChecker.m b/clang/test/Analysis/Checkers/RunLoopAutoreleaseLeakChecker.m
index 4dde40e210a..32fc2206a31 100644
--- a/clang/test/Analysis/Checkers/RunLoopAutoreleaseLeakChecker.m
+++ b/clang/test/Analysis/Checkers/RunLoopAutoreleaseLeakChecker.m
@@ -43,7 +43,7 @@ void runloop_init_before_two_objects() { // Warning: object created before the l
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 runloop_init_after() { // No warning: objects created after the loop
}
}
+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
OpenPOWER on IntegriCloud