[Fb-contrib-commit] SF.net SVN: fb-contrib:[1616] trunk/fb-contrib
Brought to you by:
dbrosius
|
From: <dbr...@us...> - 2010-09-19 04:53:18
|
Revision: 1616
http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1616&view=rev
Author: dbrosius
Date: 2010-09-19 04:53:11 +0000 (Sun, 19 Sep 2010)
Log Message:
-----------
suppress fp's with self modification --> if (a != null) a = a.trim();
Modified Paths:
--------------
trunk/fb-contrib/samples/SNG_Sample.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousNullGuard.java
Modified: trunk/fb-contrib/samples/SNG_Sample.java
===================================================================
--- trunk/fb-contrib/samples/SNG_Sample.java 2010-09-19 03:37:29 UTC (rev 1615)
+++ trunk/fb-contrib/samples/SNG_Sample.java 2010-09-19 04:53:11 UTC (rev 1616)
@@ -36,4 +36,16 @@
s1 = null;
}
}
+
+ public void fpSelfAdjustingLocal(String s) {
+ if (s != null) {
+ s = s.trim();
+ }
+ }
+
+ public void fpSelfAdjustingField() {
+ if (f1 != null) {
+ f1 = f1.toString();
+ }
+ }
}
Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousNullGuard.java
===================================================================
--- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousNullGuard.java 2010-09-19 03:37:29 UTC (rev 1615)
+++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousNullGuard.java 2010-09-19 04:53:11 UTC (rev 1616)
@@ -19,6 +19,7 @@
package com.mebigfatguy.fbcontrib.detect;
import java.util.HashMap;
+import java.util.Iterator;
import java.util.Map;
import org.apache.bcel.classfile.Code;
@@ -123,13 +124,25 @@
.addClass(this)
.addMethod(this)
.addSourceLine(this));
- nullGuards.remove(guard);
+ removeNullGuard(guard);
}
}
}
}
break;
+ case ALOAD:
+ case ALOAD_0:
+ case ALOAD_1:
+ case ALOAD_2:
+ case ALOAD_3: {
+ NullGuard guard = findNullGuardWithRegister(RegisterUtils.getALoadReg(this, seen));
+ if (guard != null) {
+ removeNullGuard(guard);
+ }
+ }
+ break;
+
case PUTFIELD: {
if (stack.getStackDepth() > 1) {
OpcodeStack.Item item = stack.getStackItem(0);
@@ -142,13 +155,26 @@
.addClass(this)
.addMethod(this)
.addSourceLine(this));
- nullGuards.remove(guard);
+ removeNullGuard(guard);
}
}
}
}
}
break;
+
+ case GETFIELD: {
+ if (stack.getStackDepth() > 0) {
+ XField xf = getXFieldOperand();
+ if (xf != null) {
+ NullGuard guard = findNullGuardWithField(xf);
+ if (guard != null) {
+ removeNullGuard(guard);
+ }
+ }
+ }
+ }
+ break;
case IFEQ:
case IFNE:
@@ -195,6 +221,17 @@
return null;
}
+ private void removeNullGuard(NullGuard guard) {
+ Iterator<NullGuard> it = nullGuards.values().iterator();
+ while (it.hasNext()) {
+ NullGuard potentialNG = it.next();
+ if (potentialNG.equals(guard)) {
+ it.remove();
+ break;
+ }
+ }
+ }
+
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.
|