forked from facebook/infer
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[topl] A test for comparing arguments.
Summary: This is the kind of property for which the previous syntax forced one to use spurious registers. Reviewed By: ngorogiannis Differential Revision: D20118863 fbshipit-source-id: b49740d33
- Loading branch information
1 parent
14aee52
commit 0fc2769
Showing
5 changed files
with
50 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
infer/tests/codetoanalyze/java/topl/compareArgs/CompareArgs.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* Copyright (c) Facebook, Inc. and its affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
class CompareArgs { | ||
static int max(int[] a, int i, int k) { | ||
int m = a[i]; | ||
for (int j = i + 1; j < k; ++j) { | ||
m = Math.max(m, a[j]); | ||
} | ||
return m; | ||
} | ||
|
||
static void aBad() { | ||
int[] a = new int[10]; | ||
int x = max(a, 2, 2); | ||
} | ||
|
||
static void bOk() { | ||
int[] a = new int[10]; | ||
int x = max(a, 2, 3); | ||
} | ||
|
||
static void cBad() { | ||
int[] a = new int[10]; | ||
int x = max(a, 2, 1); | ||
} | ||
} |
4 changes: 4 additions & 0 deletions
4
infer/tests/codetoanalyze/java/topl/compareArgs/CompareArgs.topl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
property MaxArgs | ||
nondet (start) | ||
start -> start: * | ||
start -> error: "CompareArgs.max"(Ignore, I, J, IgnoreRet) when I >= J |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Copyright (c) Facebook, Inc. and its affiliates. | ||
# | ||
# This source code is licensed under the MIT license found in the | ||
# LICENSE file in the root directory of this source tree. | ||
|
||
TESTS_DIR = ../../../.. | ||
|
||
INFER_OPTIONS = --seconds-per-iteration 10 --symops-per-iteration 4000 --topl-properties CompareArgs.topl --biabduction-only | ||
INFERPRINT_OPTIONS = --issues-tests | ||
|
||
SOURCES = $(wildcard *.java) | ||
|
||
include $(TESTS_DIR)/javac.make |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
codetoanalyze/java/topl/compareArgs/CompareArgs.java, CompareArgs.aBad():void, 0, TOPL_ERROR, no_bucket, ERROR, [] | ||
codetoanalyze/java/topl/compareArgs/CompareArgs.java, CompareArgs.cBad():void, 0, TOPL_ERROR, no_bucket, ERROR, [] |