[cfe-commits] r125443 - in /cfe/trunk: lib/StaticAnalyzer/Checkers/IdempotentOperationChecker.cpp test/Analysis/idempotent-operations.m
Ted Kremenek
kremenek at apple.com
Sat Feb 12 10:50:03 PST 2011
Author: kremenek
Date: Sat Feb 12 12:50:03 2011
New Revision: 125443
URL: http://llvm.org/viewvc/llvm-project?rev=125443&view=rev
Log:
Teach the IdempotentOperations checker to ignore property setters.
Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/IdempotentOperationChecker.cpp
cfe/trunk/test/Analysis/idempotent-operations.m
Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/IdempotentOperationChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/IdempotentOperationChecker.cpp?rev=125443&r1=125442&r2=125443&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Checkers/IdempotentOperationChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/IdempotentOperationChecker.cpp Sat Feb 12 12:50:03 2011
@@ -357,8 +357,15 @@
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());
}
Modified: cfe/trunk/test/Analysis/idempotent-operations.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/idempotent-operations.m?rev=125443&r1=125442&r2=125443&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/idempotent-operations.m (original)
+++ cfe/trunk/test/Analysis/idempotent-operations.m Sat Feb 12 12:50:03 2011
@@ -4,10 +4,12 @@
typedef unsigned long NSUInteger;
typedef struct _NSZone NSZone;
@protocol NSObject - (BOOL)isEqual:(id)object;
- at end @interface NSObject <NSObject> {
-}
@end
+ at interface NSObject {}
+ @property int locked;
+ @property(nonatomic, readonly) NSObject *media;
+ at end
// <rdar://problem/8725041> - Don't flag idempotent operation warnings when
// a method may invalidate an instance variable.
@@ -32,3 +34,9 @@
}
@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;
+}
+
More information about the cfe-commits
mailing list