aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/StaticAnalyzer/Checkers/IdempotentOperationChecker.cpp11
-rw-r--r--test/Analysis/idempotent-operations.m12
2 files changed, 19 insertions, 4 deletions
diff --git a/lib/StaticAnalyzer/Checkers/IdempotentOperationChecker.cpp b/lib/StaticAnalyzer/Checkers/IdempotentOperationChecker.cpp
index 633648ec6c..7f64f8e2c4 100644
--- a/lib/StaticAnalyzer/Checkers/IdempotentOperationChecker.cpp
+++ b/lib/StaticAnalyzer/Checkers/IdempotentOperationChecker.cpp
@@ -357,8 +357,15 @@ void IdempotentOperationChecker::PostVisitBinaryOperator(
const BinaryOperator *B) {
// Add the ExplodedNode we just visited
BinaryOperatorData &Data = hash[B];
- assert(isa<BinaryOperator>(cast<StmtPoint>(C.getPredecessor()
- ->getLocation()).getStmt()));
+
+ const Stmt *predStmt
+ = cast<StmtPoint>(C.getPredecessor()->getLocation()).getStmt();
+
+ // Ignore implicit calls to setters.
+ if (isa<ObjCPropertyRefExpr>(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 3f68206b16..bda98fa717 100644
--- a/test/Analysis/idempotent-operations.m
+++ b/test/Analysis/idempotent-operations.m
@@ -4,10 +4,12 @@ typedef signed char BOOL;
typedef unsigned long NSUInteger;
typedef struct _NSZone NSZone;
@protocol NSObject - (BOOL)isEqual:(id)object;
-@end @interface NSObject <NSObject> {
-}
@end
+@interface NSObject {}
+ @property int locked;
+ @property(nonatomic, readonly) NSObject *media;
+@end
// <rdar://problem/8725041> - Don't flag idempotent operation warnings when
// a method may invalidate an instance variable.
@@ -32,3 +34,9 @@ typedef struct _NSZone NSZone;
}
@end
+// Test that the idempotent operations checker works in the prescence
+// of property expressions.
+void pr9116(NSObject *placeholder) {
+ int x = placeholder.media.locked = placeholder ? 1 : 0;
+}
+