Summary: @public Adding support for NSMakeCollectable and CFMakeCollectable. Fixes issue https://github.com/facebook/infer/issues/116 Test Plan: Tested on the example of the issue https://github.com/facebook/infer/issues/116 and we don't get the leak there anymore.master
parent
9f9bc53361
commit
ea3e614cce
@ -0,0 +1,5 @@
|
|||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
|
||||||
|
CFTypeRef CFMakeCollectable ( CFTypeRef cf ) {
|
||||||
|
return cf;
|
||||||
|
}
|
@ -0,0 +1,19 @@
|
|||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
|
||||||
|
@interface E : NSObject
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation E
|
||||||
|
|
||||||
|
- (CFReadStreamRef) readStream {
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) handleStreamError
|
||||||
|
{
|
||||||
|
NSError *underlyingError = NSMakeCollectable(
|
||||||
|
[(NSError*)CFReadStreamCopyError((CFReadStreamRef)[self readStream]) autorelease]);
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
@ -0,0 +1,62 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2013- Facebook.
|
||||||
|
* All rights reserved.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package endtoend.objc;
|
||||||
|
|
||||||
|
import static org.hamcrest.MatcherAssert.assertThat;
|
||||||
|
import static utils.matchers.ResultContainsExactly.containsExactly;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableList;
|
||||||
|
|
||||||
|
import org.junit.BeforeClass;
|
||||||
|
import org.junit.ClassRule;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import utils.DebuggableTemporaryFolder;
|
||||||
|
import utils.InferException;
|
||||||
|
import utils.InferResults;
|
||||||
|
import utils.InferRunner;
|
||||||
|
|
||||||
|
public class NSMakeCollectableTest {
|
||||||
|
|
||||||
|
public static final String memory_leak_file =
|
||||||
|
"infer/tests/codetoanalyze/objc/errors/memory_leaks_benchmark/NSMakeCollectableExample.m";
|
||||||
|
|
||||||
|
private static ImmutableList<String> inferCmd;
|
||||||
|
|
||||||
|
public static final String MEMORY_LEAK = "MEMORY_LEAK";
|
||||||
|
|
||||||
|
@ClassRule
|
||||||
|
public static DebuggableTemporaryFolder folder =
|
||||||
|
new DebuggableTemporaryFolder();
|
||||||
|
|
||||||
|
@BeforeClass
|
||||||
|
public static void runInfer() throws InterruptedException, IOException {
|
||||||
|
inferCmd = InferRunner.createObjCInferCommandWithMLBuckets(
|
||||||
|
folder,
|
||||||
|
memory_leak_file,
|
||||||
|
"cf",
|
||||||
|
false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void whenInferRunsOnTestWithBucketingThenMLIsNotFound()
|
||||||
|
throws InterruptedException, IOException, InferException {
|
||||||
|
InferResults inferResults = InferRunner.runInferObjC(inferCmd);
|
||||||
|
String[] procedures = {
|
||||||
|
};
|
||||||
|
assertThat(
|
||||||
|
"Results should not contain memory leak",
|
||||||
|
inferResults,
|
||||||
|
containsExactly(
|
||||||
|
MEMORY_LEAK,
|
||||||
|
memory_leak_file,
|
||||||
|
procedures));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in new issue