Skip to content

Commit c44bcd6

Browse files
committed
Reformat compilation database arguments case
1 parent a14b93f commit c44bcd6

File tree

1 file changed

+13
-14
lines changed

1 file changed

+13
-14
lines changed

src/util/compilationDatabase.ml

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -70,21 +70,20 @@ let load_and_preprocess ~all_cppflags filename =
7070
preprocess_command_o
7171
| None, Some arguments ->
7272
let arguments_program, arguments =
73-
begin match List.map reroot arguments with
74-
| arguments_program::arguments -> arguments_program, arguments
75-
| _ -> failwith ("CompilationDatabase.preprocess: no program found for " ^ file)
76-
end in
73+
match List.map reroot arguments with
74+
| arguments_program :: arguments -> arguments_program, arguments
75+
| _ -> failwith ("CompilationDatabase.preprocess: no program found for " ^ file)
76+
in
7777
let preprocess_arguments =
78-
let suf =
79-
begin match List.findi (fun i e -> e = "-o") arguments with
80-
| (o_i, _) ->
81-
begin match List.split_at o_i arguments with
82-
| (arguments_init, _ :: o_file :: arguments_tl) -> arguments_init @ "-o" :: preprocessed_file :: arguments_tl
83-
| _ -> failwith ("CompilationDatabase.preprocess: no argument found for -o option for " ^ file)
84-
end
85-
| exception Not_found -> arguments @ "-o" :: [preprocessed_file]
86-
end in
87-
all_cppflags @ "-E" :: suf in
78+
match List.findi (fun i e -> e = "-o") arguments with
79+
| (o_i, _) ->
80+
begin match List.split_at o_i arguments with
81+
| (arguments_init, _ :: o_file :: arguments_tl) -> arguments_init @ "-o" :: preprocessed_file :: arguments_tl
82+
| _ -> failwith ("CompilationDatabase.preprocess: no argument found for -o option for " ^ file)
83+
end
84+
| exception Not_found -> arguments @ "-o" :: [preprocessed_file]
85+
in
86+
let preprocess_arguments = all_cppflags @ "-E" :: preprocess_arguments in
8887
Filename.quote_command arguments_program preprocess_arguments
8988
| Some _, Some _ ->
9089
failwith "CompilationDatabase.preprocess: both command and arguments specified for " ^ file

0 commit comments

Comments
 (0)