From 2e3b9a30ab72c54cf5113e603683d627c9b9629f Mon Sep 17 00:00:00 2001 From: Martino Luca Date: Wed, 19 Apr 2017 03:35:05 -0700 Subject: [PATCH] [CTL][Debug] Fix colouring issue Summary: Handling special case of DeclStmt with VarDecl: emit the VarDecl node then emit the statements in DeclStmt as children of VarDecl. This is because despite being equal, the statements inside VarDecl and those inside DeclStmt belong to different instances, hence they fail the phys_equal check that should colour them Reviewed By: dulmarod Differential Revision: D4850681 fbshipit-source-id: b9683dc --- infer/src/clang/cTL.ml | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/infer/src/clang/cTL.ml b/infer/src/clang/cTL.ml index 865bd810c..217e2c4f7 100644 --- a/infer/src/clang/cTL.ml +++ b/infer/src/clang/cTL.ml @@ -176,12 +176,17 @@ module Debug = struct let next_level = level + 1 in Format.fprintf fmt "%s%s%s %a@\n" spaces prefix node_name pp_node_info root; (match root with - | Stmt (DeclStmt (_, _, decls)) -> pp_decls fmt next_level decls + | Stmt (DeclStmt (_, stmts, ([(VarDecl _)] as var_decl))) -> + (* handling special case of DeclStmt with VarDecl: emit the VarDecl node + then emit the statements in DeclStmt as children of VarDecl. This is + because despite being equal, the statements inside VarDecl and those + inside DeclStmt belong to different instances, hence they fail the + phys_equal check that should colour them *) + pp_children pp_ast_aux (fun n -> Decl n) fmt next_level var_decl; + pp_stmts fmt (next_level+1) stmts | Stmt stmt -> let _, stmts = Clang_ast_proj.get_stmt_tuple stmt in pp_stmts fmt next_level stmts - | Decl (VarDecl (_, _, _, {vdi_init_expr})) -> - pp_stmts fmt next_level (Option.to_list vdi_init_expr) | Decl decl -> let decls = Clang_ast_proj.get_decl_context_tuple decl |>