From edb0d3d46d76df6c54c174f026c8a6a21b833ebf Mon Sep 17 00:00:00 2001 From: Roman Lebedev Date: Mon, 3 Jul 2023 12:18:31 +0300 Subject: [PATCH] Suppress intentional potential memory leak as detected by clang static analysis (#1618) https://github.com/google/benchmark/issues/1513 Co-authored-by: dominic <510002+dmah42@users.noreply.github.com> --- include/benchmark/benchmark.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/benchmark/benchmark.h b/include/benchmark/benchmark.h index 558aca8d..1444ec61 100644 --- a/include/benchmark/benchmark.h +++ b/include/benchmark/benchmark.h @@ -1362,6 +1362,8 @@ class LambdaBenchmark : public Benchmark { inline internal::Benchmark* RegisterBenchmark(const std::string& name, internal::Function* fn) { + // FIXME: this should be a `std::make_unique<>()` but we don't have C++14. + // codechecker_intentional [cplusplus.NewDeleteLeaks] return internal::RegisterBenchmarkInternal( ::new internal::FunctionBenchmark(name, fn)); } @@ -1371,6 +1373,8 @@ template internal::Benchmark* RegisterBenchmark(const std::string& name, Lambda&& fn) { using BenchType = internal::LambdaBenchmark::type>; + // FIXME: this should be a `std::make_unique<>()` but we don't have C++14. + // codechecker_intentional [cplusplus.NewDeleteLeaks] return internal::RegisterBenchmarkInternal( ::new BenchType(name, std::forward(fn))); }