aboutsummaryrefslogtreecommitdiff
path: root/llvm/tools/llvm-rc/llvm-rc.cpp
diff options
context:
space:
mode:
authorMartin Storsjö <martin@martin.st>2023-03-24 12:17:25 +0200
committerMartin Storsjö <martin@martin.st>2023-03-28 11:02:41 +0300
commitd2fa6b694c2052cef1ddd507f6569bc84e3bbe35 (patch)
treee727cf63139199091026bf226b9098400cf254f7 /llvm/tools/llvm-rc/llvm-rc.cpp
parent7cf203e73922b8eaa4c23fba30702d7954eba107 (diff)
downloadllvm-d2fa6b694c2052cef1ddd507f6569bc84e3bbe35.zip
llvm-d2fa6b694c2052cef1ddd507f6569bc84e3bbe35.tar.gz
llvm-d2fa6b694c2052cef1ddd507f6569bc84e3bbe35.tar.bz2
[llvm-rc] Respect the executable specified in the --preprocessor command
The arguments passed in this option were passed onto the child process, but we still blindly used the clang binary that we had found to sys::ExecuteAndWait as the intended executable to run. If the user hasn't specified any custom --preprocessor command, Args[0] is equal to the variable Clang. This doesn't affect any tests, since the tests only print the arguments it would try to execute (but not the first parameter to sys::ExecuteAndWait), but there's no testes for executing it (and validating that it did execute the right thing). Differential Revision: https://reviews.llvm.org/D146793
Diffstat (limited to 'llvm/tools/llvm-rc/llvm-rc.cpp')
-rw-r--r--llvm/tools/llvm-rc/llvm-rc.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/llvm/tools/llvm-rc/llvm-rc.cpp b/llvm/tools/llvm-rc/llvm-rc.cpp
index fbf2aa7..036178b 100644
--- a/llvm/tools/llvm-rc/llvm-rc.cpp
+++ b/llvm/tools/llvm-rc/llvm-rc.cpp
@@ -227,7 +227,7 @@ struct RcOptions {
bool preprocess(StringRef Src, StringRef Dst, const RcOptions &Opts,
const char *Argv0) {
std::string Clang;
- if (Opts.PrintCmdAndExit) {
+ if (Opts.PrintCmdAndExit || !Opts.PreprocessCmd.empty()) {
Clang = "clang";
} else {
ErrorOr<std::string> ClangOrErr = findClang(Argv0, Opts.Triple);
@@ -267,7 +267,7 @@ bool preprocess(StringRef Src, StringRef Dst, const RcOptions &Opts,
}
// The llvm Support classes don't handle reading from stdout of a child
// process; otherwise we could avoid using a temp file.
- int Res = sys::ExecuteAndWait(Clang, Args);
+ int Res = sys::ExecuteAndWait(Args[0], Args);
if (Res) {
fatalError("llvm-rc: Preprocessing failed.");
}