diff --git a/src/eu.aniketos.dasca.dataflow/src/main/java/eu/aniketos/dasca/dataflow/util/PlugInUtil.java b/src/eu.aniketos.dasca.dataflow/src/main/java/eu/aniketos/dasca/dataflow/util/PlugInUtil.java index 52a7591..0c96f89 100644 --- a/src/eu.aniketos.dasca.dataflow/src/main/java/eu/aniketos/dasca/dataflow/util/PlugInUtil.java +++ b/src/eu.aniketos.dasca.dataflow/src/main/java/eu/aniketos/dasca/dataflow/util/PlugInUtil.java @@ -41,53 +41,53 @@ public class PlugInUtil { } public static void populateScope(JavaSourceAnalysisEngine engine, Collection sources, List libs) { - if (null != libs ){ - boolean foundLib = false; - for (String lib : libs) { - File libFile = new File(lib); - if (libFile.exists()) { - foundLib = true; - try { - engine.addSystemModule(new JarFileModule(new JarFile(libFile, false))); - } catch (IOException e) { - Assert.fail(e.getMessage()); - } - } - } - assert foundLib : "couldn't find library file from " + libs; - } + if (null != libs ) { + boolean foundLib = false; + for (String lib : libs) { + File libFile = new File(lib); + if (libFile.exists()) { + foundLib = true; + try { + engine.addSystemModule(new JarFileModule(new JarFile(libFile, false))); + } catch (IOException e) { + Assert.fail(e.getMessage()); + } + } + } + assert foundLib : "couldn't find library file from " + libs; + } - for (String srcFilePath : sources) { - String srcFileName = srcFilePath.substring(srcFilePath.lastIndexOf(File.separator) + 1); - File f = new File(srcFilePath); - Assert.assertTrue("couldn't find " + srcFilePath, f.exists()); - if (f.isDirectory()) { - engine.addSourceModule(new SourceDirectoryTreeModule(f)); - } else { - engine.addSourceModule(new SourceFileModule(f, srcFileName, null)); - } - } + for (String srcFilePath : sources) { + String srcFileName = srcFilePath.substring(srcFilePath.lastIndexOf(File.separator) + 1); + File f = new File(srcFilePath); + Assert.assertTrue("couldn't find " + srcFilePath, f.exists()); + if (f.isDirectory()) { + engine.addSourceModule(new SourceDirectoryTreeModule(f)); + } else { + engine.addSourceModule(new SourceFileModule(f, srcFileName, null)); + } + } } - + public static JavaSourceAnalysisEngine createECJJavaEngine(Collection sources, List libs, final String [] entryPoints) { - JavaSourceAnalysisEngine engine=null; - if(null == entryPoints){ - engine = new ECJJavaSourceAnalysisEngine(); - }else{ - engine = new ECJJavaSourceAnalysisEngine() { + JavaSourceAnalysisEngine engine=null; + if(null == entryPoints) { + engine = new ECJJavaSourceAnalysisEngine(); + } else { + engine = new ECJJavaSourceAnalysisEngine() { @Override protected Iterable makeDefaultEntrypoints(AnalysisScope scope, IClassHierarchy cha) { return Util.makeMainEntrypoints(JavaSourceAnalysisScope.SOURCE,cha, entryPoints); } }; - } + } engine.setExclusionsFile(REGRESSION_EXCLUSIONS); populateScope(engine, sources, libs); return engine; - } + } } diff --git a/src/eu.aniketos.dasca.dataflow/src/main/java/eu/aniketos/dasca/dataflow/util/SMTChecker.java b/src/eu.aniketos.dasca.dataflow/src/main/java/eu/aniketos/dasca/dataflow/util/SMTChecker.java index 49fb08c..81526c2 100644 --- a/src/eu.aniketos.dasca.dataflow/src/main/java/eu/aniketos/dasca/dataflow/util/SMTChecker.java +++ b/src/eu.aniketos.dasca.dataflow/src/main/java/eu/aniketos/dasca/dataflow/util/SMTChecker.java @@ -124,7 +124,7 @@ public class SMTChecker { } IOperator op = binOpInstruction.getOperator(); - + if(op == BinaryOpInstruction.Operator.OR) { return vc.orExpr(exprLhs, exprRhs); } else if(op == BinaryOpInstruction.Operator.AND) { @@ -254,7 +254,7 @@ public class SMTChecker { return vc.gtExpr(exprLhs, exprRhs); } else if(op == CAstBinaryOp.NE) { return vc.notExpr(vc.eqExpr(exprLhs, exprRhs)); - } + } } else if(defInst instanceof SSAUnaryOpInstruction) { // WALA uses unary operation ONLY for negation SSAUnaryOpInstruction unaryInst = (SSAUnaryOpInstruction) defInst; diff --git a/src/eu.aniketos.dasca.dataflow/src/main/java/eu/aniketos/dasca/dataflow/util/SSAInstructionKey.java b/src/eu.aniketos.dasca.dataflow/src/main/java/eu/aniketos/dasca/dataflow/util/SSAInstructionKey.java index 06af500..080325c 100644 --- a/src/eu.aniketos.dasca.dataflow/src/main/java/eu/aniketos/dasca/dataflow/util/SSAInstructionKey.java +++ b/src/eu.aniketos.dasca.dataflow/src/main/java/eu/aniketos/dasca/dataflow/util/SSAInstructionKey.java @@ -14,32 +14,32 @@ import com.ibm.wala.ssa.SSAInstruction; public class SSAInstructionKey { - private final SSAInstruction key; - public SSAInstructionKey(SSAInstruction key) { - this.key = key; - } - - public int hashCode(){ - return key.hashCode(); - } + private final SSAInstruction key; + public SSAInstructionKey(SSAInstruction key) { + this.key = key; + } - public String toString(){ - if (null == key){ - return "null (key)"; - }else{ - return key.toString(); - } - } - - public boolean equals(Object obj){ - if (null == obj){ - return false; - }else{ - if (obj instanceof SSAInstructionKey){ - return key == ((SSAInstructionKey) obj).key; - }else{ - return false; - } - } - } + public int hashCode() { + return key.hashCode(); + } + + public String toString() { + if (null == key) { + return "null (key)"; + } else { + return key.toString(); + } + } + + public boolean equals(Object obj) { + if (null == obj) { + return false; + } else { + if (obj instanceof SSAInstructionKey) { + return key == ((SSAInstructionKey) obj).key; + } else { + return false; + } + } + } } diff --git a/src/eu.aniketos.dasca.dataflow/src/main/java/eu/aniketos/dasca/dataflow/util/SuperGraphUtil.java b/src/eu.aniketos.dasca.dataflow/src/main/java/eu/aniketos/dasca/dataflow/util/SuperGraphUtil.java index ee0ff26..fcd3f07 100644 --- a/src/eu.aniketos.dasca.dataflow/src/main/java/eu/aniketos/dasca/dataflow/util/SuperGraphUtil.java +++ b/src/eu.aniketos.dasca.dataflow/src/main/java/eu/aniketos/dasca/dataflow/util/SuperGraphUtil.java @@ -95,8 +95,8 @@ public class SuperGraphUtil { } } else { if(!acceptedMethods.contains(method)) { - log.debug("supergraph cut at '" + bbic.getNumber() + " -> " + nextChild.getNumber() + " (" - + nextChild.toString() + ")'"); + log.debug("supergraph cut at '" + bbic.getNumber() + " -> " + nextChild.getNumber() + " (" + + nextChild.toString() + ")'"); continue; } } @@ -172,15 +172,15 @@ public class SuperGraphUtil { i++; } if(mainEntryId == 0 && mainExitId == 0) { - log.error(" "+entryClass + "." + entryMethod + - ": empty entry method, ensure invocation in main method " + - "(mainEntryId = " +mainEntryId + " / mainExitId = " + mainExitId + ")"); + log.error(" "+entryClass + "." + entryMethod + + ": empty entry method, ensure invocation in main method " + + "(mainEntryId = " +mainEntryId + " / mainExitId = " + mainExitId + ")"); return -1; } HashSet relevantIDs = new HashSet(); BasicBlockInContext bbic = sgNodes.get(mainEntryId); acceptedMethods.add(bbic.getMethod().getReference()); - log.error(" "+entryClass + "." + entryMethod + + log.error(" "+entryClass + "." + entryMethod + "start recursive graph building"); relevantPathSearch(relevantIDs, sg, sgNodes, sgNodesReversed, acceptedMethods, mainEntryId, mainExitId); @@ -196,7 +196,7 @@ public class SuperGraphUtil { } // build separate adjacency list - log.debug(" "+entryClass + "." + entryMethod + + log.debug(" "+entryClass + "." + entryMethod + "build seperate adjacency list"); HashMap> adjList = new HashMap>(); HashMap> adjListReverse = new HashMap>(); @@ -207,19 +207,19 @@ public class SuperGraphUtil { buildAdjacencyLists(sg, sgNodes, sgNodesReversed, adjList, adjListReverse, emptyNodes, relevantIDs); // <<< print original adjacency list to log - log.debug("adjacency list before removing empty nodes:"); - AnalysisUtil.printAdjList(adjList, log); + log.debug("adjacency list before removing empty nodes:"); + AnalysisUtil.printAdjList(adjList, log); // if(removeEmptyNodes) { removeEmptyNodes(emptyNodes, adjList, adjListReverse, sgNodes, sgNodesReversed); // <<< print adjacency list to log - log.debug("adjacency after removing empty nodes:"); - AnalysisUtil.printAdjList(adjList, log); + log.debug("adjacency after removing empty nodes:"); + AnalysisUtil.printAdjList(adjList, log); // } - - - log.debug(" "+entryClass + "." + entryMethod + + + + log.debug(" "+entryClass + "." + entryMethod + "add conditions to graph nodes"); ArrayList visited = new ArrayList(); ArrayList currentConditions = new ArrayList(); @@ -483,10 +483,10 @@ public class SuperGraphUtil { HashMap> adjList, HashMap>> paths) { - log.debug(" searching for "+currentId+" in adjList."); + log.debug(" searching for "+currentId+" in adjList."); ArrayList children = adjList.get(currentId); if (null == children) { - throw new RuntimeException ("No entry found in adjList for "+currentId); + throw new RuntimeException ("No entry found in adjList for "+currentId); } HashSet> currentPaths = new HashSet>(); @@ -541,8 +541,8 @@ public class SuperGraphUtil { vc.pop(); vc.push(); if(expr.toString().equalsIgnoreCase("null")) { - log.debug(" isNotMutuallyExclusive: EXPR: "+expr+" is NULL (combinedConditions: " - + combinedConditions + "/ expressions: " + expressions +")"); + log.debug(" isNotMutuallyExclusive: EXPR: "+expr+" is NULL (combinedConditions: " + + combinedConditions + "/ expressions: " + expressions +")"); return true; } SatResult satResult = vc.checkUnsat(expr);