[llvm] 89ada6c - llvm-reduce: Avoid push_back for constant array
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 3 07:13:41 PST 2023
Author: Matt Arsenault
Date: 2023-01-03T10:13:17-05:00
New Revision: 89ada6c51fbdf59dcab8a1e479f60196d29bd4d3
URL: https://github.com/llvm/llvm-project/commit/89ada6c51fbdf59dcab8a1e479f60196d29bd4d3
DIFF: https://github.com/llvm/llvm-project/commit/89ada6c51fbdf59dcab8a1e479f60196d29bd4d3.diff
LOG: llvm-reduce: Avoid push_back for constant array
Added:
Modified:
llvm/tools/llvm-reduce/TestRunner.cpp
Removed:
################################################################################
diff --git a/llvm/tools/llvm-reduce/TestRunner.cpp b/llvm/tools/llvm-reduce/TestRunner.cpp
index 058664d2e9a3..3d486f87e1bd 100644
--- a/llvm/tools/llvm-reduce/TestRunner.cpp
+++ b/llvm/tools/llvm-reduce/TestRunner.cpp
@@ -31,6 +31,10 @@ TestRunner::TestRunner(StringRef TestName,
assert(this->Program && "Initialized with null program?");
}
+static constexpr std::array<std::optional<StringRef>, 3> DefaultRedirects = {
+ StringRef()};
+static constexpr std::array<std::optional<StringRef>, 3> NullRedirects;
+
/// Runs the interestingness test, passes file to be tested as first argument
/// and other specified test arguments after that.
int TestRunner::run(StringRef Filename) const {
@@ -43,15 +47,11 @@ int TestRunner::run(StringRef Filename) const {
ProgramArgs.push_back(Filename);
std::string ErrMsg;
- SmallVector<std::optional<StringRef>, 3> Redirects;
- std::optional<StringRef> Empty = StringRef();
- if (!Verbose) {
- for (int i = 0; i < 3; ++i)
- Redirects.push_back(Empty);
- }
- int Result = sys::ExecuteAndWait(
- TestName, ProgramArgs, /*Env=*/std::nullopt, Redirects,
- /*SecondsToWait=*/0, /*MemoryLimit=*/0, &ErrMsg);
+
+ int Result =
+ sys::ExecuteAndWait(TestName, ProgramArgs, /*Env=*/std::nullopt,
+ Verbose ? DefaultRedirects : NullRedirects,
+ /*SecondsToWait=*/0, /*MemoryLimit=*/0, &ErrMsg);
if (Result < 0) {
Error E = make_error<StringError>("Error running interesting-ness test: " +
More information about the llvm-commits
mailing list