From 6de277c03922fd67ad5d13daa9325357e7a02ac7 Mon Sep 17 00:00:00 2001 From: Arthur Eubanks Date: Wed, 16 Oct 2024 21:26:34 +0000 Subject: [PATCH 1/2] rustc_llvm: Fix flattened CLI args Fixes string manipulation errors introduced in #130446. --- compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp b/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp index 8f0b1b8127657..b28215af467ea 100644 --- a/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp +++ b/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp @@ -491,12 +491,12 @@ extern "C" LLVMTargetMachineRef LLVMRustCreateTargetMachine( auto Arg0 = std::string(ArgsCstrBuff); buffer_offset = Arg0.size() + 1; auto ArgsCppStr = - std::string(ArgsCstrBuff + buffer_offset, ArgsCstrBuffLen - 1); + std::string(ArgsCstrBuff + buffer_offset, ArgsCstrBuffLen - buffer_offset); auto i = 0; while (i != std::string::npos) { i = ArgsCppStr.find('\0', i + 1); if (i != std::string::npos) - ArgsCppStr.replace(i, i + 1, " "); + ArgsCppStr.replace(i, 1, " "); } Options.MCOptions.Argv0 = Arg0; Options.MCOptions.CommandlineArgs = ArgsCppStr; From 18bbf5f118e721477fec1cde3c11d3fd2faebcd3 Mon Sep 17 00:00:00 2001 From: Arthur Eubanks Date: Wed, 16 Oct 2024 21:46:52 +0000 Subject: [PATCH 2/2] clang-format --- compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp b/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp index b28215af467ea..4b303511dbc05 100644 --- a/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp +++ b/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp @@ -490,8 +490,8 @@ extern "C" LLVMTargetMachineRef LLVMRustCreateTargetMachine( assert(ArgsCstrBuff[ArgsCstrBuffLen - 1] == '\0'); auto Arg0 = std::string(ArgsCstrBuff); buffer_offset = Arg0.size() + 1; - auto ArgsCppStr = - std::string(ArgsCstrBuff + buffer_offset, ArgsCstrBuffLen - buffer_offset); + auto ArgsCppStr = std::string(ArgsCstrBuff + buffer_offset, + ArgsCstrBuffLen - buffer_offset); auto i = 0; while (i != std::string::npos) { i = ArgsCppStr.find('\0', i + 1);