1313
1414using namespace llvm ;
1515
16- TestRunner::TestRunner (StringRef TestName,
17- const std::vector<std::string> &TestArgs,
16+ TestRunner::TestRunner (StringRef TestName, ArrayRef<std::string> RawTestArgs,
1817 std::unique_ptr<ReducerWorkItem> Program,
1918 std::unique_ptr<TargetMachine> TM, StringRef ToolName,
2019 StringRef OutputName, bool InputIsBitcode,
2120 bool OutputBitcode)
22- : TestName(TestName), ToolName(ToolName), TestArgs(TestArgs),
23- Program(std::move(Program)), TM(std::move(TM)),
24- OutputFilename(OutputName), InputIsBitcode(InputIsBitcode),
25- EmitBitcode(OutputBitcode) {
21+ : TestName(TestName), ToolName(ToolName), Program(std::move(Program)),
22+ TM(std::move(TM)), OutputFilename(OutputName),
23+ InputIsBitcode(InputIsBitcode), EmitBitcode(OutputBitcode) {
2624 assert (this ->Program && " Initialized with null program?" );
25+
26+ TestArgs.push_back (TestName); // argv[0]
27+ TestArgs.append (RawTestArgs.begin (), RawTestArgs.end ());
2728}
2829
2930static constexpr std::array<std::optional<StringRef>, 3 > DefaultRedirects = {
@@ -33,18 +34,13 @@ static constexpr std::array<std::optional<StringRef>, 3> NullRedirects;
3334// / Runs the interestingness test, passes file to be tested as first argument
3435// / and other specified test arguments after that.
3536int TestRunner::run (StringRef Filename) const {
36- std::vector<StringRef> ProgramArgs;
37- ProgramArgs.push_back (TestName);
38-
39- for (const auto &Arg : TestArgs)
40- ProgramArgs.push_back (Arg);
41-
42- ProgramArgs.push_back (Filename);
37+ SmallVector<StringRef> ExecArgs (TestArgs);
38+ ExecArgs.push_back (Filename);
4339
4440 std::string ErrMsg;
4541
4642 int Result =
47- sys::ExecuteAndWait (TestName, ProgramArgs , /* Env=*/ std::nullopt ,
43+ sys::ExecuteAndWait (TestName, ExecArgs , /* Env=*/ std::nullopt ,
4844 Verbose ? DefaultRedirects : NullRedirects,
4945 /* SecondsToWait=*/ 0 , /* MemoryLimit=*/ 0 , &ErrMsg);
5046
0 commit comments