]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
Context: add ArgsInfo and move input_file
authorThomas Otto <thomas.otto@pdv-fs.de>
Fri, 24 Jan 2020 17:40:21 +0000 (18:40 +0100)
committerJoel Rosdahl <joel@rosdahl.net>
Mon, 10 Feb 2020 20:08:27 +0000 (21:08 +0100)
src/Context.hpp
src/ccache.cpp
src/legacy_globals.cpp
src/legacy_globals.hpp
unittest/test_argument_processing.cpp

index a3ff59b0f6c9e3076fb7860fb1c1ae9ea3451bd0..770c257b7a03296f22afb6c24193925f264d520b 100644 (file)
@@ -27,4 +27,6 @@ struct Context : NonCopyable
 {
   Context() = default;
   ~Context();
+
+  ArgsInfo args_info;
 };
index 30017d1cebef2335b4de62092b07442ab0ae3b5b..ee066666f8d276508884fefe7d477126ef492d68 100644 (file)
@@ -435,7 +435,8 @@ get_current_working_dir(void)
 }
 
 static bool
-do_remember_include_file(std::string path,
+do_remember_include_file(Context& ctx,
+                         std::string path,
                          struct hash* cpp_hash,
                          bool system,
                          struct hash* depend_mode_hash)
@@ -448,7 +449,7 @@ do_remember_include_file(std::string path,
     return true;
   }
 
-  if (path == input_file) {
+  if (path == ctx.args_info.input_file) {
     // Don't remember the input file.
     return true;
   }
@@ -600,12 +601,13 @@ do_remember_include_file(std::string path,
 // global g_included_files variable. If the include file is a PCH, cpp_hash is
 // also updated.
 static void
-remember_include_file(const std::string& path,
+remember_include_file(Context& ctx,
+                      const std::string& path,
                       struct hash* cpp_hash,
                       bool system,
                       struct hash* depend_mode_hash)
 {
-  if (!do_remember_include_file(path, cpp_hash, system, depend_mode_hash)
+  if (!do_remember_include_file(ctx, path, cpp_hash, system, depend_mode_hash)
       && g_config.direct_mode()) {
     cc_log("Disabling direct mode");
     g_config.set_direct_mode(false);
@@ -706,7 +708,10 @@ make_relative_path(const char* path)
 // - Stores the paths and hashes of included files in the global variable
 //   g_included_files.
 static bool
-process_preprocessed_file(struct hash* hash, const char* path, bool pump)
+process_preprocessed_file(Context& ctx,
+                          struct hash* hash,
+                          const char* path,
+                          bool pump)
 {
   char* data;
   size_t size;
@@ -848,7 +853,7 @@ process_preprocessed_file(struct hash* hash, const char* path, bool pump)
         hash_string_buffer(hash, inc_path, strlen(inc_path));
       }
 
-      remember_include_file(inc_path, hash, system, NULL);
+      remember_include_file(ctx, inc_path, hash, system, NULL);
       free(inc_path);
       p = q; // Everything of interest between p and q has been hashed now.
     } else if (q[0] == '.' && q[1] == 'i' && q[2] == 'n' && q[3] == 'c'
@@ -889,7 +894,7 @@ process_preprocessed_file(struct hash* hash, const char* path, bool pump)
   if (included_pch_file) {
     std::string pch_path = make_relative_path(included_pch_file);
     hash_string(hash, pch_path);
-    remember_include_file(pch_path, hash, false, NULL);
+    remember_include_file(ctx, pch_path, hash, false, NULL);
   }
 
   bool debug_included = getenv("CCACHE_DEBUG_INCLUDED");
@@ -991,7 +996,7 @@ out:
 // Extract the used includes from the dependency file. Note that we cannot
 // distinguish system headers from other includes here.
 static struct digest*
-result_name_from_depfile(const char* depfile, struct hash* hash)
+result_name_from_depfile(Context& ctx, const char* depfile, struct hash* hash)
 {
   FILE* f = fopen(depfile, "r");
   if (!f) {
@@ -1012,7 +1017,7 @@ result_name_from_depfile(const char* depfile, struct hash* hash)
         has_absolute_include_headers = is_absolute_path(token);
       }
       std::string path = make_relative_path(token);
-      remember_include_file(path, hash, false, hash);
+      remember_include_file(ctx, path, hash, false, hash);
     }
   }
 
@@ -1023,7 +1028,7 @@ result_name_from_depfile(const char* depfile, struct hash* hash)
   if (included_pch_file) {
     std::string pch_path = make_relative_path(included_pch_file);
     hash_string(hash, pch_path);
-    remember_include_file(pch_path, hash, false, NULL);
+    remember_include_file(ctx, pch_path, hash, false, NULL);
   }
 
   bool debug_included = getenv("CCACHE_DEBUG_INCLUDED");
@@ -1127,7 +1132,8 @@ create_cachedir_tag(const std::string& dir)
 
 // Run the real compiler and put the result in cache.
 static void
-to_cache(struct args* args,
+to_cache(Context& ctx,
+         struct args* args,
          struct args* depend_extra_args,
          struct hash* depend_mode_hash)
 {
@@ -1154,7 +1160,7 @@ to_cache(struct args* args,
   x_unsetenv("SUNPRO_DEPENDENCIES");
 
   if (g_config.run_second_cpp()) {
-    args_add(args, input_file);
+    args_add(args, ctx.args_info.input_file.c_str());
   } else {
     args_add(args, i_tmpfile);
   }
@@ -1292,7 +1298,7 @@ to_cache(struct args* args,
 
   if (g_config.depend_mode()) {
     struct digest* result_name =
-      result_name_from_depfile(output_dep, depend_mode_hash);
+      result_name_from_depfile(ctx, output_dep, depend_mode_hash);
     if (!result_name) {
       stats_update(STATS_ERROR);
       failed();
@@ -1400,24 +1406,25 @@ to_cache(struct args* args,
 // Find the result name by running the compiler in preprocessor mode and
 // hashing the result.
 static struct digest*
-get_result_name_from_cpp(struct args* args, struct hash* hash)
+get_result_name_from_cpp(Context& ctx, struct args* args, struct hash* hash)
 {
   time_of_compilation = time(NULL);
 
   char* path_stderr = NULL;
-  char* path_stdout;
+  char* path_stdout = nullptr;
   int status;
   if (direct_i_file) {
     // We are compiling a .i or .ii file - that means we can skip the cpp stage
     // and directly form the correct i_tmpfile.
-    path_stdout = input_file;
+    path_stdout = x_strdup(ctx.args_info.input_file.c_str());
     status = 0;
   } else {
     // Run cpp on the input file to obtain the .i.
 
     // Limit the basename to 10 characters in order to cope with filesystem with
     // small maximum filename length limits.
-    string_view input_base = Util::get_truncated_base_name(input_file, 10);
+    string_view input_base =
+      Util::get_truncated_base_name(ctx.args_info.input_file, 10);
     path_stdout =
       x_strdup(fmt::format("{}/{}.stdout", temp_dir(), input_base).c_str());
     int path_stdout_fd = create_tmp_fd(&path_stdout);
@@ -1433,7 +1440,7 @@ get_result_name_from_cpp(struct args* args, struct hash* hash)
       args_add(args, "-C");
       args_added = 3;
     }
-    args_add(args, input_file);
+    args_add(args, ctx.args_info.input_file.c_str());
     add_prefix(args, g_config.prefix_command_cpp().c_str());
     cc_log("Running preprocessor");
     MTR_BEGIN("execute", "preprocessor");
@@ -1450,7 +1457,7 @@ get_result_name_from_cpp(struct args* args, struct hash* hash)
 
   hash_delimiter(hash, "cpp");
   if (!process_preprocessed_file(
-        hash, path_stdout, guessed_compiler == GUESSED_PUMP)) {
+        ctx, hash, path_stdout, guessed_compiler == GUESSED_PUMP)) {
     stats_update(STATS_ERROR);
     failed();
   }
@@ -1464,7 +1471,7 @@ get_result_name_from_cpp(struct args* args, struct hash* hash)
   }
 
   if (direct_i_file) {
-    i_tmpfile = input_file;
+    i_tmpfile = x_strdup(ctx.args_info.input_file.c_str());
   } else {
     // i_tmpfile needs the proper cpp_extension for the compiler to do its
     // thing correctly
@@ -1724,7 +1731,8 @@ hash_common_info(struct args* args,
 // modes and calculate the result name. Returns the result name on success,
 // otherwise NULL. Caller frees.
 static struct digest*
-calculate_result_name(struct args* args,
+calculate_result_name(Context& ctx,
+                      struct args* args,
                       struct args* preprocessor_args,
                       struct hash* hash,
                       bool direct_mode)
@@ -1966,10 +1974,11 @@ calculate_result_name(struct args* args,
     //     share manifests and a/r.h exists.
     // * The expansion of __FILE__ may be incorrect.
     hash_delimiter(hash, "inputfile");
-    hash_string(hash, input_file);
+    hash_string(hash, ctx.args_info.input_file);
 
     hash_delimiter(hash, "sourcecode");
-    int result = hash_source_code_file(g_config, hash, input_file);
+    int result =
+      hash_source_code_file(g_config, hash, ctx.args_info.input_file.c_str());
     if (result & HASH_SOURCE_CODE_ERROR) {
       stats_update(STATS_ERROR);
       failed();
@@ -2003,13 +2012,13 @@ calculate_result_name(struct args* args,
   } else {
     assert(preprocessor_args);
     if (arch_args_size == 0) {
-      result_name = get_result_name_from_cpp(preprocessor_args, hash);
+      result_name = get_result_name_from_cpp(ctx, preprocessor_args, hash);
       cc_log("Got result name from preprocessor");
     } else {
       args_add(preprocessor_args, "-arch");
       for (size_t i = 0; i < arch_args_size; ++i) {
         args_add(preprocessor_args, arch_args[i]);
-        result_name = get_result_name_from_cpp(preprocessor_args, hash);
+        result_name = get_result_name_from_cpp(ctx, preprocessor_args, hash);
         cc_log("Got result name from preprocessor with -arch %s", arch_args[i]);
         if (i != arch_args_size - 1) {
           free(result_name);
@@ -3535,7 +3544,6 @@ cc_reset(void)
   free_and_nullify(included_pch_file);
   args_free(orig_args);
   orig_args = NULL;
-  free_and_nullify(input_file);
   free_and_nullify(output_obj);
   free_and_nullify(output_dep);
   free_and_nullify(output_cov);
@@ -3605,7 +3613,7 @@ configuration_printer(const std::string& key,
 }
 
 static void cache_compilation(int argc, char* argv[]) ATTR_NORETURN;
-static void do_cache_compilation(char* argv[]) ATTR_NORETURN;
+static void do_cache_compilation(Context& ctx, char* argv[]) ATTR_NORETURN;
 
 // The entry point when invoked to cache a compilation.
 static void
@@ -3621,14 +3629,13 @@ cache_compilation(int argc, char* argv[])
   orig_args = args_init(argc, argv);
 
   Context& ctx = initialize();
-  (void)ctx;
 
   MTR_BEGIN("main", "find_compiler");
   find_compiler(argv);
   MTR_END("main", "find_compiler");
 
   try {
-    do_cache_compilation(argv);
+    do_cache_compilation(ctx, argv);
   } catch (const Failure& e) {
     if (e.stat() != STATS_NONE) {
       stats_update(e.stat());
@@ -3648,7 +3655,7 @@ cache_compilation(int argc, char* argv[])
 }
 
 static void
-do_cache_compilation(char* argv[])
+do_cache_compilation(Context& ctx, char* argv[])
 {
   MTR_BEGIN("main", "clean_up_internal_tempdir");
   if (g_config.temporary_dir().empty()) {
@@ -3690,8 +3697,7 @@ do_cache_compilation(char* argv[])
   struct args* compiler_args;
   MTR_BEGIN("main", "process_args");
 
-  ArgsInfo args_info;
-  if (!cc_process_args(args_info,
+  if (!cc_process_args(ctx.args_info,
                        g_config,
                        orig_args,
                        &preprocessor_args,
@@ -3700,34 +3706,32 @@ do_cache_compilation(char* argv[])
     failed(); // stats_update is called in cc_process_args.
   }
 
-  input_file = x_strdup(args_info.input_file.c_str());
-
-  output_obj = x_strdup(args_info.output_obj.c_str());
-  output_dep = x_strdup(args_info.output_dep.c_str());
-  output_cov = x_strdup(args_info.output_cov.c_str());
-  output_su = x_strdup(args_info.output_su.c_str());
-  output_dia = x_strdup(args_info.output_dia.c_str());
-  output_dwo = x_strdup(args_info.output_dwo.c_str());
+  output_obj = x_strdup(ctx.args_info.output_obj.c_str());
+  output_dep = x_strdup(ctx.args_info.output_dep.c_str());
+  output_cov = x_strdup(ctx.args_info.output_cov.c_str());
+  output_su = x_strdup(ctx.args_info.output_su.c_str());
+  output_dia = x_strdup(ctx.args_info.output_dia.c_str());
+  output_dwo = x_strdup(ctx.args_info.output_dwo.c_str());
 
-  actual_language = x_strdup(args_info.actual_language.c_str());
+  actual_language = x_strdup(ctx.args_info.actual_language.c_str());
 
-  generating_dependencies = args_info.generating_dependencies;
-  generating_coverage = args_info.generating_coverage;
-  generating_stackusage = args_info.generating_stackusage;
-  generating_diagnostics = args_info.generating_diagnostics;
-  seen_split_dwarf = args_info.seen_split_dwarf;
-  profile_arcs = args_info.profile_arcs;
-  profile_dir = x_strdup(args_info.profile_dir.c_str());
+  generating_dependencies = ctx.args_info.generating_dependencies;
+  generating_coverage = ctx.args_info.generating_coverage;
+  generating_stackusage = ctx.args_info.generating_stackusage;
+  generating_diagnostics = ctx.args_info.generating_diagnostics;
+  seen_split_dwarf = ctx.args_info.seen_split_dwarf;
+  profile_arcs = ctx.args_info.profile_arcs;
+  profile_dir = x_strdup(ctx.args_info.profile_dir.c_str());
 
-  direct_i_file = args_info.direct_i_file;
-  output_is_precompiled_header = args_info.output_is_precompiled_header;
-  profile_use = args_info.profile_use;
-  profile_generate = args_info.profile_generate;
-  using_precompiled_header = args_info.using_precompiled_header;
+  direct_i_file = ctx.args_info.direct_i_file;
+  output_is_precompiled_header = ctx.args_info.output_is_precompiled_header;
+  profile_use = ctx.args_info.profile_use;
+  profile_generate = ctx.args_info.profile_generate;
+  using_precompiled_header = ctx.args_info.using_precompiled_header;
 
-  arch_args_size = args_info.arch_args_size;
-  for (size_t i = 0; i < args_info.arch_args_size; ++i) {
-    arch_args[i] = x_strdup(args_info.arch_args[i]);
+  arch_args_size = ctx.args_info.arch_args_size;
+  for (size_t i = 0; i < ctx.args_info.arch_args_size; ++i) {
+    arch_args[i] = x_strdup(ctx.args_info.arch_args[i]);
   }
 
   MTR_END("main", "process_args");
@@ -3739,7 +3743,7 @@ do_cache_compilation(char* argv[])
     g_config.set_depend_mode(false);
   }
 
-  cc_log("Source file: %s", input_file);
+  cc_log("Source file: %s", ctx.args_info.input_file.c_str());
   if (generating_dependencies) {
     cc_log("Dependency file: %s", output_dep);
   }
@@ -3778,7 +3782,7 @@ do_cache_compilation(char* argv[])
   init_hash_debug(common_hash, output_obj, 'c', "COMMON", debug_text_file);
 
   MTR_BEGIN("hash", "common_hash");
-  hash_common_info(preprocessor_args, common_hash, args_info);
+  hash_common_info(preprocessor_args, common_hash, ctx.args_info);
   MTR_END("hash", "common_hash");
 
   // Try to find the hash using the manifest.
@@ -3795,7 +3799,7 @@ do_cache_compilation(char* argv[])
     cc_log("Trying direct lookup");
     MTR_BEGIN("hash", "direct_hash");
     result_name =
-      calculate_result_name(args_to_hash, nullptr, direct_hash, true);
+      calculate_result_name(ctx, args_to_hash, nullptr, direct_hash, true);
     MTR_END("hash", "direct_hash");
     if (result_name) {
       update_cached_result_globals(result_name);
@@ -3828,8 +3832,8 @@ do_cache_compilation(char* argv[])
       cpp_hash, output_obj, 'p', "PREPROCESSOR MODE", debug_text_file);
 
     MTR_BEGIN("hash", "cpp_hash");
-    result_name =
-      calculate_result_name(args_to_hash, preprocessor_args, cpp_hash, false);
+    result_name = calculate_result_name(
+      ctx, args_to_hash, preprocessor_args, cpp_hash, false);
     MTR_END("hash", "cpp_hash");
     if (!result_name) {
       fatal("internal error: calculate_result_name returned NULL for cpp");
@@ -3875,7 +3879,8 @@ do_cache_compilation(char* argv[])
 
   // Run real compiler, sending output to cache.
   MTR_BEGIN("cache", "to_cache");
-  to_cache(compiler_args, args_info.depend_extra_args, depend_mode_hash);
+  to_cache(
+    ctx, compiler_args, ctx.args_info.depend_extra_args, depend_mode_hash);
   MTR_END("cache", "to_cache");
 
   x_exit(0);
index 5785ec040caf9fa0ee6d63ca917d1a6340e98437..122ceb9a2bea2f0d86c89e366d20e7df71a59ead 100644 (file)
@@ -25,9 +25,6 @@ char* current_working_dir = nullptr;
 extern struct args* orig_args;
 struct args* orig_args = nullptr;
 
-// The source file.
-char* input_file;
-
 // The output file being compiled to.
 char* output_obj;
 
index 9ef8db588154924d1f6b6ef4e3175303dfb5aa1e..1adc3cf0f753dece550b3893071247b5dad61386 100644 (file)
@@ -34,8 +34,6 @@ extern unsigned lock_staleness_limit;
 
 extern struct args* orig_args;
 
-extern char* input_file;
-
 extern char* output_obj;
 
 extern char* output_dep;
index 2d52eb56939c91973247289715f669225cce1415..69ee5d60fa62f11c584db2af2aab9d847370192c 100644 (file)
@@ -18,8 +18,8 @@
 
 // This file contains tests for the processing of compiler arguments.
 
-#include "../src/ArgsInfo.hpp"
 #include "../src/Config.hpp"
+#include "../src/Context.hpp"
 #include "../src/args.hpp"
 #include "../src/ccache.hpp"
 #include "../src/legacy_globals.hpp"
@@ -64,50 +64,48 @@ get_posix_path(char* path)
 #endif
 }
 
-bool cc_process_args(struct args* args,
+bool cc_process_args(Context& ctx,
+                     struct args* args,
                      struct args** preprocessor_args,
                      struct args** extra_args_to_hash,
                      struct args** compiler_args);
 
 bool
-cc_process_args(struct args* args,
+cc_process_args(Context& ctx,
+                struct args* args,
                 struct args** preprocessor_args,
                 struct args** extra_args_to_hash,
                 struct args** compiler_args)
 {
-  ArgsInfo argsinfo;
-
-  bool success = cc_process_args(argsinfo,
+  bool success = cc_process_args(ctx.args_info,
                                  g_config,
                                  args,
                                  preprocessor_args,
                                  extra_args_to_hash,
                                  compiler_args);
 
-  input_file = x_strdup(argsinfo.input_file.c_str());
-
-  output_obj = x_strdup(argsinfo.output_obj.c_str());
-  output_dep = x_strdup(argsinfo.output_dep.c_str());
-  output_cov = x_strdup(argsinfo.output_cov.c_str());
-  output_su = x_strdup(argsinfo.output_su.c_str());
-  output_dia = x_strdup(argsinfo.output_dia.c_str());
-  output_dwo = x_strdup(argsinfo.output_dwo.c_str());
-
-  actual_language = x_strdup(argsinfo.actual_language.c_str());
-
-  generating_dependencies = argsinfo.generating_dependencies;
-  generating_coverage = argsinfo.generating_coverage;
-  generating_stackusage = argsinfo.generating_stackusage;
-  generating_diagnostics = argsinfo.generating_diagnostics;
-  seen_split_dwarf = argsinfo.seen_split_dwarf;
-  profile_arcs = argsinfo.profile_arcs;
-  profile_dir = x_strdup(argsinfo.profile_dir.c_str());
-
-  direct_i_file = argsinfo.direct_i_file;
-  output_is_precompiled_header = argsinfo.output_is_precompiled_header;
-  profile_use = argsinfo.profile_use;
-  profile_generate = argsinfo.profile_generate;
-  using_precompiled_header = argsinfo.using_precompiled_header;
+  output_obj = x_strdup(ctx.args_info.output_obj.c_str());
+  output_dep = x_strdup(ctx.args_info.output_dep.c_str());
+  output_cov = x_strdup(ctx.args_info.output_cov.c_str());
+  output_su = x_strdup(ctx.args_info.output_su.c_str());
+  output_dia = x_strdup(ctx.args_info.output_dia.c_str());
+  output_dwo = x_strdup(ctx.args_info.output_dwo.c_str());
+
+  actual_language = x_strdup(ctx.args_info.actual_language.c_str());
+
+  generating_dependencies = ctx.args_info.generating_dependencies;
+  generating_coverage = ctx.args_info.generating_coverage;
+  generating_stackusage = ctx.args_info.generating_stackusage;
+  generating_diagnostics = ctx.args_info.generating_diagnostics;
+  seen_split_dwarf = ctx.args_info.seen_split_dwarf;
+  profile_arcs = ctx.args_info.profile_arcs;
+  profile_dir = x_strdup(ctx.args_info.profile_dir.c_str());
+
+  direct_i_file = ctx.args_info.direct_i_file;
+  output_is_precompiled_header = ctx.args_info.output_is_precompiled_header;
+  profile_use = ctx.args_info.profile_use;
+  profile_generate = ctx.args_info.profile_generate;
+  using_precompiled_header = ctx.args_info.using_precompiled_header;
 
   return success;
 }
@@ -116,11 +114,13 @@ TEST_SUITE(argument_processing)
 
 TEST(dash_E_should_result_in_called_for_preprocessing)
 {
+  Context ctx;
+
   struct args* orig = args_init_from_string("cc -c foo.c -E");
   struct args *preprocessed, *compiler;
 
   create_file("foo.c", "");
-  CHECK(!cc_process_args(orig, &preprocessed, NULL, &compiler));
+  CHECK(!cc_process_args(ctx, orig, &preprocessed, NULL, &compiler));
   CHECK_INT_EQ(1, stats_get_pending(STATS_PREPROCESSING));
 
   args_free(orig);
@@ -128,11 +128,13 @@ TEST(dash_E_should_result_in_called_for_preprocessing)
 
 TEST(dash_M_should_be_unsupported)
 {
+  Context ctx;
+
   struct args* orig = args_init_from_string("cc -c foo.c -M");
   struct args *preprocessed, *compiler;
 
   create_file("foo.c", "");
-  CHECK(!cc_process_args(orig, &preprocessed, NULL, &compiler));
+  CHECK(!cc_process_args(ctx, orig, &preprocessed, NULL, &compiler));
   CHECK_INT_EQ(1, stats_get_pending(STATS_UNSUPPORTED_OPTION));
 
   args_free(orig);
@@ -140,6 +142,8 @@ TEST(dash_M_should_be_unsupported)
 
 TEST(dependency_args_to_preprocessor_if_run_second_cpp_is_false)
 {
+  Context ctx;
+
 #define DEP_ARGS                                                               \
   "-MD -MMD -MP -MF foo.d -MT mt1 -MT mt2 -MQ mq1 -MQ mq2 -Wp,-MD,wpmd"        \
   " -Wp,-MMD,wpmmd -Wp,-MP -Wp,-MT,wpmt -Wp,-MQ,wpmq -Wp,-MF,wpf"
@@ -155,7 +159,7 @@ TEST(dependency_args_to_preprocessor_if_run_second_cpp_is_false)
   create_file("foo.c", "");
 
   g_config.set_run_second_cpp(false);
-  CHECK(cc_process_args(orig, &act_cpp, &act_extra, &act_cc));
+  CHECK(cc_process_args(ctx, orig, &act_cpp, &act_extra, &act_cc));
   CHECK_ARGS_EQ_FREE12(exp_cpp, act_cpp);
   CHECK_ARGS_EQ_FREE12(exp_extra, act_extra);
   CHECK_ARGS_EQ_FREE12(exp_cc, act_cc);
@@ -165,6 +169,8 @@ TEST(dependency_args_to_preprocessor_if_run_second_cpp_is_false)
 
 TEST(dependency_args_to_compiler_if_run_second_cpp_is_true)
 {
+  Context ctx;
+
 #define DEP_ARGS                                                               \
   "-MD -MMD -MP -MF foo.d -MT mt1 -MT mt2 -MQ mq1 -MQ mq2 -Wp,-MD,wpmd"        \
   " -Wp,-MMD,wpmmd -Wp,-MP -Wp,-MT,wpmt -Wp,-MQ,wpmq -Wp,-MF,wpf"
@@ -179,7 +185,7 @@ TEST(dependency_args_to_compiler_if_run_second_cpp_is_true)
   struct args* act_cc = NULL;
   create_file("foo.c", "");
 
-  CHECK(cc_process_args(orig, &act_cpp, &act_extra, &act_cc));
+  CHECK(cc_process_args(ctx, orig, &act_cpp, &act_extra, &act_cc));
   CHECK_ARGS_EQ_FREE12(exp_cpp, act_cpp);
   CHECK_ARGS_EQ_FREE12(exp_extra, act_extra);
   CHECK_ARGS_EQ_FREE12(exp_cc, act_cc);
@@ -189,6 +195,8 @@ TEST(dependency_args_to_compiler_if_run_second_cpp_is_true)
 
 TEST(cpp_only_args_to_preprocessor_if_run_second_cpp_is_false)
 {
+  Context ctx;
+
 #define CPP_ARGS                                                               \
   "-I. -idirafter . -iframework. -imacros . -imultilib . -include test.h"      \
   " -include-pch test.pch -iprefix . -iquote . -isysroot . -isystem ."         \
@@ -210,7 +218,7 @@ TEST(cpp_only_args_to_preprocessor_if_run_second_cpp_is_false)
   create_file("foo.c", "");
 
   g_config.set_run_second_cpp(false);
-  CHECK(cc_process_args(orig, &act_cpp, &act_extra, &act_cc));
+  CHECK(cc_process_args(ctx, orig, &act_cpp, &act_extra, &act_cc));
   CHECK_ARGS_EQ_FREE12(exp_cpp, act_cpp);
   CHECK_ARGS_EQ_FREE12(exp_extra, act_extra);
   CHECK_ARGS_EQ_FREE12(exp_cc, act_cc);
@@ -220,6 +228,8 @@ TEST(cpp_only_args_to_preprocessor_if_run_second_cpp_is_false)
 
 TEST(cpp_only_args_to_preprocessor_and_compiler_if_run_second_cpp_is_true)
 {
+  Context ctx;
+
 #define CPP_ARGS                                                               \
   "-I. -idirafter . -iframework. -imacros . -imultilib . -include test.h"      \
   " -include-pch test.pch -iprefix . -iquote . -isysroot . -isystem ."         \
@@ -240,7 +250,7 @@ TEST(cpp_only_args_to_preprocessor_and_compiler_if_run_second_cpp_is_true)
   struct args* act_cc = NULL;
   create_file("foo.c", "");
 
-  CHECK(cc_process_args(orig, &act_cpp, &act_extra, &act_cc));
+  CHECK(cc_process_args(ctx, orig, &act_cpp, &act_extra, &act_cc));
   CHECK_ARGS_EQ_FREE12(exp_cpp, act_cpp);
   CHECK_ARGS_EQ_FREE12(exp_extra, act_extra);
   CHECK_ARGS_EQ_FREE12(exp_cc, act_cc);
@@ -250,6 +260,8 @@ TEST(cpp_only_args_to_preprocessor_and_compiler_if_run_second_cpp_is_true)
 
 TEST(dependency_args_that_take_an_argument_should_not_require_space_delimiter)
 {
+  Context ctx;
+
 #define DEP_ARGS "-MMD -MFfoo.d -MT mt -MTmt -MQmq"
   struct args* orig =
     args_init_from_string("cc -c " DEP_ARGS " foo.c -o foo.o");
@@ -262,7 +274,7 @@ TEST(dependency_args_that_take_an_argument_should_not_require_space_delimiter)
   struct args* act_cc = NULL;
   create_file("foo.c", "");
 
-  CHECK(cc_process_args(orig, &act_cpp, &act_extra, &act_cc));
+  CHECK(cc_process_args(ctx, orig, &act_cpp, &act_extra, &act_cc));
   CHECK_ARGS_EQ_FREE12(exp_cpp, act_cpp);
   CHECK_ARGS_EQ_FREE12(exp_extra, act_extra);
   CHECK_ARGS_EQ_FREE12(exp_cc, act_cc);
@@ -272,6 +284,8 @@ TEST(dependency_args_that_take_an_argument_should_not_require_space_delimiter)
 
 TEST(MQ_flag_should_not_be_added_if_run_second_cpp_is_true)
 {
+  Context ctx;
+
   struct args* orig =
     args_init_from_string("cc -c -MD foo.c -MF foo.d -o foo.o");
   struct args* exp_cpp = args_init_from_string("cc");
@@ -282,7 +296,7 @@ TEST(MQ_flag_should_not_be_added_if_run_second_cpp_is_true)
   struct args* act_cc = NULL;
   create_file("foo.c", "");
 
-  CHECK(cc_process_args(orig, &act_cpp, &act_extra, &act_cc));
+  CHECK(cc_process_args(ctx, orig, &act_cpp, &act_extra, &act_cc));
   CHECK_ARGS_EQ_FREE12(exp_cpp, act_cpp);
   CHECK_ARGS_EQ_FREE12(exp_extra, act_extra);
   CHECK_ARGS_EQ_FREE12(exp_cc, act_cc);
@@ -292,6 +306,8 @@ TEST(MQ_flag_should_not_be_added_if_run_second_cpp_is_true)
 
 TEST(MQ_flag_should_be_added_if_run_second_cpp_is_false)
 {
+  Context ctx;
+
   struct args* orig =
     args_init_from_string("cc -c -MD foo.c -MF foo.d -o foo.o");
   struct args* exp_cpp = args_init_from_string("cc -MD -MF foo.d -MQ foo.o");
@@ -303,7 +319,7 @@ TEST(MQ_flag_should_be_added_if_run_second_cpp_is_false)
   create_file("foo.c", "");
 
   g_config.set_run_second_cpp(false);
-  CHECK(cc_process_args(orig, &act_cpp, &act_extra, &act_cc));
+  CHECK(cc_process_args(ctx, orig, &act_cpp, &act_extra, &act_cc));
   CHECK_ARGS_EQ_FREE12(exp_cpp, act_cpp);
   CHECK_ARGS_EQ_FREE12(exp_extra, act_extra);
   CHECK_ARGS_EQ_FREE12(exp_cc, act_cc);
@@ -313,6 +329,8 @@ TEST(MQ_flag_should_be_added_if_run_second_cpp_is_false)
 
 TEST(MF_should_be_added_if_run_second_cpp_is_false)
 {
+  Context ctx;
+
   struct args* orig = args_init_from_string("cc -c -MD foo.c -o foo.o");
   struct args* exp_cpp = args_init_from_string("cc -MD -MF foo.d -MQ foo.o");
   struct args* exp_extra = args_init(0, NULL);
@@ -324,7 +342,7 @@ TEST(MF_should_be_added_if_run_second_cpp_is_false)
   create_file("foo.c", "");
 
   g_config.set_run_second_cpp(false);
-  CHECK(cc_process_args(orig, &act_cpp, &act_extra, &act_cc));
+  CHECK(cc_process_args(ctx, orig, &act_cpp, &act_extra, &act_cc));
   CHECK_ARGS_EQ_FREE12(exp_cpp, act_cpp);
   CHECK_ARGS_EQ_FREE12(exp_extra, act_extra);
   CHECK_ARGS_EQ_FREE12(exp_cc, act_cc);
@@ -334,6 +352,8 @@ TEST(MF_should_be_added_if_run_second_cpp_is_false)
 
 TEST(MF_should_not_be_added_if_run_second_cpp_is_true)
 {
+  Context ctx;
+
   struct args* orig = args_init_from_string("cc -c -MD foo.c -o foo.o");
   struct args* exp_cpp = args_init_from_string("cc");
   struct args* exp_extra = args_init_from_string("-MD");
@@ -344,7 +364,7 @@ TEST(MF_should_not_be_added_if_run_second_cpp_is_true)
 
   create_file("foo.c", "");
 
-  CHECK(cc_process_args(orig, &act_cpp, &act_extra, &act_cc));
+  CHECK(cc_process_args(ctx, orig, &act_cpp, &act_extra, &act_cc));
   CHECK_ARGS_EQ_FREE12(exp_cpp, act_cpp);
   CHECK_ARGS_EQ_FREE12(exp_extra, act_extra);
   CHECK_ARGS_EQ_FREE12(exp_cc, act_cc);
@@ -354,6 +374,8 @@ TEST(MF_should_not_be_added_if_run_second_cpp_is_true)
 
 TEST(equal_sign_after_MF_should_be_removed)
 {
+  Context ctx;
+
   struct args* orig = args_init_from_string("cc -c -MF=path foo.c -o foo.o");
   struct args* exp_cpp = args_init_from_string("cc");
   struct args* exp_extra = args_init_from_string("-MFpath");
@@ -364,7 +386,7 @@ TEST(equal_sign_after_MF_should_be_removed)
 
   create_file("foo.c", "");
 
-  CHECK(cc_process_args(orig, &act_cpp, &act_extra, &act_cc));
+  CHECK(cc_process_args(ctx, orig, &act_cpp, &act_extra, &act_cc));
   CHECK_ARGS_EQ_FREE12(exp_cpp, act_cpp);
   CHECK_ARGS_EQ_FREE12(exp_extra, act_extra);
   CHECK_ARGS_EQ_FREE12(exp_cc, act_cc);
@@ -374,6 +396,8 @@ TEST(equal_sign_after_MF_should_be_removed)
 
 TEST(sysroot_should_be_rewritten_if_basedir_is_used)
 {
+  Context ctx;
+
   extern char* current_working_dir;
   char* arg_string;
   struct args* orig;
@@ -388,7 +412,7 @@ TEST(sysroot_should_be_rewritten_if_basedir_is_used)
   orig = args_init_from_string(arg_string);
   free(arg_string);
 
-  CHECK(cc_process_args(orig, &act_cpp, &act_extra, &act_cc));
+  CHECK(cc_process_args(ctx, orig, &act_cpp, &act_extra, &act_cc));
   CHECK_STR_EQ(act_cpp->argv[1], "--sysroot=./foo/bar");
 
   args_free(orig);
@@ -398,6 +422,8 @@ TEST(sysroot_should_be_rewritten_if_basedir_is_used)
 
 TEST(sysroot_with_separate_argument_should_be_rewritten_if_basedir_is_used)
 {
+  Context ctx;
+
   extern char* current_working_dir;
   char* arg_string;
   struct args* orig;
@@ -412,7 +438,7 @@ TEST(sysroot_with_separate_argument_should_be_rewritten_if_basedir_is_used)
   orig = args_init_from_string(arg_string);
   free(arg_string);
 
-  CHECK(cc_process_args(orig, &act_cpp, &act_extra, &act_cc));
+  CHECK(cc_process_args(ctx, orig, &act_cpp, &act_extra, &act_cc));
   CHECK_STR_EQ(act_cpp->argv[1], "--sysroot");
   CHECK_STR_EQ(act_cpp->argv[2], "./foo");
 
@@ -423,6 +449,8 @@ TEST(sysroot_with_separate_argument_should_be_rewritten_if_basedir_is_used)
 
 TEST(MF_flag_with_immediate_argument_should_work_as_last_argument)
 {
+  Context ctx;
+
   struct args* orig =
     args_init_from_string("cc -c foo.c -o foo.o -MMD -MT bar -MFfoo.d");
   struct args* exp_cpp = args_init_from_string("cc");
@@ -434,7 +462,7 @@ TEST(MF_flag_with_immediate_argument_should_work_as_last_argument)
 
   create_file("foo.c", "");
 
-  CHECK(cc_process_args(orig, &act_cpp, &act_extra, &act_cc));
+  CHECK(cc_process_args(ctx, orig, &act_cpp, &act_extra, &act_cc));
   CHECK_ARGS_EQ_FREE12(exp_cpp, act_cpp);
   CHECK_ARGS_EQ_FREE12(exp_extra, act_extra);
   CHECK_ARGS_EQ_FREE12(exp_cc, act_cc);
@@ -444,6 +472,8 @@ TEST(MF_flag_with_immediate_argument_should_work_as_last_argument)
 
 TEST(MT_flag_with_immediate_argument_should_work_as_last_argument)
 {
+  Context ctx;
+
   struct args* orig =
     args_init_from_string("cc -c foo.c -o foo.o -MMD -MFfoo.d -MT foo -MTbar");
   struct args* exp_cpp = args_init_from_string("cc");
@@ -457,7 +487,7 @@ TEST(MT_flag_with_immediate_argument_should_work_as_last_argument)
 
   create_file("foo.c", "");
 
-  CHECK(cc_process_args(orig, &act_cpp, &act_extra, &act_cc));
+  CHECK(cc_process_args(ctx, orig, &act_cpp, &act_extra, &act_cc));
   CHECK_ARGS_EQ_FREE12(exp_cpp, act_cpp);
   CHECK_ARGS_EQ_FREE12(exp_extra, act_extra);
   CHECK_ARGS_EQ_FREE12(exp_cc, act_cc);
@@ -467,6 +497,8 @@ TEST(MT_flag_with_immediate_argument_should_work_as_last_argument)
 
 TEST(MQ_flag_with_immediate_argument_should_work_as_last_argument)
 {
+  Context ctx;
+
   struct args* orig =
     args_init_from_string("cc -c foo.c -o foo.o -MMD -MFfoo.d -MQ foo -MQbar");
   struct args* exp_cpp = args_init_from_string("cc");
@@ -480,7 +512,7 @@ TEST(MQ_flag_with_immediate_argument_should_work_as_last_argument)
 
   create_file("foo.c", "");
 
-  CHECK(cc_process_args(orig, &act_cpp, &act_extra, &act_cc));
+  CHECK(cc_process_args(ctx, orig, &act_cpp, &act_extra, &act_cc));
   CHECK_ARGS_EQ_FREE12(exp_cpp, act_cpp);
   CHECK_ARGS_EQ_FREE12(exp_extra, act_extra);
   CHECK_ARGS_EQ_FREE12(exp_cc, act_cc);
@@ -490,6 +522,8 @@ TEST(MQ_flag_with_immediate_argument_should_work_as_last_argument)
 
 TEST(MQ_flag_without_immediate_argument_should_not_add_MQobj)
 {
+  Context ctx;
+
   struct args* orig =
     args_init_from_string("gcc -c -MD -MP -MFfoo.d -MQ foo.d foo.c");
   struct args* exp_cpp = args_init_from_string("gcc");
@@ -502,7 +536,7 @@ TEST(MQ_flag_without_immediate_argument_should_not_add_MQobj)
 
   create_file("foo.c", "");
 
-  CHECK(cc_process_args(orig, &act_cpp, &act_extra, &act_cc));
+  CHECK(cc_process_args(ctx, orig, &act_cpp, &act_extra, &act_cc));
   CHECK_ARGS_EQ_FREE12(exp_cpp, act_cpp);
   CHECK_ARGS_EQ_FREE12(exp_extra, act_extra);
   CHECK_ARGS_EQ_FREE12(exp_cc, act_cc);
@@ -512,6 +546,8 @@ TEST(MQ_flag_without_immediate_argument_should_not_add_MQobj)
 
 TEST(MT_flag_without_immediate_argument_should_not_add_MTobj)
 {
+  Context ctx;
+
   struct args* orig =
     args_init_from_string("gcc -c -MD -MP -MFfoo.d -MT foo.d foo.c");
   struct args* exp_cpp = args_init_from_string("gcc");
@@ -524,7 +560,7 @@ TEST(MT_flag_without_immediate_argument_should_not_add_MTobj)
 
   create_file("foo.c", "");
 
-  CHECK(cc_process_args(orig, &act_cpp, &act_extra, &act_cc));
+  CHECK(cc_process_args(ctx, orig, &act_cpp, &act_extra, &act_cc));
   CHECK_ARGS_EQ_FREE12(exp_cpp, act_cpp);
   CHECK_ARGS_EQ_FREE12(exp_extra, act_extra);
   CHECK_ARGS_EQ_FREE12(exp_cc, act_cc);
@@ -534,6 +570,8 @@ TEST(MT_flag_without_immediate_argument_should_not_add_MTobj)
 
 TEST(MQ_flag_with_immediate_argument_should_not_add_MQobj)
 {
+  Context ctx;
+
   struct args* orig =
     args_init_from_string("gcc -c -MD -MP -MFfoo.d -MQfoo.d foo.c");
   struct args* exp_cpp = args_init_from_string("gcc");
@@ -546,7 +584,7 @@ TEST(MQ_flag_with_immediate_argument_should_not_add_MQobj)
 
   create_file("foo.c", "");
 
-  CHECK(cc_process_args(orig, &act_cpp, &act_extra, &act_cc));
+  CHECK(cc_process_args(ctx, orig, &act_cpp, &act_extra, &act_cc));
   CHECK_ARGS_EQ_FREE12(exp_cpp, act_cpp);
   CHECK_ARGS_EQ_FREE12(exp_extra, act_extra);
   CHECK_ARGS_EQ_FREE12(exp_cc, act_cc);
@@ -556,6 +594,8 @@ TEST(MQ_flag_with_immediate_argument_should_not_add_MQobj)
 
 TEST(MT_flag_with_immediate_argument_should_not_add_MQobj)
 {
+  Context ctx;
+
   struct args* orig =
     args_init_from_string("gcc -c -MD -MP -MFfoo.d -MTfoo.d foo.c");
   struct args* exp_cpp = args_init_from_string("gcc");
@@ -568,7 +608,7 @@ TEST(MT_flag_with_immediate_argument_should_not_add_MQobj)
 
   create_file("foo.c", "");
 
-  CHECK(cc_process_args(orig, &act_cpp, &act_extra, &act_cc));
+  CHECK(cc_process_args(ctx, orig, &act_cpp, &act_extra, &act_cc));
   CHECK_ARGS_EQ_FREE12(exp_cpp, act_cpp);
   CHECK_ARGS_EQ_FREE12(exp_extra, act_extra);
   CHECK_ARGS_EQ_FREE12(exp_cc, act_cc);
@@ -578,6 +618,8 @@ TEST(MT_flag_with_immediate_argument_should_not_add_MQobj)
 
 TEST(fprofile_flag_with_existing_dir_should_be_rewritten_to_real_path)
 {
+  Context ctx;
+
   struct args* orig =
     args_init_from_string("gcc -c -fprofile-generate=some/dir foo.c");
   struct args* exp_cpp = args_init_from_string("gcc");
@@ -600,7 +642,7 @@ TEST(fprofile_flag_with_existing_dir_should_be_rewritten_to_real_path)
   args_add(exp_cc, "-c");
   free(s);
 
-  CHECK(cc_process_args(orig, &act_cpp, &act_extra, &act_cc));
+  CHECK(cc_process_args(ctx, orig, &act_cpp, &act_extra, &act_cc));
   CHECK_ARGS_EQ_FREE12(exp_cpp, act_cpp);
   CHECK_ARGS_EQ_FREE12(exp_extra, act_extra);
   CHECK_ARGS_EQ_FREE12(exp_cc, act_cc);
@@ -610,6 +652,8 @@ TEST(fprofile_flag_with_existing_dir_should_be_rewritten_to_real_path)
 
 TEST(fprofile_flag_with_nonexistent_dir_should_not_be_rewritten)
 {
+  Context ctx;
+
   struct args* orig =
     args_init_from_string("gcc -c -fprofile-generate=some/dir foo.c");
   struct args* exp_cpp =
@@ -623,7 +667,7 @@ TEST(fprofile_flag_with_nonexistent_dir_should_not_be_rewritten)
 
   create_file("foo.c", "");
 
-  CHECK(cc_process_args(orig, &act_cpp, &act_extra, &act_cc));
+  CHECK(cc_process_args(ctx, orig, &act_cpp, &act_extra, &act_cc));
   CHECK_ARGS_EQ_FREE12(exp_cpp, act_cpp);
   CHECK_ARGS_EQ_FREE12(exp_extra, act_extra);
   CHECK_ARGS_EQ_FREE12(exp_cc, act_cc);
@@ -633,6 +677,8 @@ TEST(fprofile_flag_with_nonexistent_dir_should_not_be_rewritten)
 
 TEST(isystem_flag_with_separate_arg_should_be_rewritten_if_basedir_is_used)
 {
+  Context ctx;
+
   extern char* current_working_dir;
   char* arg_string;
   struct args* orig;
@@ -647,7 +693,7 @@ TEST(isystem_flag_with_separate_arg_should_be_rewritten_if_basedir_is_used)
   orig = args_init_from_string(arg_string);
   free(arg_string);
 
-  CHECK(cc_process_args(orig, &act_cpp, &act_extra, &act_cc));
+  CHECK(cc_process_args(ctx, orig, &act_cpp, &act_extra, &act_cc));
   CHECK_STR_EQ("./foo", act_cpp->argv[2]);
 
   args_free(orig);
@@ -657,6 +703,8 @@ TEST(isystem_flag_with_separate_arg_should_be_rewritten_if_basedir_is_used)
 
 TEST(isystem_flag_with_concat_arg_should_be_rewritten_if_basedir_is_used)
 {
+  Context ctx;
+
   extern char* current_working_dir;
   char* cwd;
   char* arg_string;
@@ -674,7 +722,7 @@ TEST(isystem_flag_with_concat_arg_should_be_rewritten_if_basedir_is_used)
   orig = args_init_from_string(arg_string);
   free(arg_string);
 
-  CHECK(cc_process_args(orig, &act_cpp, &act_extra, &act_cc));
+  CHECK(cc_process_args(ctx, orig, &act_cpp, &act_extra, &act_cc));
   CHECK_STR_EQ("-isystem./foo", act_cpp->argv[1]);
 
   free(cwd);
@@ -685,6 +733,8 @@ TEST(isystem_flag_with_concat_arg_should_be_rewritten_if_basedir_is_used)
 
 TEST(I_flag_with_concat_arg_should_be_rewritten_if_basedir_is_used)
 {
+  Context ctx;
+
   extern char* current_working_dir;
   char* cwd;
   char* arg_string;
@@ -702,7 +752,7 @@ TEST(I_flag_with_concat_arg_should_be_rewritten_if_basedir_is_used)
   orig = args_init_from_string(arg_string);
   free(arg_string);
 
-  CHECK(cc_process_args(orig, &act_cpp, &act_extra, &act_cc));
+  CHECK(cc_process_args(ctx, orig, &act_cpp, &act_extra, &act_cc));
   CHECK_STR_EQ("-I./foo", act_cpp->argv[1]);
 
   free(cwd);
@@ -713,6 +763,8 @@ TEST(I_flag_with_concat_arg_should_be_rewritten_if_basedir_is_used)
 
 TEST(debug_flag_order_with_known_option_first)
 {
+  Context ctx;
+
   struct args* orig = args_init_from_string("cc -g1 -gsplit-dwarf foo.c -c");
   struct args* exp_cpp = args_init_from_string("cc -g1 -gsplit-dwarf");
   struct args* exp_extra = args_init(0, NULL);
@@ -722,7 +774,7 @@ TEST(debug_flag_order_with_known_option_first)
   struct args* act_cc = NULL;
 
   create_file("foo.c", "");
-  CHECK(cc_process_args(orig, &act_cpp, &act_extra, &act_cc));
+  CHECK(cc_process_args(ctx, orig, &act_cpp, &act_extra, &act_cc));
   CHECK_ARGS_EQ_FREE12(exp_cpp, act_cpp);
   CHECK_ARGS_EQ_FREE12(exp_extra, act_extra);
   CHECK_ARGS_EQ_FREE12(exp_cc, act_cc);
@@ -732,6 +784,8 @@ TEST(debug_flag_order_with_known_option_first)
 
 TEST(debug_flag_order_with_known_option_last)
 {
+  Context ctx;
+
   struct args* orig = args_init_from_string("cc -gsplit-dwarf -g1 foo.c -c");
   struct args* exp_cpp = args_init_from_string("cc -gsplit-dwarf -g1");
   struct args* exp_extra = args_init(0, NULL);
@@ -741,7 +795,7 @@ TEST(debug_flag_order_with_known_option_last)
   struct args* act_cc = NULL;
 
   create_file("foo.c", "");
-  CHECK(cc_process_args(orig, &act_cpp, &act_extra, &act_cc));
+  CHECK(cc_process_args(ctx, orig, &act_cpp, &act_extra, &act_cc));
   CHECK_ARGS_EQ_FREE12(exp_cpp, act_cpp);
   CHECK_ARGS_EQ_FREE12(exp_extra, act_extra);
   CHECK_ARGS_EQ_FREE12(exp_cc, act_cc);
@@ -751,6 +805,8 @@ TEST(debug_flag_order_with_known_option_last)
 
 TEST(options_not_to_be_passed_to_the_preprocesor)
 {
+  Context ctx;
+
   struct args* orig = args_init_from_string(
     "cc -Wa,foo foo.c -g -c -DX -Werror -Xlinker fie -Xlinker,fum -Wno-error");
   struct args* exp_cpp = args_init_from_string("cc -g -DX");
@@ -763,7 +819,7 @@ TEST(options_not_to_be_passed_to_the_preprocesor)
   struct args* act_cc = NULL;
 
   create_file("foo.c", "");
-  CHECK(cc_process_args(orig, &act_cpp, &act_extra, &act_cc));
+  CHECK(cc_process_args(ctx, orig, &act_cpp, &act_extra, &act_cc));
   CHECK_ARGS_EQ_FREE12(exp_cpp, act_cpp);
   CHECK_ARGS_EQ_FREE12(exp_extra, act_extra);
   CHECK_ARGS_EQ_FREE12(exp_cc, act_cc);