[libcxx-commits] [libcxx] [libc++] Don't pass a path lvalue to DoNotOptimize in the filesystem benchmark (PR #225504)

via libcxx-commits libcxx-commits at lists.llvm.org
Tue Sep 22 12:51:35 PDT 2026


llvmorg-github-actions[bot] wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-libcxx

Author: Louis Dionne (ldionne)

<details>
<summary>Changes</summary>

BM_PathIterateOnceBackwards passes *I directly to DoNotOptimize. However, libstdc++ returns a const lvalue reference to `path` from that operation, which selects GoogleBenchmark's deprecated const-ref overload.

Use the pattern used elsewhere in this file instead.

---
Full diff: https://github.com/llvm/llvm-project/pull/225504.diff


1 Files Affected:

- (modified) libcxx/test/benchmarks/filesystem.bench.cpp (+2-2) 


``````````diff
diff --git a/libcxx/test/benchmarks/filesystem.bench.cpp b/libcxx/test/benchmarks/filesystem.bench.cpp
index ad88c517b4665..e400c904340b7 100644
--- a/libcxx/test/benchmarks/filesystem.bench.cpp
+++ b/libcxx/test/benchmarks/filesystem.bench.cpp
@@ -131,9 +131,9 @@ TEST_ALIGN_BENCHMARK void BM_PathIterateOnceBackwards(benchmark::State& st, GenI
     auto I       = P.end();
     while (I != B) {
       --I;
-      benchmark::DoNotOptimize(*I);
+      benchmark::DoNotOptimize(I->native().data());
     }
-    benchmark::DoNotOptimize(*I);
+    benchmark::DoNotOptimize(I->native().data());
   }
 }
 BENCHMARK_CAPTURE(BM_PathIterateOnceBackwards, iterate_elements, getRandomStringInputs)

``````````

</details>


https://github.com/llvm/llvm-project/pull/225504


More information about the libcxx-commits mailing list