diff options
-rw-r--r-- | lib/StaticAnalyzer/Checkers/IdempotentOperationChecker.cpp | 5 | ||||
-rw-r--r-- | test/Analysis/idempotent-operations.m | 12 |
2 files changed, 14 insertions, 3 deletions
diff --git a/lib/StaticAnalyzer/Checkers/IdempotentOperationChecker.cpp b/lib/StaticAnalyzer/Checkers/IdempotentOperationChecker.cpp index 495c594bea..b2177c9a75 100644 --- a/lib/StaticAnalyzer/Checkers/IdempotentOperationChecker.cpp +++ b/lib/StaticAnalyzer/Checkers/IdempotentOperationChecker.cpp @@ -336,10 +336,9 @@ void IdempotentOperationChecker::checkPostStmt(const BinaryOperator *B, = cast<StmtPoint>(C.getPredecessor()->getLocation()).getStmt(); // Ignore implicit calls to setters. - if (isa<ObjCPropertyRefExpr>(predStmt)) + if (!isa<BinaryOperator>(predStmt)) return; - - assert(isa<BinaryOperator>(predStmt)); + Data.explodedNodes.Add(C.getPredecessor()); } diff --git a/test/Analysis/idempotent-operations.m b/test/Analysis/idempotent-operations.m index 39d44c4978..8f534940c9 100644 --- a/test/Analysis/idempotent-operations.m +++ b/test/Analysis/idempotent-operations.m @@ -40,3 +40,15 @@ void pr9116(NSObject *placeholder) { int x = placeholder.media.locked = placeholder ? 1 : 0; } +// <rdar://problem/9130239>: Test that calling property setters doesn't +// trigger an assertion failure when the object is nil. +@interface RDar9130239 +@property (assign) id delegate; +@end + +void test_RDar9130239(RDar9130239 *x) { + if (x) + return; + x.delegate = x; // no-warning +} + |