diff --git a/clang/clang/ast.ml b/clang/clang/ast.ml index e77b7f5..34c64d1 100644 --- a/clang/clang/ast.ml +++ b/clang/clang/ast.ml @@ -954,10 +954,12 @@ and stmt_ = AstBridge.stmt_ = * stmt * decl * (* captures *)stmt list - | ObjCAtFinallyStmt of (* body *)stmt - | ObjCAtTryStmt of (* body *)stmt | ObjCAtCatchStmt of (* param *)decl * (* body *)stmt + | ObjCAtFinallyStmt of (* body *)stmt + | ObjCAtTryStmt of (* try body *)stmt + * (* catch stmts *)stmt list + * (* finally body *)stmt option | AttributedStmt diff --git a/clang/clang/pp.ml b/clang/clang/pp.ml index b389a29..f05d060 100644 --- a/clang/clang/pp.ml +++ b/clang/clang/pp.ml @@ -663,16 +663,22 @@ and pp_stmt_ fmt = function pp_stmt stmt pp_decl decl (Formatx.pp_list pp_stmt) captures - | ObjCAtFinallyStmt body -> - Format.fprintf fmt "@@finally %a" - pp_stmt body - | ObjCAtTryStmt body -> - Format.fprintf fmt "@@try %a" - pp_stmt body | ObjCAtCatchStmt (param, body) -> Format.fprintf fmt "@@catch (%a) %a" pp_decl param pp_stmt body + | ObjCAtFinallyStmt body -> + Format.fprintf fmt "@@finally %a" + pp_stmt body + | ObjCAtTryStmt (try_body, catch_stmts, Some finally_body) -> + Format.fprintf fmt "@@try %a %a %a" + pp_stmt try_body + (Formatx.pp_list pp_stmt) catch_stmts + pp_stmt finally_body + | ObjCAtTryStmt (try_body, catch_stmts, None) -> + Format.fprintf fmt "@@try %a %a" + pp_stmt try_body + (Formatx.pp_list pp_stmt) catch_stmts | OMPParallelDirective -> Format.pp_print_string fmt "" diff --git a/plugin/c++/OCamlVisitor/Stmt.cpp b/plugin/c++/OCamlVisitor/Stmt.cpp index d28d3d0..059b948 100644 --- a/plugin/c++/OCamlVisitor/Stmt.cpp +++ b/plugin/c++/OCamlVisitor/Stmt.cpp @@ -331,9 +331,17 @@ OCamlVisitor::TraverseObjCAtTryStmt (clang::ObjCAtTryStmt *S) { TRACE; - ptr body = must_traverse (S->getTryBody ()); + ptr try_body = must_traverse (S->getTryBody ()); - stack.push (mkObjCAtTryStmt (body)); + list catch_stmts; + for (unsigned i = 0; i < S->getNumCatchStmts (); ++i) + { + catch_stmts.push_back(must_traverse (S->getCatchStmt (i))); + } + + option finally_body = maybe_traverse (S->getFinallyStmt ()); + + stack.push (mkObjCAtTryStmt (try_body, catch_stmts, finally_body)); return true; }