aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/StaticAnalyzer/Checkers/DirectIvarAssignment.cpp2
-rw-r--r--test/Analysis/objc-properties.m20
2 files changed, 20 insertions, 2 deletions
diff --git a/lib/StaticAnalyzer/Checkers/DirectIvarAssignment.cpp b/lib/StaticAnalyzer/Checkers/DirectIvarAssignment.cpp
index 8646829548..dc90b67e20 100644
--- a/lib/StaticAnalyzer/Checkers/DirectIvarAssignment.cpp
+++ b/lib/StaticAnalyzer/Checkers/DirectIvarAssignment.cpp
@@ -122,6 +122,8 @@ void DirectIvarAssignment::checkASTDecl(const ObjCImplementationDecl *D,
// initialization based on their name.
if (M->getMethodFamily() == OMF_init ||
M->getMethodFamily() == OMF_dealloc ||
+ M->getMethodFamily() == OMF_copy ||
+ M->getMethodFamily() == OMF_mutableCopy ||
M->getSelector().getNameForSlot(0).find("init") != StringRef::npos ||
M->getSelector().getNameForSlot(0).find("Init") != StringRef::npos)
continue;
diff --git a/test/Analysis/objc-properties.m b/test/Analysis/objc-properties.m
index 2311ef2437..87ab7f7163 100644
--- a/test/Analysis/objc-properties.m
+++ b/test/Analysis/objc-properties.m
@@ -1,8 +1,18 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=alpha.osx.cocoa.DirectIvarAssignment -fobjc-default-synthesize-properties -Wno-objc-root-class -verify -fblocks %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=alpha.osx.cocoa.DirectIvarAssignment -fobjc-default-synthesize-properties -verify -fblocks %s
+
+typedef signed char BOOL;
+@protocol NSObject - (BOOL)isEqual:(id)object; @end
+@interface NSObject <NSObject> {}
++(id)alloc;
+-(id)init;
+-(id)autorelease;
+-(id)copy;
+-(id)retain;
+@end
@interface MyClass;
@end
-@interface TestProperty {
+@interface TestProperty :NSObject {
MyClass *_Z;
id _nonSynth;
}
@@ -29,6 +39,12 @@
return self;
}
+ - (id) copyWithPtrY: (TestProperty*) value {
+ TestProperty *another = [[TestProperty alloc] init];
+ another->_Y = value->_Y; // no-warning
+ return another;
+ }
+
- (id) myInitWithPtr: (MyClass*) value {
_Y = value; // no-warning
return self;