| Ast_c.OriginTok _ ->
Buffer.add_string buf (TH.str_of_tok tok)
| Ast_c.AbstractLineTok _ ->
- raise Impossible
+ raise (Impossible 79)
| _ -> ()
);
Buffer.contents buf
||
(s =~ "__.*")
| 3 ->
- List.mem cppkind [Token_c.CppAttr;Token_c.CppPassingNormal;Token_c.CppDirective]
+ (match cppkind with
+ Token_c.CppAttr | Token_c.CppPassingNormal
+ | Token_c.CppDirective | Token_c.CppIfDirective _ -> true
+ | _ -> false)
||
(s =~ "__.*")
| 4 ->
- List.mem cppkind [Token_c.CppAttr;Token_c.CppPassingNormal;Token_c.CppMacro]
+ List.mem cppkind
+ [Token_c.CppAttr;Token_c.CppPassingNormal;Token_c.CppMacro]
||
(s =~ "__.*")
| 5 ->
- List.mem cppkind [Token_c.CppAttr;Token_c.CppPassingNormal;Token_c.CppDirective;Token_c.CppMacro]
+ (match cppkind with
+ Token_c.CppAttr | Token_c.CppPassingNormal
+ | Token_c.CppDirective | Token_c.CppIfDirective _
+ | Token_c.CppMacro -> true
+ | _ -> false)
||
(s =~ "__.*")
!cur_tok
)
in
- let lexbuf_fake = Lexing.from_function (fun buf n -> raise Impossible) in
+ let lexbuf_fake = Lexing.from_function (fun buf n -> raise (Impossible 80)) in
let result = parsefunc lexer_function lexbuf_fake in
result
let max_pass = 4
-
let get_one_elem ~pass tr (file, filelines) =
if not (LP.is_enabled_typedef()) && !Flag_parsing_c.debug_typedef
tr.passed <- [];
- let lexbuf_fake = Lexing.from_function (fun buf n -> raise Impossible) in
+ let lexbuf_fake = Lexing.from_function (fun buf n -> raise (Impossible 81)) in
(try
(* -------------------------------------------------- *)
(* -------------------------------------------------- *)
(* call lexer and get all the tokens *)
(* -------------------------------------------------- *)
+
LP.lexer_reset_typedef saved_typedefs;
Parsing_hacks.ifdef_paren_cnt := 0;
pr2 ("parse error \n = " ^ error_msg_tok cur)
| Semantic_c.Semantic (s, i) ->
pr2 ("semantic error " ^s^ "\n ="^ error_msg_tok cur)
- | e -> raise Impossible
+ | e -> raise (Impossible 82)
);
(* bugfix: *)
if (checkpoint_file =$= checkpoint2_file) &&
if not !Flag_parsing_c.use_cache
then parse_print_error_heuristic None None file
else
- let _ = pr2 "TOFIX" in
+ let _ = pr2_once "TOFIX: use_cache is not sensitive to changes in the considered macros, include files, etc" in
let need_no_changed_files =
(* should use Sys.argv.(0), would be safer. *)
*)
!Config.std_h;
*)
- ]
- in
+ ] in
let need_no_changed_variables =
(* could add some of the flags of flag_parsing_c.ml *)
- []
- in
- Common.cache_computation_robust
- file ".ast_raw"
+ [] in
+ Common.cache_computation_robust_in_dir
+ !Flag_parsing_c.cache_prefix file ".ast_raw"
(need_no_changed_files, need_no_changed_variables) ".depend_raw"
- (fun () -> parse_print_error_heuristic None None file)
+ (fun () ->
+ (* check whether to clear the cache *)
+ (match (!Flag_parsing_c.cache_limit,!Flag_parsing_c.cache_prefix) with
+ (None,_) | (_,None) -> ()
+ | (Some limit,Some prefix) ->
+ let count =
+ Common.cmd_to_list
+ (Printf.sprintf "test -e %s && find %s -name \"*_raw\" | wc -l"
+ prefix prefix) in
+ match count with
+ [c] ->
+ if int_of_string c >= limit
+ then
+ let _ =
+ Sys.command
+ (Printf.sprintf
+ "find %s -name \"*_raw\" -exec /bin/rm {} \\;"
+ prefix) in
+ ()
+ | _ -> ());
+ (* recompute *)
+ parse_print_error_heuristic None None file)