[Fb-contrib-commit] SF.net SVN: fb-contrib: [937] trunk/fb-contrib
Brought to you by:
dbrosius
From: <dbr...@us...> - 2007-10-13 05:18:22
|
Revision: 937 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=937&view=rev Author: dbrosius Date: 2007-10-12 22:18:24 -0700 (Fri, 12 Oct 2007) Log Message: ----------- if the ICONST_1 statement is the target of a seemingly unrelated branch, it is probably caused by compiler emitted code, so don't report. Modified Paths: -------------- trunk/fb-contrib/samples/SPP_Sample.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java Modified: trunk/fb-contrib/samples/SPP_Sample.java =================================================================== --- trunk/fb-contrib/samples/SPP_Sample.java 2007-10-13 04:49:06 UTC (rev 936) +++ trunk/fb-contrib/samples/SPP_Sample.java 2007-10-13 05:18:24 UTC (rev 937) @@ -83,4 +83,9 @@ { return (b ? true : false); } + + public boolean testFPUselessTrinary(boolean a, boolean b) + { + return a || b; + } } Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java 2007-10-13 04:49:06 UTC (rev 936) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java 2007-10-13 05:18:24 UTC (rev 937) @@ -19,6 +19,8 @@ package com.mebigfatguy.fbcontrib.detect; import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; import org.apache.bcel.Repository; import org.apache.bcel.classfile.Code; @@ -43,6 +45,7 @@ private int lastPCs[]; private int lastOpcode; private int lastReg; + private Set<Integer> branchTargets; /** * constructs a SPP detector given the reporter to report bugs on @@ -57,10 +60,12 @@ try { stack = new OpcodeStack(); lastPCs = new int[4]; + branchTargets = new HashSet<Integer>(); super.visitClassContext(classContext); } finally { stack = null; lastPCs = null; + branchTargets = null; } } @@ -75,6 +80,7 @@ lastOpcode = -1; lastReg = -1; Arrays.fill(lastPCs, -1); + branchTargets.clear(); super.visitCode(obj); } @@ -90,9 +96,15 @@ try { stack.mergeJumps(this); + if ((seen >= IFEQ) && (seen <= GOTO)) { + branchTargets.add(Integer.valueOf(getBranchTarget())); + } + + if (seen == ICONST_0) { byte[] bytes = getCode().getCode(); if ((lastPCs[3] != -1) + && (!branchTargets.contains(Integer.valueOf(lastPCs[2]))) && ((0x00FF & bytes[lastPCs[3]]) == GOTO) && ((0x00FF & bytes[lastPCs[2]]) == ICONST_1) && ((0x00FF & bytes[lastPCs[1]]) == IFEQ)) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |