From f6c228e0266cdd1a14cc038e46de2a3d25a58aed Mon Sep 17 00:00:00 2001 From: Dominic Hamon Date: Wed, 10 Nov 2021 16:49:49 +0000 Subject: [PATCH] check clang format on pull requests and merges (#1281) * check clang format on pull requests and merges * manage some formatting by hand * undo one format too many --- .github/workflows/clang-format-lint.yml | 17 +++++++++++++++++ include/benchmark/benchmark.h | 4 +++- src/cycleclock.h | 2 +- 3 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/clang-format-lint.yml diff --git a/.github/workflows/clang-format-lint.yml b/.github/workflows/clang-format-lint.yml new file mode 100644 index 0000000000..75775c7cfc --- /dev/null +++ b/.github/workflows/clang-format-lint.yml @@ -0,0 +1,17 @@ +name: clang-format-lint +on: + push: {} + pull_request: {} + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - uses: DoozyX/clang-format-lint-action@v0.13 + with: + source: './include/benchmark ./src ./test' + extensions: 'h,cc' + clangFormatVersion: 12 + style: Google diff --git a/include/benchmark/benchmark.h b/include/benchmark/benchmark.h index d8b8cd9a2a..45f26c8e94 100644 --- a/include/benchmark/benchmark.h +++ b/include/benchmark/benchmark.h @@ -239,6 +239,7 @@ BENCHMARK(BM_test)->Unit(benchmark::kMillisecond); #define BENCHMARK_INTERNAL_TOSTRING2(x) #x #define BENCHMARK_INTERNAL_TOSTRING(x) BENCHMARK_INTERNAL_TOSTRING2(x) +// clang-format off #if defined(__GNUC__) || defined(__clang__) #define BENCHMARK_BUILTIN_EXPECT(x, y) __builtin_expect(x, y) #define BENCHMARK_DEPRECATED_MSG(msg) __attribute__((deprecated(msg))) @@ -255,6 +256,7 @@ BENCHMARK(BM_test)->Unit(benchmark::kMillisecond); #define BENCHMARK_DISABLE_DEPRECATED_WARNING #define BENCHMARK_RESTORE_DEPRECATED_WARNING #endif +// clang-format on #if defined(__GNUC__) && !defined(__clang__) #define BENCHMARK_GCC_VERSION (__GNUC__ * 100 + __GNUC_MINOR__) @@ -489,7 +491,7 @@ class Counter { Counter(double v = 0., Flags f = kDefaults, OneK k = kIs1000) : value(v), flags(f), oneK(k) {} - BENCHMARK_ALWAYS_INLINE operator double const&() const { return value; } + BENCHMARK_ALWAYS_INLINE operator double const &() const { return value; } BENCHMARK_ALWAYS_INLINE operator double&() { return value; } }; diff --git a/src/cycleclock.h b/src/cycleclock.h index 0db7bc4aa2..d65d32a39d 100644 --- a/src/cycleclock.h +++ b/src/cycleclock.h @@ -115,7 +115,7 @@ inline BENCHMARK_ALWAYS_INLINE int64_t Now() { // the code is being compiled with a non-ancient compiler. _asm rdtsc #elif defined(COMPILER_MSVC) && defined(_M_ARM64) - // See https://docs.microsoft.com/en-us/cpp/intrinsics/arm64-intrinsics?view=vs-2019 + // See // https://docs.microsoft.com/en-us/cpp/intrinsics/arm64-intrinsics // and https://reviews.llvm.org/D53115 int64_t virtual_timer_value; virtual_timer_value = _ReadStatusReg(ARM64_CNTVCT);