[llvm] [third-party] Fix benchmark build error with Clang 22 (PR #184532)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 3 17:56:47 PST 2026
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-third-party-benchmark
Author: mitchell (zeyi2)
<details>
<summary>Changes</summary>
While running CI, I noticed a build failure:
```log
llvm-project/clang-tools-extra/clangd/benchmarks/IndexBenchmark.cpp:92:1: error: '__COUNTER__' is a C2y extension [-Werror,-Wc2y-extensions]
```
Related link: https://github.com/llvm/llvm-project/pull/184015#issuecomment-3994435400
While `benchmark.h` already had some suppression logic, it didn't cover the macro expansion at call sites.
This patch ensures `IndexBenchmark.cpp` build successfully when compiled with `-pedantic` and `-Werror`.
---
Full diff: https://github.com/llvm/llvm-project/pull/184532.diff
1 Files Affected:
- (modified) third-party/benchmark/include/benchmark/benchmark.h (+5-2)
``````````diff
diff --git a/third-party/benchmark/include/benchmark/benchmark.h b/third-party/benchmark/include/benchmark/benchmark.h
index c2debb216d64f..f5bae6179c557 100644
--- a/third-party/benchmark/include/benchmark/benchmark.h
+++ b/third-party/benchmark/include/benchmark/benchmark.h
@@ -1495,6 +1495,7 @@ BENCHMARK_RESTORE_PEDANTIC_WARNING
BaseClass##_##Method##_Benchmark
#define BENCHMARK_PRIVATE_DECLARE(n) \
+ BENCHMARK_DISABLE_PEDANTIC_WARNING \
static ::benchmark::internal::Benchmark* BENCHMARK_PRIVATE_NAME(n) \
BENCHMARK_UNUSED
@@ -1503,12 +1504,14 @@ BENCHMARK_RESTORE_PEDANTIC_WARNING
BENCHMARK_PRIVATE_DECLARE(_benchmark_) = \
(::benchmark::internal::RegisterBenchmarkInternal( \
new ::benchmark::internal::FunctionBenchmark(#__VA_ARGS__, \
- __VA_ARGS__)))
+ __VA_ARGS__))) \
+ BENCHMARK_RESTORE_PEDANTIC_WARNING
#else
#define BENCHMARK(n) \
BENCHMARK_PRIVATE_DECLARE(n) = \
(::benchmark::internal::RegisterBenchmarkInternal( \
- new ::benchmark::internal::FunctionBenchmark(#n, n)))
+ new ::benchmark::internal::FunctionBenchmark(#n, n))) \
+ BENCHMARK_RESTORE_PEDANTIC_WARNING
#endif // BENCHMARK_HAS_CXX11
// Old-style macros
``````````
</details>
https://github.com/llvm/llvm-project/pull/184532
More information about the llvm-commits
mailing list