Summary: @public First diff to give better language information in the frontend. This information is necessary to understand when 'self' is objc keyword, when 'this' is C++ keyword and when they are not. Reviewed By: @ddino, @dulmarod Differential Revision: D2489252master
parent
5e41fc7a54
commit
a045886eba
@ -0,0 +1,23 @@
|
||||
/*
|
||||
* Copyright (c) 2015 - 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.
|
||||
*/
|
||||
|
||||
class A {
|
||||
public:
|
||||
int meth_with_self(int self, int b) {
|
||||
return self + b;
|
||||
}
|
||||
};
|
||||
|
||||
int fun_with_self(int self) {
|
||||
return self;
|
||||
}
|
||||
|
||||
int test(A *a) {
|
||||
return a->meth_with_self(1, 2) + fun_with_self(10);
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
digraph iCFG {
|
||||
9 [label="9: Return Stmt \n n$0=*&a:class A * [line 22]\n n$1=_fun_A_meth_with_self(n$0:class A ,1:int ,2:int ) [line 22]\n n$2=_fun_fun_with_self(10:int ) [line 22]\n *&return:int =(n$1 + n$2) [line 22]\n REMOVE_TEMPS(n$0,n$1,n$2); [line 22]\n NULLIFY(&a,false); [line 22]\n APPLY_ABSTRACTION; [line 22]\n " shape="box"]
|
||||
|
||||
|
||||
9 -> 8 ;
|
||||
8 [label="8: Exit test \n " color=yellow style=filled]
|
||||
|
||||
|
||||
7 [label="7: Start test\nFormals: a:class A *\nLocals: \n DECLARE_LOCALS(&return); [line 21]\n " color=yellow style=filled]
|
||||
|
||||
|
||||
7 -> 9 ;
|
||||
6 [label="6: Return Stmt \n n$0=*&self:int [line 18]\n *&return:int =n$0 [line 18]\n REMOVE_TEMPS(n$0); [line 18]\n NULLIFY(&self,false); [line 18]\n APPLY_ABSTRACTION; [line 18]\n " shape="box"]
|
||||
|
||||
|
||||
6 -> 5 ;
|
||||
5 [label="5: Exit fun_with_self \n " color=yellow style=filled]
|
||||
|
||||
|
||||
4 [label="4: Start fun_with_self\nFormals: self:int \nLocals: \n DECLARE_LOCALS(&return); [line 17]\n " color=yellow style=filled]
|
||||
|
||||
|
||||
4 -> 6 ;
|
||||
3 [label="3: Return Stmt \n n$0=*&self:int [line 13]\n n$1=*&b:int [line 13]\n *&return:int =(n$0 + n$1) [line 13]\n REMOVE_TEMPS(n$0,n$1); [line 13]\n NULLIFY(&b,false); [line 13]\n NULLIFY(&self,false); [line 13]\n APPLY_ABSTRACTION; [line 13]\n " shape="box"]
|
||||
|
||||
|
||||
3 -> 2 ;
|
||||
2 [label="2: Exit A_meth_with_self \n " color=yellow style=filled]
|
||||
|
||||
|
||||
1 [label="1: Start A_meth_with_self\nFormals: this:class A self:int b:int \nLocals: \n DECLARE_LOCALS(&return); [line 12]\n NULLIFY(&this,false); [line 12]\n " color=yellow style=filled]
|
||||
|
||||
|
||||
1 -> 3 ;
|
||||
}
|
@ -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 SelfParameterTest {
|
||||
|
||||
@Rule
|
||||
public DebuggableTemporaryFolder folder = new DebuggableTemporaryFolder();
|
||||
|
||||
@Test
|
||||
public void whenCaptureRunCommaThenDotFilesAreTheSame()
|
||||
throws InterruptedException, IOException, InferException {
|
||||
String src =
|
||||
"infer/tests/codetoanalyze/cpp/frontend/keywords/self_parameter.cpp";
|
||||
|
||||
String dotty =
|
||||
"infer/tests/codetoanalyze/cpp/frontend/keywords/self_parameter.dot";
|
||||
|
||||
ImmutableList<String> inferCmd =
|
||||
InferRunner.createCPPInferCommandFrontend(
|
||||
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