Skip to content

Commit

Permalink
Rewrite the swiftc params file if an argument contains a space.
Browse files Browse the repository at this point in the history
Bazel does not quote arguments when it writes a multiline params file, but LLVM's command line parser does not distinguish between newlines and other kinds of whitespace, and we don't want to use the shell-quoted params file format from Bazel because it would be more difficult for us to parse. This change ensures that if a line in the incoming params file contains a space, it causes a rewrite which triggers the defensive "quote everything" logic.

RELNOTES: None.
PiperOrigin-RevId: 307876851
  • Loading branch information
allevato authored and swiple-rules-gardener committed Apr 22, 2020
1 parent 50de9d0 commit 7eee6cc
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion tools/worker/swift_runner.cc
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,11 @@ bool SwiftRunner::ProcessArgument(
// Apply any other text substitutions needed in the argument (i.e., for
// Apple toolchains).
auto new_arg = arg;
changed = MakeSubstitutions(&new_arg, bazel_placeholder_substitutions_);
// Bazel doesn't quote arguments in multi-line params files, so we need to
// ensure that our defensive quoting kicks in if an argument contains a
// space, even if no other changes would have been made.
changed = MakeSubstitutions(&new_arg, bazel_placeholder_substitutions_) ||
new_arg.find_first_of(' ') != std::string::npos;
consumer(new_arg);
}

Expand Down

0 comments on commit 7eee6cc

Please sign in to comment.