From 350ddd0ce098492e1a8cd6864b8158e0d4f3f68c Mon Sep 17 00:00:00 2001 From: Julia Lawall Date: Sun, 8 Mar 2020 15:38:49 +0100 Subject: [PATCH 1/2] fail more gracefully on dead code Due to macros, there may be some fake nodes, and thus no position information. Just print some information that is not totally useless to find the problem. Problem noted by Markus Elfring --- parsing_c/control_flow_c_build.ml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/parsing_c/control_flow_c_build.ml b/parsing_c/control_flow_c_build.ml index b500ed00..0487a6e0 100644 --- a/parsing_c/control_flow_c_build.ml +++ b/parsing_c/control_flow_c_build.ml @@ -1563,7 +1563,14 @@ let deadcode_detection (g : Control_flow_c.cflow) = (match Control_flow_c.extract_fullstatement node with | Some st -> let ii = Ast_c.get_ii_st_take_care st in - raise (Error (DeadCode (Some (pinfo_of_ii ii)))) + let loc = + try Some (pinfo_of_ii ii) + with _ -> + begin + Printf.eprintf "dead code problem in: %s\n" (Dumper.dump st); + None + end in + raise (Error (DeadCode loc)) | _ -> pr2 "CFG: orphan nodes, maybe something weird happened" ) ) -- GitLab From 0ab82ec2050b0820fd79682034c35757503c1398 Mon Sep 17 00:00:00 2001 From: Julia Lawall Date: Sun, 8 Mar 2020 15:39:07 +0100 Subject: [PATCH 2/2] spaces -> tab --- parsing_c/control_flow_c_build.ml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/parsing_c/control_flow_c_build.ml b/parsing_c/control_flow_c_build.ml index 0487a6e0..19254ec9 100644 --- a/parsing_c/control_flow_c_build.ml +++ b/parsing_c/control_flow_c_build.ml @@ -1562,7 +1562,7 @@ let deadcode_detection (g : Control_flow_c.cflow) = | x -> (match Control_flow_c.extract_fullstatement node with | Some st -> - let ii = Ast_c.get_ii_st_take_care st in + let ii = Ast_c.get_ii_st_take_care st in let loc = try Some (pinfo_of_ii ii) with _ -> -- GitLab