+ private boolean isCompositeLocation(CompositeLocation cl) {
+ return cl.getSize() > 1;
+ }
+
+ private boolean containsNonPrimitiveElement(Set<Descriptor> descSet) {
+ for (Iterator iterator = descSet.iterator(); iterator.hasNext();) {
+ Descriptor desc = (Descriptor) iterator.next();
+
+ if (desc instanceof VarDescriptor) {
+ if (!((VarDescriptor) desc).getType().isPrimitive()) {
+ return true;
+ }
+ } else if (desc instanceof FieldDescriptor) {
+ if (!((FieldDescriptor) desc).getType().isPrimitive()) {
+ return true;
+ }
+ }
+
+ }
+ return false;
+ }
+
+ private void addRelationHigherToLower(SSJavaLattice<String> lattice, LocationInfo locInfo,
+ String higher, String lower) {
+
+ Set<String> cycleElementSet = lattice.getPossibleCycleElements(higher, lower);
+
+ boolean hasNonPrimitiveElement = false;
+ for (Iterator iterator = cycleElementSet.iterator(); iterator.hasNext();) {
+ String cycleElementLocSymbol = (String) iterator.next();
+
+ Set<Descriptor> descSet = locInfo.getDescSet(cycleElementLocSymbol);
+ if (containsNonPrimitiveElement(descSet)) {
+ hasNonPrimitiveElement = true;
+ break;
+ }
+ }
+
+ if (hasNonPrimitiveElement) {
+ // if there is non-primitive element in the cycle, no way to merge cyclic
+ // elements into the shared location
+ throw new Error("Failed to merge cyclic value flows into a shared location.");
+ }
+
+ if (cycleElementSet.size() > 0) {
+ String newSharedLoc = "SharedLoc" + (SSJavaLattice.seed++);
+
+ lattice.mergeIntoSharedLocation(cycleElementSet, newSharedLoc);
+
+ for (Iterator iterator = cycleElementSet.iterator(); iterator.hasNext();) {
+ String oldLocSymbol = (String) iterator.next();
+ locInfo.mergeMapping(oldLocSymbol, newSharedLoc);
+ }
+
+
+ } else if (!lattice.isGreaterThan(higher, lower)) {
+ lattice.addRelationHigherToLower(higher, lower);
+ }
+ }
+
+ private void replaceOldLocWithNewLoc(SSJavaLattice<String> methodLattice, String oldLocSymbol,
+ String newLocSymbol) {
+
+ if (methodLattice.containsKey(oldLocSymbol)) {
+ methodLattice.substituteLocation(oldLocSymbol, newLocSymbol);
+ }
+
+ }
+
+ private void prefixSanityCheck(List<NTuple<Location>> prefixList, int curIdx,
+ FlowGraph flowGraph, Set<FlowNode> reachableNodeSet) {