From 7f398575ba9edc72c4c67f6ecd9a3a231c45b7ff Mon Sep 17 00:00:00 2001 From: Thomas Otto Date: Sat, 25 Jan 2020 11:00:35 +0100 Subject: [PATCH] Context: move i_tmpfile and converted to std::string --- src/Context.hpp | 3 +++ src/ccache.cpp | 13 ++++++------- src/legacy_globals.cpp | 3 --- src/legacy_globals.hpp | 2 -- 4 files changed, 9 insertions(+), 12 deletions(-) diff --git a/src/Context.hpp b/src/Context.hpp index 4931ebc63..74eb4e30e 100644 --- a/src/Context.hpp +++ b/src/Context.hpp @@ -72,4 +72,7 @@ struct Context : NonCopyable // Uses absolute path for some include files. bool has_absolute_include_headers = false; + + // The name of the temporary preprocessed file. + std::string i_tmpfile; }; diff --git a/src/ccache.cpp b/src/ccache.cpp index a15b58d63..d7f4f60a9 100644 --- a/src/ccache.cpp +++ b/src/ccache.cpp @@ -1146,7 +1146,7 @@ to_cache(Context& ctx, if (ctx.config.run_second_cpp()) { args_add(args, ctx.args_info.input_file.c_str()); } else { - args_add(args, i_tmpfile); + args_add(args, ctx.i_tmpfile.c_str()); } if (ctx.args_info.seen_split_dwarf) { @@ -1457,14 +1457,14 @@ get_result_name_from_cpp(Context& ctx, struct args* args, struct hash* hash) } if (ctx.args_info.direct_i_file) { - i_tmpfile = x_strdup(ctx.args_info.input_file.c_str()); + ctx.i_tmpfile = ctx.args_info.input_file; } else { // i_tmpfile needs the proper cpp_extension for the compiler to do its // thing correctly - i_tmpfile = - format("%s.%s", path_stdout, ctx.config.cpp_extension().c_str()); - x_rename(path_stdout, i_tmpfile); - add_pending_tmp_file(i_tmpfile); + ctx.i_tmpfile = + fmt::format("{}.{}", path_stdout, ctx.config.cpp_extension()); + x_rename(path_stdout, ctx.i_tmpfile.c_str()); + add_pending_tmp_file(ctx.i_tmpfile.c_str()); } if (ctx.config.run_second_cpp()) { @@ -3531,7 +3531,6 @@ cc_reset() } free_and_nullify(ignore_headers); ignore_headers_len = 0; - i_tmpfile = NULL; free_and_nullify(cpp_stderr); } diff --git a/src/legacy_globals.cpp b/src/legacy_globals.cpp index 80898479c..0359c8756 100644 --- a/src/legacy_globals.cpp +++ b/src/legacy_globals.cpp @@ -24,9 +24,6 @@ char** ignore_headers; // Size of headers to ignore list. size_t ignore_headers_len; -// The name of the temporary preprocessed file. -char* i_tmpfile; - // The name of the cpp stderr file. char* cpp_stderr; diff --git a/src/legacy_globals.hpp b/src/legacy_globals.hpp index eba4d1400..b6a695b06 100644 --- a/src/legacy_globals.hpp +++ b/src/legacy_globals.hpp @@ -34,8 +34,6 @@ extern char** ignore_headers; extern size_t ignore_headers_len; -extern char* i_tmpfile; - extern char* cpp_stderr; extern char* manifest_stats_file; -- 2.47.2