[Fb-contrib-commit] SF.net SVN: fb-contrib: [416] trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/det
Brought to you by:
dbrosius
From: <dbr...@us...> - 2006-04-08 14:25:09
|
Revision: 416 Author: dbrosius Date: 2006-04-08 07:24:57 -0700 (Sat, 08 Apr 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=416&view=rev Log Message: ----------- only check methods that actually return a value Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnnecessaryStoreBeforeReturn.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnnecessaryStoreBeforeReturn.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnnecessaryStoreBeforeReturn.java 2006-04-08 14:19:15 UTC (rev 415) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnnecessaryStoreBeforeReturn.java 2006-04-08 14:24:57 UTC (rev 416) @@ -21,7 +21,9 @@ import java.util.HashSet; import java.util.Set; +import org.apache.bcel.classfile.Code; import org.apache.bcel.classfile.Method; +import org.apache.bcel.generic.Type; import edu.umd.cs.findbugs.BugInstance; import edu.umd.cs.findbugs.BugReporter; @@ -82,12 +84,29 @@ return super.clone(); } + /** + * implements the visitor to make sure method returns a value, and then clears the targets + * + * @param obj the context object of the currently parsed code block + */ @Override - public void visitMethod(Method obj) { - state = SEEN_NOTHING; - branchTargets.clear(); + public void visitCode(Code obj) { + Method m = getMethod(); + String sig = m.getSignature(); + Type t = Type.getReturnType(sig); + if (!t.equals(Type.VOID)) { + state = SEEN_NOTHING; + branchTargets.clear(); + super.visitCode(obj); + } } + /** + * implements the visitor to look for store of registers immediately before returns + * of that register + * + * @param seen the opcode of the currently parsed instruction + */ @Override public void sawOpcode(int seen) { int loadReg; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |