[Fb-contrib-commit] SF.net SVN: fb-contrib: [896] trunk/fb-contrib/src/com/mebigfatguy/ fbcontrib/d
Brought to you by:
dbrosius
From: <dbr...@us...> - 2007-06-29 16:54:47
|
Revision: 896 http://svn.sourceforge.net/fb-contrib/?rev=896&view=rev Author: dbrosius Date: 2007-06-29 09:54:46 -0700 (Fri, 29 Jun 2007) Log Message: ----------- better filtering out of conditionals from loops Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UseAddAll.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UseAddAll.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UseAddAll.java 2007-06-29 05:55:41 UTC (rev 895) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UseAddAll.java 2007-06-29 16:54:46 UTC (rev 896) @@ -131,7 +131,7 @@ uValue = (Integer)valueItem.getUserValue(); if (uValue != null) { LoopInfo loop = loops.get(uValue); - if ((loop != null) && loop.isInLoop(getPC())) { + if ((loop != null) && loop.isInLoop(getPC(), false)) { bugReporter.reportBug(new BugInstance(this, "UAA_USE_ADD_ALL", NORMAL_PRIORITY) .addClass(this) .addMethod(this) @@ -151,6 +151,7 @@ || ((seen == ALOAD) || ((seen >= ALOAD_0) && (seen <= ALOAD_3)))) { sawLoad = true; } else if (seen == IFEQ) { + boolean loopFound = false; if (stack.getStackDepth() > 0) { if (getBranchOffset() > 0) { int gotoPos = getBranchTarget() - 3; @@ -166,9 +167,13 @@ if (uValue != null) { loops.put(uValue, new LoopInfo(getPC(), getBranchTarget())); } + loopFound = true; } - } else { - LoopInfo loop = findLoop(getPC()); + } + + if (!loopFound) + { + LoopInfo loop = findLoop(getPC(), true); if (loop != null) { loop.addConditionalRange(getPC(), getBranchTarget()); } @@ -177,7 +182,7 @@ } } else if (((seen > IFEQ) && (seen <= GOTO)) || (seen == IFNULL) || (seen == IFNONNULL)) { if (getBranchOffset() > 0) { - LoopInfo loop = findLoop(getPC()); + LoopInfo loop = findLoop(getPC(), true); if (loop != null) { loop.addConditionalRange(getPC(), getBranchTarget()); } @@ -238,9 +243,9 @@ return -1; } - private LoopInfo findLoop(int pc) { + private LoopInfo findLoop(int pc, boolean ignoreConditionals) { for (LoopInfo loop : loops.values()) { - if (loop.isInLoop(pc)) + if (loop.isInLoop(pc, ignoreConditionals)) return loop; } @@ -264,11 +269,14 @@ conditionalRanges.put(Integer14.valueOf(condStart), Integer14.valueOf(condEnd)); } - public boolean isInLoop(int pc) + public boolean isInLoop(int pc, boolean ignoreConditionals) { if ((pc < start) || (pc > end)) return false; + if (ignoreConditionals) + return true; + for (Map.Entry<Integer, Integer> entry : conditionalRanges.entrySet()) { if ((pc >= entry.getKey().intValue()) && pc <= entry.getValue().intValue()) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |