summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Rosdahl <joel@rosdahl.net>2022-05-05 21:20:04 +0200
committerJoel Rosdahl <joel@rosdahl.net>2022-05-05 21:52:57 +0200
commit09dea223466e3bd27c8b84f1cc4acbfa1509e061 (patch)
tree2cc95f507cafc2fb50e3c9f973016d92b10cd30b
parent2d165f8f943bae750163cdd9b240f29b6eaf36f7 (diff)
downloadccache-09dea223466e3bd27c8b84f1cc4acbfa1509e061.tar.gz
fix: Handle MSVC /Fp and /Yu options with concatenated path again
Regression in c8fb539523c801bf15591c395c3029b4530a7a2f. See #1063.
-rw-r--r--src/argprocessing.cpp26
1 files changed, 9 insertions, 17 deletions
diff --git a/src/argprocessing.cpp b/src/argprocessing.cpp
index 518d3e1a..c00c6e07 100644
--- a/src/argprocessing.cpp
+++ b/src/argprocessing.cpp
@@ -919,12 +919,16 @@ process_arg(const Context& ctx,
// Potentially rewrite concatenated absolute path argument to relative.
if (args[i][0] == '-') {
- const auto slash_pos = Util::is_absolute_path_with_prefix(args[i]);
- if (slash_pos) {
- std::string option = args[i].substr(0, *slash_pos);
+ const auto path_pos = Util::is_absolute_path_with_prefix(args[i]);
+ if (path_pos) {
+ const std::string option = args[i].substr(0, *path_pos);
+ const std::string path = args[i].substr(*path_pos);
+ if (!detect_pch(
+ option, path, args_info.included_pch_file, false, state)) {
+ return Statistic::bad_compiler_arguments;
+ }
if (compopt_takes_concat_arg(option) && compopt_takes_path(option)) {
- auto relpath = Util::make_relative_path(
- ctx, string_view(args[i]).substr(*slash_pos));
+ const auto relpath = Util::make_relative_path(ctx, path);
std::string new_option = option + relpath;
if (compopt_affects_cpp_output(option)) {
state.cpp_args.push_back(new_option);
@@ -936,18 +940,6 @@ process_arg(const Context& ctx,
}
}
- // Detect PCH for options with concatenated path.
- if (util::starts_with(args[i], "-Fp") || util::starts_with(args[i], "-Yu")) {
- const size_t path_pos = 3;
- if (!detect_pch(args[i].substr(0, path_pos),
- args[i].substr(path_pos),
- args_info.included_pch_file,
- false,
- state)) {
- return Statistic::bad_compiler_arguments;
- }
- }
-
// Options that take an argument.
if (compopt_takes_arg(args[i])) {
if (i == args.size() - 1) {