From 8b3d1b024561e3c3711096c78761cb29a05be92f Mon Sep 17 00:00:00 2001 From: ryan-holt-1 Date: Mon, 29 Jul 2024 10:29:58 -0400 Subject: [PATCH] [mlir] Fix build after ec50f5828f25 This commit fixes what appears to be invalid C++ -- a lambda capturing a variable before it is declared. The code compiles with GCC and Clang but not MSVC. --- mlir/unittests/Support/CyclicReplacerCacheTest.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/mlir/unittests/Support/CyclicReplacerCacheTest.cpp b/mlir/unittests/Support/CyclicReplacerCacheTest.cpp index ca2eb6ce4171f7..64a8ab72b69b7d 100644 --- a/mlir/unittests/Support/CyclicReplacerCacheTest.cpp +++ b/mlir/unittests/Support/CyclicReplacerCacheTest.cpp @@ -26,14 +26,15 @@ TEST(CachedCyclicReplacerTest, testNoRecursion) { TEST(CachedCyclicReplacerTest, testInPlaceRecursionPruneAnywhere) { // Replacer cycles through ints 0 -> 1 -> 2 -> 0 -> ... - CachedCyclicReplacer replacer( - /*replacer=*/[&](int n) { return replacer((n + 1) % 3); }, + std::optional> replacer; + replacer.emplace( + /*replacer=*/[&](int n) { return (*replacer)((n + 1) % 3); }, /*cycleBreaker=*/[&](int n) { return -1; }); // Starting at 0. - EXPECT_EQ(replacer(0), -1); + EXPECT_EQ((*replacer)(0), -1); // Starting at 2. - EXPECT_EQ(replacer(2), -1); + EXPECT_EQ((*replacer)(2), -1); } //===----------------------------------------------------------------------===//