浏览代码

fix config handling in analyzer

Simon Krajewski 9 年之前
父节点
当前提交
67549cc66b
共有 2 个文件被更改,包括 8 次插入9 次删除
  1. 6 6
      analyzer.ml
  2. 2 3
      filters.ml

+ 6 - 6
analyzer.ml

@@ -225,9 +225,9 @@ module Config = struct
 		with Not_found ->
 			false
 
-	let get_base_config com optimize =
+	let get_base_config com =
 		{
-			optimize = optimize;
+			optimize = not (Common.defined com Define.NoAnalyzer);
 			const_propagation = not (Common.raw_defined com "analyzer-no-const-propagation");
 			copy_propagation = not (Common.raw_defined com "analyzer-no-copy-propagation");
 			code_motion = Common.raw_defined com "analyzer-code-motion";
@@ -266,7 +266,7 @@ module Config = struct
 		) config meta
 
 	let get_class_config com c =
-		let config = get_base_config com true in
+		let config = get_base_config com in
 		update_config_from_meta config c.cl_meta
 
 	let get_field_config com c cf =
@@ -2877,9 +2877,9 @@ module Run = struct
 		| TTypeDecl _ -> ()
 		| TAbstractDecl _ -> ()
 
-	let run_on_types ctx full types =
+	let run_on_types ctx types =
 		let com = ctx.Typecore.com in
-		let config = get_base_config com full in
-		if full && config.purity_inference then Purity.infer com;
+		let config = get_base_config com in
+		if config.optimize && config.purity_inference then Purity.infer com;
 		List.iter (run_on_type ctx config) types
 end

+ 2 - 3
filters.ml

@@ -868,7 +868,7 @@ let add_field_inits ctx t =
 				| _ ->
 					assert false
 			in
-			let config = Analyzer.Config.get_base_config ctx.com false in
+			let config = Analyzer.Config.get_field_config ctx.com c cf in
 			Analyzer.Run.run_on_field ctx config c cf;
 			(match cf.cf_expr with
 			| Some e ->
@@ -1031,7 +1031,6 @@ let run com tctx main =
 	end;
 	if not (Common.defined com Define.NoDeprecationWarnings) then
 		Codegen.DeprecationCheck.run com;
-	let use_static_analyzer = not (Common.defined com Define.NoAnalyzer) in
 	let new_types = List.filter (fun t -> not (is_cached t)) com.types in
 	(* PASS 1: general expression filters *)
 	let filters = [
@@ -1042,7 +1041,7 @@ let run com tctx main =
 		captured_vars com;
 	] in
 	List.iter (run_expression_filters tctx filters) new_types;
-	if com.platform <> Cross then Analyzer.Run.run_on_types tctx use_static_analyzer new_types;
+	if com.platform <> Cross then Analyzer.Run.run_on_types tctx new_types;
 	let filters = [
 		Optimizer.sanitize com;
 		if com.config.pf_add_final_return then add_final_return else (fun e -> e);