-no-run-subdirs option.
[self release];
[self retain];
[self autorelease];
[self release]; in an init… method (usual practice during init failure)[[self retain] autorelease]; (usual practice in getters)[self retain]; in a …copy… method (usual practice in copy methods of immutable objects)[self retain]; is followed by [self release]; in the context of the same ObjC method (since 'self' is on the stack, this is GC-safe).XCODEBUILD_PROJECT_FILE_PATH preprocessor definition must be set so that this filtering can be performed.
new and alloc are the most trivial ones - those methods always mean instantiation dependency. The last two conditions may cause some false positives
(i.e. classifying association dependency as instantiation dependency), but based on analysis of our own code, 100% of cases which were found with those patterns were either
real object instantiations or singleton accesses (which are potential instantiation dependencies as well).
typedef enum {
myTypeValue1,
myTypeValue2
} MyType;
typedef enum {
anotherTypeValue1,
anotherTypeValue2
} AnotherType;
MyType val = myTypeValue1; // OK
val = myTypeValue2; // OK
val = 0; // '0' isn't part of definition of MyType (although 'myTypeValue1' evaluates to 0)
val = anotherTypeValue1; // 'anotherTypeValue1' isn't part of definition of MyType
val = (0) ? anotherTypeValue2 : myTypeValue2; // 'anotherTypeValue2' isn't part of definition of MyType
// i is unsigned numerical value
while(i >= 0) // condition is always true
i--;
for(i = 100; i >= 0; i--) // condition is always true
i--;
if(i < 0) // condition is always false
i--;
-DXCODEBUILD_PROJECT_FILE_PATH="$(PROJECT_FILE_PATH)". Note that quotes are important.
-DXCODEBUILD_TARGET_NAME="$(TARGET_NAME)" -DXCODEBUILD_PROJECT_NAME="$(PROJECT_NAME)". Note that quotes are important.
#define MyMacro() if(1) { NSString *myString = nil; }
int main (int argc, const char * argv[]) {
NSString *myString = nil;
MyMacro();
return 0;
}
if(x == 0) {
if(x == 0) {
;
} else {
// May be unreachable, if x is not mutated between first and second if statements.
}
}
- (void)setIvar:(id)newValue
{
if(mIvar != newValue)
{
[mIvar release];
mIvar = newValue;
}
}
- (void)setIvar2:(id)newValue
{
[mIvar release];
mIvar = newValue;
}
- (void)setIvar:(id)newValue
{
if(mIvar != newValue)
{
mIvar = [newValue retain];
}
}
- (void)setIvar2:(id)newValue
{
mIvar = [newValue retain];
}
1. unsigned char c = 999999 & 0xff;
2. unsigned char c = 0; c = c + 255;
3. const int i = 255; unsigned char c = 0; c = c + i;
1. unsigned char c = 999999 & 0xffff;
2. unsigned char c = 0; c = c + 256;
3. const int i = 256; unsigned char c = 0; c = c + i;