Browse Source

delay false candidate classification

Nicolas Cannasse 8 years ago
parent
commit
f582d31a09
1 changed files with 11 additions and 3 deletions
  1. 11 3
      other/memory/Memory.hx

+ 11 - 3
other/memory/Memory.hx

@@ -62,6 +62,7 @@ class Memory {
 	var tdynObjData : TType;
 	var tdynObjData : TType;
 	var pointerBlock : Map<Pointer, Block>;
 	var pointerBlock : Map<Pointer, Block>;
 	var pointerType : Map<Pointer, TType>;
 	var pointerType : Map<Pointer, TType>;
+	var falseCandidates : Array<{ b : Block, f : Block, idx : Int }>;
 
 
 	function new() {
 	function new() {
 	}
 	}
@@ -331,6 +332,7 @@ class Memory {
 		types.push(tdynObjData);
 		types.push(tdynObjData);
 
 
 		toProcess = blocks.copy();
 		toProcess = blocks.copy();
+		falseCandidates = [];
 		while( toProcess.length > 0 )
 		while( toProcess.length > 0 )
 			buildHierarchy();
 			buildHierarchy();
 
 
@@ -348,6 +350,13 @@ class Memory {
 			}
 			}
 		}
 		}
 
 
+		for( f in falseCandidates )
+			if( f.f.owner == null ) {
+				f.f.addParent(f.b);
+				f.b.type.falsePositive++;
+				f.b.type.falsePositiveIndexes[f.idx]++;
+			}
+
 		for( b in blocks )
 		for( b in blocks )
 			b.finalize();
 			b.finalize();
 
 
@@ -464,7 +473,6 @@ class Memory {
 				var bs = pointerBlock.get(r);
 				var bs = pointerBlock.get(r);
 				if( bs == null ) continue;
 				if( bs == null ) continue;
 				var ft = fields != null ? fields[i] : null;
 				var ft = fields != null ? fields[i] : null;
-				bs.addParent(b);
 
 
 				if( b.type == tdynObj && (i == 1 || i == 2) ) {
 				if( b.type == tdynObj && (i == 1 || i == 2) ) {
 					if( bs.typeKind != KHeader && (bs.typeKind != null || bs.type != null) )
 					if( bs.typeKind != KHeader && (bs.typeKind != null || bs.type != null) )
@@ -476,10 +484,10 @@ class Memory {
 				}
 				}
 
 
 				if( ft != null && !ft.t.isPtr() ) {
 				if( ft != null && !ft.t.isPtr() ) {
-					b.type.falsePositive++;
-					b.type.falsePositiveIndexes[i]++;
+					falseCandidates.push({ b : b, f:bs, idx : i });
 					continue;
 					continue;
 				}
 				}
+				bs.addParent(b);
 
 
 				if( bs.type == null && ft != null ) {
 				if( bs.type == null && ft != null ) {
 					if( ft.t.isDynamic() ) {
 					if( ft.t.isDynamic() ) {