From: Joel Rosdahl Date: Sun, 3 Dec 2023 20:11:33 +0000 (+0100) Subject: fix: Handle -Xclang -ast-dump et al correctly X-Git-Tag: v4.9~14 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=78b2ed0884f1e48aa5f00b26af2eedc7d9e7a390;p=thirdparty%2Fccache.git fix: Handle -Xclang -ast-dump et al correctly Fixes #1356. --- diff --git a/src/argprocessing.cpp b/src/argprocessing.cpp index 9c546e21e..874d41050 100644 --- a/src/argprocessing.cpp +++ b/src/argprocessing.cpp @@ -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; } diff --git a/src/compopt.cpp b/src/compopt.cpp index d9ba6bd8f..5943e3fab 100644 --- a/src/compopt.cpp +++ b/src/compopt.cpp @@ -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},