parent
a87bedb5dd
commit
d15e60ffbf
@ -0,0 +1,77 @@
|
||||
digraph iCFG {
|
||||
20 [label="20: Call _fun___infer_assume \n n$20=*&callback:_fn_ (*) [line 42]\n n$21=_fun___infer_assume((n$20 != 0):_fn_ (*)) [line 42]\n REMOVE_TEMPS(n$20,n$21); [line 42]\n " shape="box"]
|
||||
|
||||
|
||||
20 -> 19 ;
|
||||
19 [label="19: Call n$19 \n n$19=*&callback:_fn_ (*) [line 43]\n n$19(0:class NSError *,0:id *) [line 43]\n REMOVE_TEMPS(n$19); [line 43]\n NULLIFY(&callback,false); [line 43]\n APPLY_ABSTRACTION; [line 43]\n " shape="box"]
|
||||
|
||||
|
||||
19 -> 18 ;
|
||||
18 [label="18: Exit test \n " color=yellow style=filled]
|
||||
|
||||
|
||||
17 [label="17: Start test\nFormals: callback:_fn_ (*)\nLocals: \n DECLARE_LOCALS(&return); [line 42]\n " color=yellow style=filled]
|
||||
|
||||
|
||||
17 -> 20 ;
|
||||
16 [label="16: Call _fun___infer_assume \n n$17=*&name:class NSString * [line -1]\n n$18=_fun___infer_assume((n$17 != 0):class NSString *) [line -1]\n REMOVE_TEMPS(n$17,n$18); [line -1]\n " shape="box"]
|
||||
|
||||
|
||||
16 -> 15 ;
|
||||
15 [label="15: BinaryOperatorStmt: Assign \n n$14=*&self:class C * [line 27]\n n$16=*&name:class NSString * [line -1]\n n$15=_fun_NSString_copy(n$16:class NSString *) virtual [line -1]\n *n$14._name:class NSString *=n$15 [line -1]\n REMOVE_TEMPS(n$14,n$15,n$16); [line -1]\n NULLIFY(&name,false); [line -1]\n NULLIFY(&self,false); [line -1]\n APPLY_ABSTRACTION; [line -1]\n " shape="box"]
|
||||
|
||||
|
||||
15 -> 14 ;
|
||||
14 [label="14: Exit C_setName: \n " color=yellow style=filled]
|
||||
|
||||
|
||||
13 [label="13: Start C_setName:\nFormals: self:class C * name:class NSString *\nLocals: \n DECLARE_LOCALS(&return); [line -1]\n " color=yellow style=filled]
|
||||
|
||||
|
||||
13 -> 16 ;
|
||||
12 [label="12: Return Stmt \n n$11=*&self:class C * [line -1]\n n$12=*n$11._name:class NSString * [line -1]\n *&return:class NSString *=n$12 [line -1]\n n$13=_fun___set_autorelease_attribute(n$12:class NSString *) [line -1]\n REMOVE_TEMPS(n$11,n$12,n$13); [line -1]\n NULLIFY(&self,false); [line -1]\n APPLY_ABSTRACTION; [line -1]\n " shape="box"]
|
||||
|
||||
|
||||
12 -> 11 ;
|
||||
11 [label="11: Exit C_name \n " color=yellow style=filled]
|
||||
|
||||
|
||||
10 [label="10: Start C_name\nFormals: self:class C *\nLocals: \n DECLARE_LOCALS(&return); [line -1]\n " color=yellow style=filled]
|
||||
|
||||
|
||||
10 -> 12 ;
|
||||
9 [label="9: Call _fun___infer_assume \n n$9=*&a:class A * [line -1]\n n$10=_fun___infer_assume((n$9 != 0):class A *) [line -1]\n REMOVE_TEMPS(n$9,n$10); [line -1]\n " shape="box"]
|
||||
|
||||
|
||||
9 -> 8 ;
|
||||
8 [label="8: DeclStmt \n n$8=*&a:class A * [line 35]\n n$7=_fun_A_getA(n$8:class A *) virtual [line 35]\n _fun___objc_retain(n$7:class A *) [line 35]\n *&a1:class A *=n$7 [line 35]\n REMOVE_TEMPS(n$7,n$8); [line 35]\n NULLIFY(&a,false); [line 35]\n " shape="box"]
|
||||
|
||||
|
||||
8 -> 7 ;
|
||||
7 [label="7: DeclStmt \n n$5=*&a1:class A * [line 36]\n n$6=*n$5.x:int [line 36]\n *&y:int =n$6 [line 36]\n REMOVE_TEMPS(n$5,n$6); [line 36]\n NULLIFY(&a1,false); [line 36]\n NULLIFY(&y,false); [line 36]\n " shape="box"]
|
||||
|
||||
|
||||
7 -> 6 ;
|
||||
6 [label="6: Return Stmt \n n$4=*&self:class C * [line 37]\n *&return:struct objc_object *=n$4 [line 37]\n REMOVE_TEMPS(n$4); [line 37]\n NULLIFY(&self,false); [line 37]\n APPLY_ABSTRACTION; [line 37]\n " shape="box"]
|
||||
|
||||
|
||||
6 -> 5 ;
|
||||
5 [label="5: Exit C_initWithCoder:and: \n " color=yellow style=filled]
|
||||
|
||||
|
||||
4 [label="4: Start C_initWithCoder:and:\nFormals: self:class C * aDecoder:class NSString * a:class A *\nLocals: a1:class A * y:int \n DECLARE_LOCALS(&return,&a1,&y); [line 33]\n NULLIFY(&a1,false); [line 33]\n NULLIFY(&aDecoder,false); [line 33]\n NULLIFY(&y,false); [line 33]\n " color=yellow style=filled]
|
||||
|
||||
|
||||
4 -> 9 ;
|
||||
3 [label="3: Return Stmt \n n$1=_fun___objc_alloc_no_fail(sizeof(class A ):class A *) [line 21]\n n$2=_fun_A_init(n$1:class A *) virtual [line 21]\n *&return:class A *=n$2 [line 21]\n n$3=_fun___set_autorelease_attribute(n$2:class A *) [line 21]\n REMOVE_TEMPS(n$1,n$2,n$3); [line 21]\n APPLY_ABSTRACTION; [line 21]\n " shape="box"]
|
||||
|
||||
|
||||
3 -> 2 ;
|
||||
2 [label="2: Exit A_getA \n " color=yellow style=filled]
|
||||
|
||||
|
||||
1 [label="1: Start A_getA\nFormals: self:class A *\nLocals: \n DECLARE_LOCALS(&return); [line 20]\n NULLIFY(&self,false); [line 20]\n " color=yellow style=filled]
|
||||
|
||||
|
||||
1 -> 3 ;
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright (c) 2015 - Facebook.
|
||||
* All rights reserved.
|
||||
*/
|
||||
|
||||
#import <Foundation/NSString.h>
|
||||
|
||||
void __infer_assume(int cond);
|
||||
|
||||
@interface A : NSObject {
|
||||
@public int x;
|
||||
}
|
||||
|
||||
-(A*) getA;
|
||||
|
||||
@end
|
||||
|
||||
@implementation A
|
||||
|
||||
-(A*) getA {
|
||||
return [A new];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@interface C : NSObject
|
||||
@property (copy, nonnull) NSString *name;
|
||||
|
||||
@end
|
||||
|
||||
@implementation C
|
||||
|
||||
- (instancetype)initWithCoder:(NSString*)aDecoder and:( A* __nonnull)a
|
||||
{
|
||||
A* a1 = [a getA];
|
||||
int y = a1->x;
|
||||
return self;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
void test(void (^ __nonnull callback)(NSError *, id)) {
|
||||
callback(NULL, NULL);
|
||||
}
|
@ -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 static utils.matchers.ResultContainsNoErrorInMethod.doesNotContain;
|
||||
|
||||
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 NonnullAttributeTest {
|
||||
|
||||
public static final String NONNULL_FILE =
|
||||
"infer/tests/codetoanalyze/objc/errors/npe/Nonnull_attribute_example.m";
|
||||
|
||||
private static ImmutableList<String> inferCmdNil;
|
||||
|
||||
public static final String PARAMETER_NOT_NULL_CHECKED = "PARAMETER_NOT_NULL_CHECKED";
|
||||
|
||||
|
||||
@ClassRule
|
||||
public static DebuggableTemporaryFolder folderNil = new DebuggableTemporaryFolder();
|
||||
|
||||
@BeforeClass
|
||||
public static void runInfer() throws InterruptedException, IOException {
|
||||
inferCmdNil = InferRunner.createiOSInferCommandWithMLBuckets(
|
||||
folderNil,
|
||||
NONNULL_FILE,
|
||||
"cf",
|
||||
false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void angelismTest() throws InterruptedException, IOException, InferException {
|
||||
InferResults inferResults = InferRunner.runInferObjC(inferCmdNil);
|
||||
String[] procedures = {};
|
||||
assertThat(
|
||||
"Results should not contain parameter not null checked",
|
||||
inferResults,
|
||||
containsExactly(
|
||||
PARAMETER_NOT_NULL_CHECKED,
|
||||
NONNULL_FILE,
|
||||
procedures
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright (c) 2014- Facebook.
|
||||
* All rights reserved.
|
||||
*/
|
||||
|
||||
package frontend.objc;
|
||||
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static utils.matchers.DotFilesEqual.dotFileEqualTo;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import utils.DebuggableTemporaryFolder;
|
||||
import utils.InferException;
|
||||
import utils.InferRunner;
|
||||
|
||||
|
||||
public class NonnullAttributeTest {
|
||||
|
||||
@Rule
|
||||
public DebuggableTemporaryFolder folder = new DebuggableTemporaryFolder();
|
||||
|
||||
|
||||
@Test
|
||||
public void whenCaptureRunOnNonnullAttributeExampleThenDotFilesAreTheSame()
|
||||
throws InterruptedException, IOException, InferException {
|
||||
|
||||
String src = "infer/tests/codetoanalyze/objc/errors/npe/Nonnull_attribute_example.m";
|
||||
|
||||
String dotty = "infer/tests/codetoanalyze/objc/errors/npe/Nonnull_attribute_example.dot";
|
||||
|
||||
ImmutableList<String> inferCmd = InferRunner.createObjCInferCommandFrontendArc(folder, src);
|
||||
File newDotFile = InferRunner.runInferFrontend(inferCmd);
|
||||
assertThat(
|
||||
"In the capture of " + src + " the dotty files should be the same.",
|
||||
newDotFile, dotFileEqualTo(dotty));
|
||||
}
|
||||
}
|
Loading…
Reference in new issue