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

via libcxx-commits libcxx-commits at lists.llvm.org
Wed Sep 23 11:55:19 PDT 2026


Author: Louis Dionne
Date: 2026-09-23T14:55:10-04:00
New Revision: dfc0d74533a697129b29450bd8ca7d2010007df9

URL: https://github.com/llvm/llvm-project/commit/dfc0d74533a697129b29450bd8ca7d2010007df9
DIFF: https://github.com/llvm/llvm-project/commit/dfc0d74533a697129b29450bd8ca7d2010007df9.diff

LOG: [libc++] Don't pass a path lvalue to DoNotOptimize in the filesystem benchmark (#225504)

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.

Added: 
    

Modified: 
    libcxx/test/benchmarks/filesystem.bench.cpp

Removed: 
    


################################################################################
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)


        


More information about the libcxx-commits mailing list