Skip to content

Commit

Permalink
added code to suppress remaining else-if related false positives.
Browse files Browse the repository at this point in the history
Created new jar for release
  • Loading branch information
martinschaef committed Sep 10, 2014
1 parent 5700a1c commit c1e6207
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 7 deletions.
Binary file modified jar2bpl/dist/jar2bpl.jar
Binary file not shown.
24 changes: 24 additions & 0 deletions jar2bpl/src/org/joogie/soot/SootBodyTransformer.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,18 @@
import soot.SootMethod;
import soot.Trap;
import soot.Unit;
import soot.Value;
import soot.ValueBox;
import soot.jimple.BinopExpr;
import soot.jimple.GotoStmt;
import soot.jimple.IfStmt;
import soot.jimple.NeExpr;
import soot.jimple.NegExpr;
import soot.jimple.ReturnStmt;
import soot.jimple.StaticFieldRef;
import soot.jimple.Stmt;
import soot.jimple.ThrowStmt;
import soot.jimple.internal.JEqExpr;
import soot.tagkit.LineNumberTag;
import soot.tagkit.SourceLnNamePosTag;
import soot.tagkit.Tag;
Expand Down Expand Up @@ -228,6 +233,13 @@ private HashSet<Stmt> detectDuplicatedFinallyBlocks(Iterator<Unit> stmtIt, SootP
// procInfo.duplicatedIfStatement.add(is2);
procInfo.duplicatedIfStatement.add(is);
break;
} else {
Value nonneg1 = normalizeNegations(is.getCondition());
Value nonneg2 = normalizeNegations(is2.getCondition());
if (nonneg1.equivTo(nonneg2)) {
procInfo.duplicatedIfStatement.add(is2);
procInfo.duplicatedIfStatement.add(is);
}
}
}
ifstmts.add(is);
Expand Down Expand Up @@ -309,6 +321,18 @@ private boolean compareSubprogs(LinkedList<Stmt> p1, LinkedList<Stmt> p2) {
return false;
}

private Value normalizeNegations(Value v) {
if (v instanceof NegExpr) {
return ((NegExpr)v).getOp();
} else if (v instanceof BinopExpr) {
BinopExpr bo = (BinopExpr)v;
if (bo instanceof NeExpr) {
return new JEqExpr(bo.getOp1(), bo.getOp2());
}
}
return v;
}

private boolean shallowCompareStatements(Stmt s1, Stmt s2) {
if (s1.getClass() == s2.getClass()) {
return true;
Expand Down
Binary file modified jar2bpl_test/lib/bixie.jar
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,20 +1,15 @@


public class FalsePositives08 {

Object constraintsLock;
private String[] constraints;
private String constraint;
public void fp01() {
// Add this constraint to the set for our web application
synchronized (constraintsLock) {
String results[] =
new String[constraints.length + 1];
for (int i = 0; i < constraints.length; i++)
results[i] = constraints[i];
for (int i = 0; i < constraints.length; i++);
results[constraints.length] = constraint;
constraints = results;
}

}
}
2 changes: 1 addition & 1 deletion jar2bpl_test/src/jar2bpl_test/JavaTranslationTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class JavaTranslationTest {
@Test
public void testJavaDirectory() {
//TODO: design one test case for each sort of input to the translation.
String base="fp21";
String base="fp18";

String javaFileDir = "regression/false_positives/"+base+"/";
Options.v().setClasspath(javaFileDir);
Expand Down
1 change: 1 addition & 0 deletions jar2bpl_test/test_gold/fp18.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

1 change: 1 addition & 0 deletions jar2bpl_test/test_gold/fp18_class.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

0 comments on commit c1e6207

Please sign in to comment.