forked from OSchip/llvm-project
Teach the IdempotentOperations checker to ignore property setters.
llvm-svn: 125443
This commit is contained in:
parent
210ce0feb5
commit
c059798756
|
|
@ -357,8 +357,15 @@ void IdempotentOperationChecker::PostVisitBinaryOperator(
|
||||||
const BinaryOperator *B) {
|
const BinaryOperator *B) {
|
||||||
// Add the ExplodedNode we just visited
|
// Add the ExplodedNode we just visited
|
||||||
BinaryOperatorData &Data = hash[B];
|
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());
|
Data.explodedNodes.Add(C.getPredecessor());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,10 +4,12 @@ typedef signed char BOOL;
|
||||||
typedef unsigned long NSUInteger;
|
typedef unsigned long NSUInteger;
|
||||||
typedef struct _NSZone NSZone;
|
typedef struct _NSZone NSZone;
|
||||||
@protocol NSObject - (BOOL)isEqual:(id)object;
|
@protocol NSObject - (BOOL)isEqual:(id)object;
|
||||||
@end @interface NSObject <NSObject> {
|
|
||||||
}
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
@interface NSObject {}
|
||||||
|
@property int locked;
|
||||||
|
@property(nonatomic, readonly) NSObject *media;
|
||||||
|
@end
|
||||||
|
|
||||||
// <rdar://problem/8725041> - Don't flag idempotent operation warnings when
|
// <rdar://problem/8725041> - Don't flag idempotent operation warnings when
|
||||||
// a method may invalidate an instance variable.
|
// a method may invalidate an instance variable.
|
||||||
|
|
@ -32,3 +34,9 @@ typedef struct _NSZone NSZone;
|
||||||
}
|
}
|
||||||
@end
|
@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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue