[CTL] Add support for is_unop_with_kind/is_binop_with_kind predicates to check correctness of their inputs

Summary:
This will help during the creation of new checkers, and will prevent errors like misspelling of operators' kinds.
It will also make it possible to fail immediately during the parsing of CTL inputs.

Reviewed By: ddino

Differential Revision: D4212956

fbshipit-source-id: c3c7fe7
master
Martino Luca 8 years ago committed by Facebook Github Bot
parent cd6e9e8b21
commit 7c9612b06b

@ -1 +1 @@
Subproject commit 18904710494629ff27a5350d715f3a2a228970b6 Subproject commit e13e1ecabe333209fabebedb1f80f1325669fcec

@ -172,20 +172,19 @@ let captures_cxx_references stmt =
IList.length (captured_variables_cxx_ref stmt) > 0 IList.length (captured_variables_cxx_ref stmt) > 0
let is_binop_with_kind stmt str_kind = let is_binop_with_kind stmt str_kind =
let kind = match str_kind with if not (Clang_ast_proj.is_valid_binop_kind_name str_kind) then
| "EQ" -> `EQ failwith ("Binary operator kind " ^ str_kind ^ " is not valid");
| "NE" -> `NE
| _ -> failwith ("Kind " ^ str_kind ^ " is invalid or not yet supported") in
match stmt with match stmt with
| Clang_ast_t.BinaryOperator (_, _, _, boi) when boi.boi_kind = kind -> true | Clang_ast_t.BinaryOperator (_, _, _, boi) ->
Clang_ast_proj.string_of_binop_kind boi.boi_kind = str_kind
| _ -> false | _ -> false
let is_unop_with_kind stmt str_kind = let is_unop_with_kind stmt str_kind =
let kind = match str_kind with if not (Clang_ast_proj.is_valid_unop_kind_name str_kind) then
| "LNot" -> `LNot failwith ("Unary operator kind " ^ str_kind ^ " is not valid");
| _ -> failwith ("Kind " ^ str_kind ^ " is invalid or not yet supported") in
match stmt with match stmt with
| Clang_ast_t.UnaryOperator (_, _, _, uoi) when uoi.uoi_kind = kind -> true | Clang_ast_t.UnaryOperator (_, _, _, uoi) ->
Clang_ast_proj.string_of_unop_kind uoi.uoi_kind = str_kind
| _ -> false | _ -> false
let is_stmt stmt stmt_name = let is_stmt stmt stmt_name =

Loading…
Cancel
Save