public class Taint extends Canonical {
// taints can either be associated with
- // parameters or seses (rblocks),
- // only one set of identifying objects
- // will be non-null
+ // a stall site and live variable or
+ // an sese (rblock) and an in-set var
+ // only one identifer will be non-null
- // identify a parameter index
- protected Integer paramIndex;
-
// identify an sese (rblock) + inset var
protected FlatSESEEnterNode sese;
- protected TempDescriptor insetVar;
- // either type of taint also includes
- // an allocation site
- protected AllocSite allocSite;
+ // identify a stall site + live variable
+ protected FlatNode stallSite;
+ // either type of taint includes a var
+ // and allocation site
+ protected TempDescriptor var;
+ protected Alloc allocSite;
- public static Taint factory( Integer pi,
- FlatSESEEnterNode s,
- TempDescriptor iv,
- AllocSite as ) {
- Taint out = new Taint( pi, s, iv, as );
- out = (Taint) Canonical.makeCanonical( out );
+ // taints have a new, possibly null element which is
+ // the FlatNode at which the tainted reference was
+ // defined, which currently supports DFJ but doesn't
+ // hinder other analysis modes
+ protected FlatNode fnDefined;
+
+ // existance predicates must be true in a caller
+ // context for this taint's effects to transfer from this
+ // callee to that context
+ protected ExistPredSet preds;
+
+ public Taint reTaint(FlatNode fn) {
+ Taint out=new Taint(sese, stallSite, var, allocSite, fn, preds);
+ out = (Taint) Canonical.makeCanonical(out);
return out;
}
- protected Taint( Integer pi,
- FlatSESEEnterNode s,
- TempDescriptor iv,
- AllocSite as ) {
- assert
- (pi != null && s == null && iv == null) ||
- (pi == null && s != null && iv != null);
+ public static Taint factory(FlatSESEEnterNode sese,
+ TempDescriptor insetVar,
+ Alloc as,
+ FlatNode whereDefined,
+ ExistPredSet eps) {
+ Taint out = new Taint(sese, null, insetVar, as, whereDefined, eps);
+ out = (Taint) Canonical.makeCanonical(out);
+ return out;
+ }
- assert as != null;
+ public static Taint factory(FlatNode stallSite,
+ TempDescriptor var,
+ Alloc as,
+ FlatNode whereDefined,
+ ExistPredSet eps) {
+ Taint out = new Taint(null, stallSite, var, as, whereDefined, eps);
+ out = (Taint) Canonical.makeCanonical(out);
+ return out;
+ }
- paramIndex = pi;
- sese = s;
- insetVar = iv;
- allocSite = as;
+ public static Taint factory(FlatSESEEnterNode sese,
+ FlatNode stallSite,
+ TempDescriptor var,
+ Alloc as,
+ FlatNode whereDefined,
+ ExistPredSet eps) {
+ Taint out = new Taint(sese, stallSite, var, as, whereDefined, eps);
+ out = (Taint) Canonical.makeCanonical(out);
+ return out;
}
- public boolean isParamTaint() {
- return paramIndex != null;
+ protected Taint(FlatSESEEnterNode sese,
+ FlatNode stallSite,
+ TempDescriptor v,
+ Alloc as,
+ FlatNode fnDefined,
+ ExistPredSet eps) {
+ assert
+ (sese == null && stallSite != null) ||
+ (sese != null && stallSite == null);
+
+ assert v != null;
+ assert as != null;
+ assert eps != null;
+
+ this.sese = sese;
+ this.stallSite = stallSite;
+ this.var = v;
+ this.allocSite = as;
+ this.fnDefined = fnDefined;
+ this.preds = eps;
}
- public boolean isSESETaint() {
+ protected Taint(Taint t) {
+ this( t.sese,
+ t.stallSite,
+ t.var,
+ t.allocSite,
+ t.fnDefined,
+ t.preds );
+ }
+
+ public boolean isRBlockTaint() {
return sese != null;
}
- public Integer getParamIndex() {
- return paramIndex;
+ public boolean isStallSiteTaint() {
+ return stallSite != null;
}
public FlatSESEEnterNode getSESE() {
return sese;
}
- public TempDescriptor getInSetVar() {
- return insetVar;
+ public FlatNode getStallSite() {
+ return stallSite;
+ }
+
+ public TempDescriptor getVar() {
+ return var;
}
- public AllocSite getAllocSite() {
+ public Alloc getAllocSite() {
return allocSite;
}
+ public FlatNode getWhereDefined() {
+ return fnDefined;
+ }
- public boolean equalsSpecific( Object o ) {
+ public ExistPredSet getPreds() {
+ return preds;
+ }
+
+ public boolean equalsSpecific(Object o) {
+ if( !equalsIgnorePreds(o) ) {
+ return false;
+ }
+
+ Taint t = (Taint) o;
+ return preds.equals(t.preds);
+ }
+
+ public boolean equalsIgnorePreds(Object o) {
if( o == null ) {
return false;
}
Taint t = (Taint) o;
- boolean piMatches = true;
- if( paramIndex == null ) {
- piMatches = t.paramIndex == null;
+ boolean seseEqual;
+ if( sese == null ) {
+ seseEqual = (t.sese == null);
} else {
- piMatches = paramIndex.equals( t.paramIndex );
+ seseEqual = sese.equals(t.sese);
}
- boolean sMatches = true;
- if( sese == null ) {
- sMatches = t.sese == null;
+ boolean stallSiteEqual;
+ if( stallSite == null ) {
+ stallSiteEqual = (t.stallSite == null);
} else {
- sMatches = sese.equals( t.sese );
+ stallSiteEqual = stallSite.equals(t.stallSite);
}
- boolean ivMatches = true;
- if( insetVar == null ) {
- ivMatches = t.insetVar == null;
+ boolean fnDefinedEqual;
+ if( fnDefined == null ) {
+ fnDefinedEqual = (t.fnDefined == null);
} else {
- ivMatches = insetVar.equals( t.insetVar );
+ fnDefinedEqual = fnDefined.equals(t.fnDefined);
}
- return allocSite.equals( t.allocSite ) &&
- piMatches && sMatches && ivMatches;
+ return
+ seseEqual &&
+ stallSiteEqual &&
+ fnDefinedEqual &&
+ var.equals(t.var) &&
+ allocSite.equals(t.allocSite);
}
public int hashCodeSpecific() {
int hash = allocSite.hashCode();
-
- if( paramIndex != null ) {
- hash = hash ^ paramIndex.hashCode();
- }
+ hash = hash ^ var.hashCode();
if( sese != null ) {
hash = hash ^ sese.hashCode();
}
- if( insetVar != null ) {
- hash = hash ^ insetVar.hashCode();
+ if( stallSite != null ) {
+ hash = hash ^ stallSite.hashCode();
+ }
+
+ if( fnDefined != null ) {
+ hash = hash ^ fnDefined.hashCode();
}
return hash;
}
public String toString() {
- String s = "(";
- if( paramIndex != null ) {
- s += "param"+paramIndex;
+ String s;
+
+ if( isRBlockTaint() ) {
+ s = sese.getPrettyIdentifier();
} else {
- s += sese.toPrettyString()+"-"+insetVar;
+ s = stallSite.toString();
+ }
+
+ String f = "";
+ if( fnDefined != null ) {
+ f += ", "+fnDefined;
}
- return s+", "+allocSite.toStringBrief()+")";
+ return
+ "("+s+
+ "-"+var+
+ ", "+allocSite.toStringBrief()+
+ f+
+ "):"+preds;
}
}