[Mlir-commits] [mlir] [mlir] Unbreak msvc build. NFC. (PR #102627)

Michael Kruse llvmlistbot at llvm.org
Fri Aug 9 08:05:31 PDT 2024


https://github.com/Meinersbur created https://github.com/llvm/llvm-project/pull/102627

Since ec50f5828f25, compiling the unittests fail with 
```
mlir\unittests\Support\CyclicReplacerCacheTest.cpp(30,40): error C2326: 'auto CachedCyclicReplacerTest_testInPlaceRecursionPruneAnywhere_Test::TestBody::<lambda_1>::operator ()(int) const': function cannot access 'replacer'
```
I think this is legal, as calling a lambda recursively is legal as well, as long as the declarator's type does not depend on the lambda's type. Explicitly listing the captures unbreaks the build for msvc.

Alternative to #101021

>From 84a308b55d0179546745ec9e57264c7880459cdf Mon Sep 17 00:00:00 2001
From: Michael Kruse <llvm-project at meinersbur.de>
Date: Fri, 9 Aug 2024 16:53:56 +0200
Subject: [PATCH] [mlir] Unbreak msvc build

---
 mlir/unittests/Support/CyclicReplacerCacheTest.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/mlir/unittests/Support/CyclicReplacerCacheTest.cpp b/mlir/unittests/Support/CyclicReplacerCacheTest.cpp
index ca2eb6ce4171f7..1a3f4b5d8852a0 100644
--- a/mlir/unittests/Support/CyclicReplacerCacheTest.cpp
+++ b/mlir/unittests/Support/CyclicReplacerCacheTest.cpp
@@ -27,8 +27,8 @@ TEST(CachedCyclicReplacerTest, testNoRecursion) {
 TEST(CachedCyclicReplacerTest, testInPlaceRecursionPruneAnywhere) {
   // Replacer cycles through ints 0 -> 1 -> 2 -> 0 -> ...
   CachedCyclicReplacer<int, int> replacer(
-      /*replacer=*/[&](int n) { return replacer((n + 1) % 3); },
-      /*cycleBreaker=*/[&](int n) { return -1; });
+      /*replacer=*/[&replacer](int n) { return replacer((n + 1) % 3); },
+      /*cycleBreaker=*/[](int n) { return -1; });
 
   // Starting at 0.
   EXPECT_EQ(replacer(0), -1);



More information about the Mlir-commits mailing list