Skip to content

Commit 9466945

Browse files
committed
Fix goto-cc same filename bug
Previously, when goto-cc was invoked with multiple files with different paths but the same basename (e.g., dir1/test.c, dir2/test.c), the preprocessing results would be written to the same temporary directory. Thus, earlier preprocessed files would be overwritten by later preprocessed files. This change ensures that a separate temporary directory is used for each preprocessed file.
1 parent f313e7f commit 9466945

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/goto-cc/gcc_mode.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -655,7 +655,7 @@ int gcc_modet::doit()
655655

656656
// We now iterate over any input files
657657

658-
temp_dirt temp_dir("goto-cc-XXXXXX");
658+
std::vector<temp_dirt> temp_dirs;
659659

660660
{
661661
std::string language;
@@ -688,7 +688,9 @@ int gcc_modet::doit()
688688

689689
std::string new_name=
690690
get_base_name(arg_it->arg, true)+new_suffix;
691-
std::string dest=temp_dir(new_name);
691+
692+
temp_dirs.emplace_back("goto-cc-XXXXXX");
693+
std::string dest = temp_dirs.back()(new_name);
692694

693695
int exit_code=
694696
preprocess(language, arg_it->arg, dest, act_as_bcc);

0 commit comments

Comments
 (0)