Summary: public Functions had unqualified names before. Fix it. Reviewed By: dulmarod Differential Revision: D2668647 fb-gh-sync-id: cfeddeamaster
parent
9748502a1a
commit
cb42fdcc31
@ -0,0 +1,26 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace f1 {
|
||||||
|
int get() { return 1;}
|
||||||
|
int get0() { return 0;}
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace f2 {
|
||||||
|
int get() { return -1;}
|
||||||
|
}
|
||||||
|
|
||||||
|
int div0_using() {
|
||||||
|
using namespace f1;
|
||||||
|
return 1 / get0();
|
||||||
|
}
|
||||||
|
|
||||||
|
int div0_namespace_resolution() {
|
||||||
|
return 1 / (f1::get() + f2::get());
|
||||||
|
}
|
@ -0,0 +1,57 @@
|
|||||||
|
digraph iCFG {
|
||||||
|
15 [label="15: Return Stmt \n n$0=_fun_f1::get() [line 25]\n n$1=_fun_f2::get() [line 25]\n *&return:int =(1 / (n$0 + n$1)) [line 25]\n REMOVE_TEMPS(n$0,n$1); [line 25]\n APPLY_ABSTRACTION; [line 25]\n " shape="box"]
|
||||||
|
|
||||||
|
|
||||||
|
15 -> 14 ;
|
||||||
|
14 [label="14: Exit div0_namespace_resolution \n " color=yellow style=filled]
|
||||||
|
|
||||||
|
|
||||||
|
13 [label="13: Start div0_namespace_resolution\nFormals: \nLocals: \n DECLARE_LOCALS(&return); [line 24]\n " color=yellow style=filled]
|
||||||
|
|
||||||
|
|
||||||
|
13 -> 15 ;
|
||||||
|
12 [label="12: Return Stmt \n n$0=_fun_f1::get0() [line 21]\n *&return:int =(1 / n$0) [line 21]\n REMOVE_TEMPS(n$0); [line 21]\n APPLY_ABSTRACTION; [line 21]\n " shape="box"]
|
||||||
|
|
||||||
|
|
||||||
|
12 -> 11 ;
|
||||||
|
11 [label="11: Exit div0_using \n " color=yellow style=filled]
|
||||||
|
|
||||||
|
|
||||||
|
10 [label="10: Start div0_using\nFormals: \nLocals: \n DECLARE_LOCALS(&return); [line 19]\n " color=yellow style=filled]
|
||||||
|
|
||||||
|
|
||||||
|
10 -> 12 ;
|
||||||
|
9 [label="9: Return Stmt \n *&return:int =-1 [line 16]\n APPLY_ABSTRACTION; [line 16]\n " shape="box"]
|
||||||
|
|
||||||
|
|
||||||
|
9 -> 8 ;
|
||||||
|
8 [label="8: Exit f2::get \n " color=yellow style=filled]
|
||||||
|
|
||||||
|
|
||||||
|
7 [label="7: Start f2::get\nFormals: \nLocals: \n DECLARE_LOCALS(&return); [line 16]\n " color=yellow style=filled]
|
||||||
|
|
||||||
|
|
||||||
|
7 -> 9 ;
|
||||||
|
6 [label="6: Return Stmt \n *&return:int =0 [line 12]\n APPLY_ABSTRACTION; [line 12]\n " shape="box"]
|
||||||
|
|
||||||
|
|
||||||
|
6 -> 5 ;
|
||||||
|
5 [label="5: Exit f1::get0 \n " color=yellow style=filled]
|
||||||
|
|
||||||
|
|
||||||
|
4 [label="4: Start f1::get0\nFormals: \nLocals: \n DECLARE_LOCALS(&return); [line 12]\n " color=yellow style=filled]
|
||||||
|
|
||||||
|
|
||||||
|
4 -> 6 ;
|
||||||
|
3 [label="3: Return Stmt \n *&return:int =1 [line 11]\n APPLY_ABSTRACTION; [line 11]\n " shape="box"]
|
||||||
|
|
||||||
|
|
||||||
|
3 -> 2 ;
|
||||||
|
2 [label="2: Exit f1::get \n " color=yellow style=filled]
|
||||||
|
|
||||||
|
|
||||||
|
1 [label="1: Start f1::get\nFormals: \nLocals: \n DECLARE_LOCALS(&return); [line 11]\n " color=yellow style=filled]
|
||||||
|
|
||||||
|
|
||||||
|
1 -> 3 ;
|
||||||
|
}
|
@ -0,0 +1,64 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package endtoend.cpp;
|
||||||
|
|
||||||
|
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 NamespaceFunctionTest {
|
||||||
|
|
||||||
|
public static final String FILE =
|
||||||
|
"infer/tests/codetoanalyze/cpp/frontend/namespace/function.cpp";
|
||||||
|
|
||||||
|
private static ImmutableList<String> inferCmd;
|
||||||
|
|
||||||
|
public static final String DIVIDE_BY_ZERO = "DIVIDE_BY_ZERO";
|
||||||
|
|
||||||
|
@ClassRule
|
||||||
|
public static DebuggableTemporaryFolder folder =
|
||||||
|
new DebuggableTemporaryFolder();
|
||||||
|
|
||||||
|
@BeforeClass
|
||||||
|
public static void runInfer() throws InterruptedException, IOException {
|
||||||
|
inferCmd = InferRunner.createCPPInferCommand(folder, FILE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void whenInferRunsOnDiv0MethodsErrorIsFound()
|
||||||
|
throws InterruptedException, IOException, InferException {
|
||||||
|
InferResults inferResults = InferRunner.runInferCPP(inferCmd);
|
||||||
|
String[] procedures = {
|
||||||
|
"div0_using",
|
||||||
|
"div0_namespace_resolution",
|
||||||
|
};
|
||||||
|
assertThat(
|
||||||
|
"Results should contain the expected divide by zero",
|
||||||
|
inferResults,
|
||||||
|
containsExactly(
|
||||||
|
DIVIDE_BY_ZERO,
|
||||||
|
FILE,
|
||||||
|
procedures
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in new issue