[Fb-contrib-commit] SF.net SVN: fb-contrib:[1612] trunk/fb-contrib
Brought to you by:
dbrosius
|
From: <dbr...@us...> - 2010-09-13 05:15:28
|
Revision: 1612
http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1612&view=rev
Author: dbrosius
Date: 2010-09-13 05:15:21 +0000 (Mon, 13 Sep 2010)
Log Message:
-----------
attempt to reduce FP on SNG by removing compound conditionals
Modified Paths:
--------------
trunk/fb-contrib/etc/findbugs.xml
trunk/fb-contrib/samples/SNG_Sample.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousNullGuard.java
Modified: trunk/fb-contrib/etc/findbugs.xml
===================================================================
--- trunk/fb-contrib/etc/findbugs.xml 2010-09-13 02:00:34 UTC (rev 1611)
+++ trunk/fb-contrib/etc/findbugs.xml 2010-09-13 05:15:21 UTC (rev 1612)
@@ -195,7 +195,9 @@
<!-- <Detector class="com.mebigfatguy.fbcontrib.detect.ContraVariantArrayAssignment" speed="fast" hidden="true" reports="CVAA_CONTRAVARIANT_ARRAY_ASSIGNMENT,CVAA_CONTRAVARIANT_ELEMENT_ASSIGNMENT" /> -->
<Detector class="com.mebigfatguy.fbcontrib.detect.NonFunctionalField" speed="fast" reports="NFF_NON_FUNCTIONAL_FIELD" />
- <!-- <Detector class="com.mebigfatguy.fbcontrib.detect.SuspiciousNullGuard" speed="fast" reports="SNG_SUSPICIOUS_NULL_FIELD_GUARD,SNG_SUSPICIOUS_NULL_LOCAL_GUARD" />-->
+
+ <Detector class="com.mebigfatguy.fbcontrib.detect.SuspiciousNullGuard" speed="fast" reports="SNG_SUSPICIOUS_NULL_FIELD_GUARD,SNG_SUSPICIOUS_NULL_LOCAL_GUARD" />
+
<Detector class="com.mebigfatguy.fbcontrib.detect.MoreDumbMethods" speed="fast"
reports="MDM_RUNTIME_EXIT_OR_HALT,MDM_RUNFINALIZATION,MDM_BIGDECIMAL_EQUALS,MDM_INETADDRESS_GETLOCALHOST,MDM_PROMISCUOUS_SERVERSOCKET,MDM_RANDOM_SEED,MDM_SECURERANDOM_CTOR,MDM_SECURERANDOM_GETSEED,MDM_THREAD_PRIORITIES,MDM_THREAD_YIELD,MDM_WAIT_WITHOUT_TIMEOUT,MDM_THREAD_FAIRNESS,MDM_REENTRANTLOCK_HELDBY,MDM_STRING_BYTES_ENCODING,MDM_SETDEFAULTLOCALE" />
Modified: trunk/fb-contrib/samples/SNG_Sample.java
===================================================================
--- trunk/fb-contrib/samples/SNG_Sample.java 2010-09-13 02:00:34 UTC (rev 1611)
+++ trunk/fb-contrib/samples/SNG_Sample.java 2010-09-13 05:15:21 UTC (rev 1612)
@@ -99,4 +99,12 @@
f1 = f2;
}
}
+
+ public void fpDup()
+ {
+ if ((f1 == null) || file.isDirectory())
+ {
+ f1 = file.getPath();
+ }
+ }
}
Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousNullGuard.java
===================================================================
--- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousNullGuard.java 2010-09-13 02:00:34 UTC (rev 1611)
+++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousNullGuard.java 2010-09-13 05:15:21 UTC (rev 1612)
@@ -44,7 +44,7 @@
*/
public class SuspiciousNullGuard extends BytecodeScanningDetector {
- private BugReporter bugReporter;
+ private final BugReporter bugReporter;
private OpcodeStack stack;
private LocalVariableTable lvt;
private Map<Integer, NullGuard> nullGuards;
@@ -126,6 +126,24 @@
}
break;
+ case IFEQ:
+ case IFNE:
+ case IFLE:
+ case IFGE:
+ case IFGT:
+ case IFLT:
+ case IF_ICMPEQ:
+ case IF_ICMPNE:
+ case IF_ICMPGT:
+ case IF_ICMPLE:
+ case IF_ACMPEQ:
+ case IF_ACMPNE: {
+ int target = getBranchTarget();
+ removeGuardsBeforePC(target);
+ }
+ break;
+
+
case ALOAD:
case ALOAD_0:
case ALOAD_1:
@@ -193,8 +211,9 @@
removeGuardForRegister(reg);
} else {
XField field = item.getXField();
- if (field != null)
+ if (field != null) {
removeGuardForField(field);
+ }
}
}
}
@@ -230,6 +249,16 @@
}
}
+ private void removeGuardsBeforePC(int pc) {
+ Iterator<Integer> it = nullGuards.keySet().iterator();
+ while (it.hasNext()) {
+ Integer nullGuardPC = it.next();
+ if (pc > nullGuardPC) {
+ it.remove();
+ }
+ }
+ }
+
static class NullGuard {
int register;
XField field;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|