]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
fix: Handle -Xclang -ast-dump et al correctly
authorJoel Rosdahl <joel@rosdahl.net>
Sun, 3 Dec 2023 20:11:33 +0000 (21:11 +0100)
committerJoel Rosdahl <joel@rosdahl.net>
Sun, 10 Dec 2023 20:01:46 +0000 (21:01 +0100)
Fixes #1356.

src/argprocessing.cpp
src/compopt.cpp

index 9c546e21e2434085f5949d513bbd454662513d0f..874d41050d19c71236110cd19cb130d8f042a56a 100644 (file)
@@ -472,8 +472,17 @@ process_option_arg(const Context& ctx,
   }
 
   // Handle options that should not be passed to the preprocessor.
-  if (compopt_affects_compiler_output(arg)) {
+  if (compopt_affects_compiler_output(arg)
+      || (i + 1 < args.size() && arg == "-Xclang"
+          && compopt_affects_compiler_output(args[i + 1]))) {
+    if (i + 1 < args.size() && arg == "-Xclang") {
+      state.compiler_only_args.push_back(args[i]);
+      ++i;
+      arg = make_dash_option(ctx.config, args[i]);
+    }
     state.compiler_only_args.push_back(args[i]);
+    // Note: "-Xclang -option-that-takes-arg -Xclang arg" is not handled below
+    // yet.
     if (compopt_takes_arg(arg)
         || (config.compiler_type() == CompilerType::nvcc && arg == "-Werror")) {
       if (i == args.size() - 1) {
@@ -485,7 +494,13 @@ process_option_arg(const Context& ctx,
     }
     return Statistic::none;
   }
-  if (compopt_prefix_affects_compiler_output(arg)) {
+  if (compopt_prefix_affects_compiler_output(arg)
+      || (i + 1 < args.size() && arg == "-Xclang"
+          && compopt_prefix_affects_compiler_output(args[i + 1]))) {
+    if (i + 1 < args.size() && arg == "-Xclang") {
+      state.compiler_only_args.push_back(args[i]);
+      ++i;
+    }
     state.compiler_only_args.push_back(args[i]);
     return Statistic::none;
   }
index d9ba6bd8f37ac2d9f1c0466a80b96e69f2e91bb8..5943e3fab8c812106bc06301dd18e94dcd98c805 100644 (file)
@@ -99,6 +99,17 @@ const CompOpt compopts[] = {
   {"-all_load", AFFECTS_COMP},
   {"-analyze", TOO_HARD}, // Clang
   {"-arch", TAKES_ARG},
+  {"-ast-dump", AFFECTS_COMP},                         // Clang
+  {"-ast-dump-all", AFFECTS_COMP},                     // Clang
+  {"-ast-dump-all=", AFFECTS_COMP | TAKES_CONCAT_ARG}, // Clang
+  {"-ast-dump-decl-types", AFFECTS_COMP},              // Clang
+  {"-ast-dump-filter", AFFECTS_COMP | TAKES_ARG},      // Clang
+  {"-ast-dump-lookups", AFFECTS_COMP},                 // Clang
+  {"-ast-dump=", AFFECTS_COMP | TAKES_CONCAT_ARG},     // Clang
+  {"-ast-list", AFFECTS_COMP},                         // Clang
+  {"-ast-merge", TOO_HARD | TAKES_ARG},                // Clang
+  {"-ast-print", AFFECTS_COMP},                        // Clang
+  {"-ast-view", TOO_HARD},                             // Clang
   {"-aux-info", TAKES_ARG},
   {"-b", TAKES_ARG},
   {"-bind_at_load", AFFECTS_COMP},