bug fix for previous bug fix

git-svn-id: https://wala.svn.sourceforge.net/svnroot/wala/trunk@2570 f5eafffb-2e1d-0410-98e4-8ec43c5233c4
This commit is contained in:
sjfink 2008-02-13 00:09:46 +00:00
parent 2904150420
commit a3ac4d3a45
1 changed files with 15 additions and 21 deletions

View File

@ -70,7 +70,7 @@ public class ShrikeCFG extends AbstractCFG<ShrikeCFG.BasicBlock> {
init(); init();
computeI2BMapping(); computeI2BMapping();
computeEdges(); computeEdges();
if (DEBUG) { if (DEBUG) {
System.err.println(this); System.err.println(this);
} }
@ -97,8 +97,7 @@ public class ShrikeCFG extends AbstractCFG<ShrikeCFG.BasicBlock> {
} }
/** /**
* Compute a mapping from instruction to basic block. Also, compute the blocks * Compute a mapping from instruction to basic block. Also, compute the blocks that end with a 'normal' return.
* that end with a 'normal' return.
*/ */
private void computeI2BMapping() { private void computeI2BMapping() {
instruction2Block = new int[getInstructions().length]; instruction2Block = new int[getInstructions().length];
@ -207,8 +206,7 @@ public class ShrikeCFG extends AbstractCFG<ShrikeCFG.BasicBlock> {
} }
/** /**
* Return an instruction's basic block in the CFG given the index of the * Return an instruction's basic block in the CFG given the index of the instruction in the CFG's instruction array.
* instruction in the CFG's instruction array.
*/ */
public BasicBlock getBlockForInstruction(int index) { public BasicBlock getBlockForInstruction(int index) {
return getNode(instruction2Block[index]); return getNode(instruction2Block[index]);
@ -253,11 +251,9 @@ public class ShrikeCFG extends AbstractCFG<ShrikeCFG.BasicBlock> {
} }
/** /**
* Add any exceptional edges generated by the last instruction in a basic * Add any exceptional edges generated by the last instruction in a basic block.
* block.
* *
* @param last * @param last the last instruction in a basic block.
* the last instruction in a basic block.
*/ */
private void addExceptionalEdges(Instruction last) { private void addExceptionalEdges(Instruction last) {
IClassHierarchy cha = getMethod().getClassHierarchy(); IClassHierarchy cha = getMethod().getClassHierarchy();
@ -307,6 +303,9 @@ public class ShrikeCFG extends AbstractCFG<ShrikeCFG.BasicBlock> {
if (hs[j].getCatchClass() != null) { if (hs[j].getCatchClass() != null) {
ClassLoaderReference loader = ShrikeCFG.this.getMethod().getDeclaringClass().getReference().getClassLoader(); ClassLoaderReference loader = ShrikeCFG.this.getMethod().getDeclaringClass().getReference().getClassLoader();
caughtException = ShrikeUtil.makeTypeReference(loader, hs[j].getCatchClass()); caughtException = ShrikeUtil.makeTypeReference(loader, hs[j].getCatchClass());
if (DEBUG) {
System.err.println(" caughtException " + caughtException);
}
IClass caughtClass = cha.lookupClass(caughtException); IClass caughtClass = cha.lookupClass(caughtException);
if (caughtClass == null) { if (caughtClass == null) {
// conservatively add the edge, and raise a warning // conservatively add the edge, and raise a warning
@ -314,13 +313,14 @@ public class ShrikeCFG extends AbstractCFG<ShrikeCFG.BasicBlock> {
Warnings.add(FailedExceptionResolutionWarning.create(caughtException)); Warnings.add(FailedExceptionResolutionWarning.create(caughtException));
// null out caughtException, to avoid attempting to process it // null out caughtException, to avoid attempting to process it
caughtException = null; caughtException = null;
} else {
// hs[j].getCatchClass() == null.
// this means that the handler catches all exceptions.
// add the edge and null out all types
addExceptionalEdgeTo(b);
exceptionTypes.clear();
} }
} else {
// hs[j].getCatchClass() == null.
// this means that the handler catches all exceptions.
// add the edge and null out all types
addExceptionalEdgeTo(b);
exceptionTypes.clear();
caughtException = null;
} }
if (caughtException != null) { if (caughtException != null) {
// the set "caught" should be the set of exceptions that MUST // the set "caught" should be the set of exceptions that MUST
@ -386,7 +386,6 @@ public class ShrikeCFG extends AbstractCFG<ShrikeCFG.BasicBlock> {
addExceptionalEdge(this, b); addExceptionalEdge(this, b);
} }
public int getLastInstructionIndex() { public int getLastInstructionIndex() {
if (this == entry() || this == exit()) { if (this == entry() || this == exit()) {
// these are the special end blocks // these are the special end blocks
@ -472,17 +471,14 @@ public class ShrikeCFG extends AbstractCFG<ShrikeCFG.BasicBlock> {
return s.toString(); return s.toString();
} }
public int getMaxStackHeight() { public int getMaxStackHeight() {
return method.getMaxStackHeight(); return method.getMaxStackHeight();
} }
public int getMaxLocals() { public int getMaxLocals() {
return method.getMaxLocals(); return method.getMaxLocals();
} }
public Set<ExceptionHandler> getExceptionHandlers() { public Set<ExceptionHandler> getExceptionHandlers() {
return exceptionHandlers; return exceptionHandlers;
} }
@ -501,8 +497,6 @@ public class ShrikeCFG extends AbstractCFG<ShrikeCFG.BasicBlock> {
} }
/** /**
* @author sfink
*
* A warning when we fail to resolve the type of an exception * A warning when we fail to resolve the type of an exception
*/ */
private static class FailedExceptionResolutionWarning extends Warning { private static class FailedExceptionResolutionWarning extends Warning {