@@ -172,10 +172,22 @@ let handle_flags () =
172172 Messages. formatter := Format. formatter_of_out_channel (Legacy. open_out (Legacy.Filename. concat path " warnings.out" ));
173173 set_string " outfile" " "
174174
175+ let basic_preprocess_counts = Preprocessor.FpathH. create 3
176+
175177(* * Use gcc to preprocess a file. Returns the path to the preprocessed file. *)
176178let basic_preprocess ~all_cppflags fname =
177179 (* The actual filename of the preprocessed sourcefile *)
178- let nname = Fpath. append (GoblintDir. preprocessed () ) (Fpath. set_ext " .i" (Fpath. base fname)) in
180+ let basename = Fpath. rem_ext (Fpath. base fname) in
181+ (* generate unique preprocessed filename in case multiple basic files have same basename (from different directories), happens in ddverify *)
182+ let count = Preprocessor.FpathH. find_default basic_preprocess_counts basename 0 in
183+ let unique_name =
184+ if count = 0 then
185+ basename
186+ else
187+ Fpath. add_ext (string_of_int count) basename
188+ in
189+ Preprocessor.FpathH. replace basic_preprocess_counts basename (count + 1 );
190+ let nname = Fpath. append (GoblintDir. preprocessed () ) (Fpath. add_ext " .i" unique_name) in
179191 (* Preprocess using cpp. *)
180192 (* ?? what is __BLOCKS__? is it ok to just undef? this? http://en.wikipedia.org/wiki/Blocks_(C_language_extension) *)
181193 let arguments = " --undef" :: " __BLOCKS__" :: all_cppflags @ Fpath. to_string fname :: " -o" :: Fpath. to_string nname :: [] in
@@ -185,6 +197,7 @@ let basic_preprocess ~all_cppflags fname =
185197
186198(* * Preprocess all files. Return list of preprocessed files and the temp directory name. *)
187199let preprocess_files () =
200+ Preprocessor.FpathH. clear basic_preprocess_counts;
188201 Preprocessor.FpathH. clear Preprocessor. dependencies; (* clear for server mode *)
189202
190203 (* Preprocessor flags *)
0 commit comments