Summary: In objC we already prefix field names with classes. It's better to make it consistent since it'll allow us to share more code between C++ and objCmaster
parent
2a0cca5cc7
commit
b328ee1509
@ -0,0 +1,10 @@
|
||||
struct X {
|
||||
int a;
|
||||
int b;
|
||||
};
|
||||
|
||||
void test() {
|
||||
X x;
|
||||
x.a = 10;
|
||||
x.b = 20;
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
struct X {
|
||||
int a;
|
||||
int b;
|
||||
};
|
||||
|
||||
void test() {
|
||||
struct X x;
|
||||
x.a = 10;
|
||||
x.b = 20;
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
digraph iCFG {
|
||||
4 [label="4: BinaryOperatorStmt: Assign \n *&x.a:int =10 [line 8]\n " shape="box"]
|
||||
|
||||
|
||||
4 -> 3 ;
|
||||
3 [label="3: BinaryOperatorStmt: Assign \n *&x.b:int =20 [line 9]\n APPLY_ABSTRACTION; [line 9]\n " shape="box"]
|
||||
|
||||
|
||||
3 -> 2 ;
|
||||
2 [label="2: Exit test \n " color=yellow style=filled]
|
||||
|
||||
|
||||
1 [label="1: Start test\nFormals: \nLocals: x:struct X \n DECLARE_LOCALS(&return,&x); [line 6]\n NULLIFY(&x,false); [line 6]\n " color=yellow style=filled]
|
||||
|
||||
|
||||
1 -> 4 ;
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
struct X_struct {
|
||||
int a;
|
||||
int b;
|
||||
};
|
||||
|
||||
class X_class {
|
||||
public:
|
||||
int a;
|
||||
int b;
|
||||
};
|
||||
|
||||
void test() {
|
||||
// use pointers until c++ constructors are translated
|
||||
X_struct *xs;
|
||||
xs->a = 10;
|
||||
xs->b = 20;
|
||||
|
||||
X_class *xc;
|
||||
xc->a = 10;
|
||||
xc->b = 20;
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
digraph iCFG {
|
||||
6 [label="6: BinaryOperatorStmt: Assign \n n$3=*&xs:struct X_struct * [line 15]\n *n$3.a:int =10 [line 15]\n REMOVE_TEMPS(n$3); [line 15]\n " shape="box"]
|
||||
|
||||
|
||||
6 -> 5 ;
|
||||
5 [label="5: BinaryOperatorStmt: Assign \n n$2=*&xs:struct X_struct * [line 16]\n *n$2.b:int =20 [line 16]\n REMOVE_TEMPS(n$2); [line 16]\n NULLIFY(&xs,false); [line 16]\n " shape="box"]
|
||||
|
||||
|
||||
5 -> 4 ;
|
||||
4 [label="4: BinaryOperatorStmt: Assign \n n$1=*&xc:class X_class * [line 19]\n *n$1.a:int =10 [line 19]\n REMOVE_TEMPS(n$1); [line 19]\n " shape="box"]
|
||||
|
||||
|
||||
4 -> 3 ;
|
||||
3 [label="3: BinaryOperatorStmt: Assign \n n$0=*&xc:class X_class * [line 20]\n *n$0.b:int =20 [line 20]\n REMOVE_TEMPS(n$0); [line 20]\n NULLIFY(&xc,false); [line 20]\n APPLY_ABSTRACTION; [line 20]\n " shape="box"]
|
||||
|
||||
|
||||
3 -> 2 ;
|
||||
2 [label="2: Exit test \n " color=yellow style=filled]
|
||||
|
||||
|
||||
1 [label="1: Start test\nFormals: \nLocals: xs:struct X_struct * xc:class X_class * \n DECLARE_LOCALS(&return,&xs,&xc); [line 12]\n " color=yellow style=filled]
|
||||
|
||||
|
||||
1 -> 6 ;
|
||||
}
|
@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright (c) 2013 - present Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
|
||||
package frontend.c;
|
||||
|
||||
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 TypesTest {
|
||||
|
||||
@Rule
|
||||
public DebuggableTemporaryFolder folder = new DebuggableTemporaryFolder();
|
||||
|
||||
@Test
|
||||
public void whenCaptureRunStructThenDotFilesAreTheSame()
|
||||
throws InterruptedException, IOException, InferException {
|
||||
String switch_src =
|
||||
"infer/tests/codetoanalyze/c/frontend/types/struct.c";
|
||||
|
||||
String switch_dotty =
|
||||
"infer/tests/codetoanalyze/c/frontend/types/struct.dot";
|
||||
|
||||
ImmutableList<String> inferCmd =
|
||||
InferRunner.createCInferCommandFrontend(folder, switch_src);
|
||||
File newDotFile = InferRunner.runInferFrontend(inferCmd);
|
||||
assertThat(
|
||||
"In the capture of " + switch_src +
|
||||
" the dotty files should be the same.",
|
||||
newDotFile, dotFileEqualTo(switch_dotty));
|
||||
}
|
||||
}
|
@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright (c) 2013 - present Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
|
||||
package frontend.cpp;
|
||||
|
||||
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 ClassTest {
|
||||
|
||||
@Rule
|
||||
public DebuggableTemporaryFolder folder = new DebuggableTemporaryFolder();
|
||||
|
||||
@Test
|
||||
public void whenCaptureRunCommaThenDotFilesAreTheSame()
|
||||
throws InterruptedException, IOException, InferException {
|
||||
String literal_src =
|
||||
"infer/tests/codetoanalyze/cpp/frontend/types/struct.cpp";
|
||||
|
||||
String literal_dotty =
|
||||
"infer/tests/codetoanalyze/cpp/frontend/types/struct.dot";
|
||||
|
||||
ImmutableList<String> inferCmd =
|
||||
InferRunner.createCPPInferCommandFrontend(
|
||||
folder,
|
||||
literal_src);
|
||||
File newDotFile = InferRunner.runInferFrontend(inferCmd);
|
||||
assertThat(
|
||||
"In the capture of " + literal_src +
|
||||
" the dotty files should be the same.",
|
||||
newDotFile, dotFileEqualTo(literal_dotty));
|
||||
}
|
||||
}
|
Loading…
Reference in new issue