mirror of
https://github.com/google/benchmark.git
synced 2025-01-14 13:50:13 +08:00
Add clang-tidy check (#1290)
* Add clang-tidy.yml and .clang-tidy * Add mention to authors/contributors * Temp fix 2 clang-tidy issues * Enable clang-tidy on pull requests * Exclude gtest source files from clang-tidy
This commit is contained in:
parent
d6ba952fc1
commit
680d3fdbb5
7
.clang-tidy
Normal file
7
.clang-tidy
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
---
|
||||||
|
Checks: 'clang-analyzer-*'
|
||||||
|
WarningsAsErrors: 'clang-analyzer-*'
|
||||||
|
HeaderFilterRegex: '.*'
|
||||||
|
AnalyzeTemporaryDtors: false
|
||||||
|
FormatStyle: none
|
||||||
|
User: user
|
38
.github/workflows/clang-tidy.yml
vendored
Normal file
38
.github/workflows/clang-tidy.yml
vendored
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
name: clang-tidy
|
||||||
|
|
||||||
|
on:
|
||||||
|
push: {}
|
||||||
|
pull_request: {}
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
job:
|
||||||
|
name: run-clang-tidy
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: install clang-tidy
|
||||||
|
run: sudo apt update && sudo apt -y install clang-tidy
|
||||||
|
|
||||||
|
- name: create build environment
|
||||||
|
run: cmake -E make_directory ${{ runner.workspace }}/_build
|
||||||
|
|
||||||
|
- name: configure cmake
|
||||||
|
shell: bash
|
||||||
|
working-directory: ${{ runner.workspace }}/_build
|
||||||
|
run: >
|
||||||
|
cmake $GITHUB_WORKSPACE
|
||||||
|
-DBENCHMARK_ENABLE_ASSEMBLY_TESTS=OFF
|
||||||
|
-DBENCHMARK_ENABLE_LIBPFM=OFF
|
||||||
|
-DBENCHMARK_DOWNLOAD_DEPENDENCIES=ON
|
||||||
|
-DCMAKE_C_COMPILER=clang
|
||||||
|
-DCMAKE_CXX_COMPILER=clang++
|
||||||
|
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON
|
||||||
|
-DGTEST_COMPILE_COMMANDS=OFF
|
||||||
|
|
||||||
|
- name: run
|
||||||
|
shell: bash
|
||||||
|
working-directory: ${{ runner.workspace }}/_build
|
||||||
|
run: run-clang-tidy
|
1
AUTHORS
1
AUTHORS
@ -21,6 +21,7 @@ David Coeurjolly <david.coeurjolly@liris.cnrs.fr>
|
|||||||
Deniz Evrenci <denizevrenci@gmail.com>
|
Deniz Evrenci <denizevrenci@gmail.com>
|
||||||
Dirac Research
|
Dirac Research
|
||||||
Dominik Czarnota <dominik.b.czarnota@gmail.com>
|
Dominik Czarnota <dominik.b.czarnota@gmail.com>
|
||||||
|
Dominik Korman <kormandominik@gmail.com>
|
||||||
Donald Aingworth <donalds_junk_mail@yahoo.com>
|
Donald Aingworth <donalds_junk_mail@yahoo.com>
|
||||||
Eric Backus <eric_backus@alum.mit.edu>
|
Eric Backus <eric_backus@alum.mit.edu>
|
||||||
Eric Fiselier <eric@efcs.ca>
|
Eric Fiselier <eric@efcs.ca>
|
||||||
|
@ -38,6 +38,7 @@ David Coeurjolly <david.coeurjolly@liris.cnrs.fr>
|
|||||||
Deniz Evrenci <denizevrenci@gmail.com>
|
Deniz Evrenci <denizevrenci@gmail.com>
|
||||||
Dominic Hamon <dma@stripysock.com> <dominic@google.com>
|
Dominic Hamon <dma@stripysock.com> <dominic@google.com>
|
||||||
Dominik Czarnota <dominik.b.czarnota@gmail.com>
|
Dominik Czarnota <dominik.b.czarnota@gmail.com>
|
||||||
|
Dominik Korman <kormandominik@gmail.com>
|
||||||
Donald Aingworth <donalds_junk_mail@yahoo.com>
|
Donald Aingworth <donalds_junk_mail@yahoo.com>
|
||||||
Eric Backus <eric_backus@alum.mit.edu>
|
Eric Backus <eric_backus@alum.mit.edu>
|
||||||
Eric Fiselier <eric@efcs.ca>
|
Eric Fiselier <eric@efcs.ca>
|
||||||
|
@ -38,7 +38,11 @@ add_subdirectory(${GOOGLETEST_SOURCE_DIR}
|
|||||||
${GOOGLETEST_BINARY_DIR}
|
${GOOGLETEST_BINARY_DIR}
|
||||||
EXCLUDE_FROM_ALL)
|
EXCLUDE_FROM_ALL)
|
||||||
|
|
||||||
set_target_properties(gtest PROPERTIES INTERFACE_SYSTEM_INCLUDE_DIRECTORIES $<TARGET_PROPERTY:gtest,INTERFACE_INCLUDE_DIRECTORIES>)
|
if(NOT DEFINED GTEST_COMPILE_COMMANDS)
|
||||||
set_target_properties(gtest_main PROPERTIES INTERFACE_SYSTEM_INCLUDE_DIRECTORIES $<TARGET_PROPERTY:gtest_main,INTERFACE_INCLUDE_DIRECTORIES>)
|
set(GTEST_COMPILE_COMMANDS ON)
|
||||||
set_target_properties(gmock PROPERTIES INTERFACE_SYSTEM_INCLUDE_DIRECTORIES $<TARGET_PROPERTY:gmock,INTERFACE_INCLUDE_DIRECTORIES>)
|
endif()
|
||||||
set_target_properties(gmock_main PROPERTIES INTERFACE_SYSTEM_INCLUDE_DIRECTORIES $<TARGET_PROPERTY:gmock_main,INTERFACE_INCLUDE_DIRECTORIES>)
|
|
||||||
|
set_target_properties(gtest PROPERTIES INTERFACE_SYSTEM_INCLUDE_DIRECTORIES $<TARGET_PROPERTY:gtest,INTERFACE_INCLUDE_DIRECTORIES> EXPORT_COMPILE_COMMANDS ${GTEST_COMPILE_COMMANDS})
|
||||||
|
set_target_properties(gtest_main PROPERTIES INTERFACE_SYSTEM_INCLUDE_DIRECTORIES $<TARGET_PROPERTY:gtest_main,INTERFACE_INCLUDE_DIRECTORIES> EXPORT_COMPILE_COMMANDS ${GTEST_COMPILE_COMMANDS})
|
||||||
|
set_target_properties(gmock PROPERTIES INTERFACE_SYSTEM_INCLUDE_DIRECTORIES $<TARGET_PROPERTY:gmock,INTERFACE_INCLUDE_DIRECTORIES> EXPORT_COMPILE_COMMANDS ${GTEST_COMPILE_COMMANDS})
|
||||||
|
set_target_properties(gmock_main PROPERTIES INTERFACE_SYSTEM_INCLUDE_DIRECTORIES $<TARGET_PROPERTY:gmock_main,INTERFACE_INCLUDE_DIRECTORIES> EXPORT_COMPILE_COMMANDS ${GTEST_COMPILE_COMMANDS})
|
||||||
|
@ -151,7 +151,7 @@ std::string StrFormatImp(const char* msg, va_list args) {
|
|||||||
auto buff_ptr = std::unique_ptr<char[]>(new char[size]);
|
auto buff_ptr = std::unique_ptr<char[]>(new char[size]);
|
||||||
// 2015-10-08: vsnprintf is used instead of snd::vsnprintf due to a limitation
|
// 2015-10-08: vsnprintf is used instead of snd::vsnprintf due to a limitation
|
||||||
// in the android-ndk
|
// in the android-ndk
|
||||||
ret = vsnprintf(buff_ptr.get(), size, msg, args);
|
vsnprintf(buff_ptr.get(), size, msg, args);
|
||||||
return std::string(buff_ptr.get());
|
return std::string(buff_ptr.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -119,7 +119,7 @@ ADD_CASES("BM_error_during_running", {{"/1/threads:1", true, "error message"},
|
|||||||
|
|
||||||
void BM_error_during_running_ranged_for(benchmark::State& state) {
|
void BM_error_during_running_ranged_for(benchmark::State& state) {
|
||||||
assert(state.max_iterations > 3 && "test requires at least a few iterations");
|
assert(state.max_iterations > 3 && "test requires at least a few iterations");
|
||||||
int first_iter = true;
|
[[maybe_unused]] bool first_iter = true;
|
||||||
// NOTE: Users should not write the for loop explicitly.
|
// NOTE: Users should not write the for loop explicitly.
|
||||||
for (auto It = state.begin(), End = state.end(); It != End; ++It) {
|
for (auto It = state.begin(), End = state.end(); It != End; ++It) {
|
||||||
if (state.range(0) == 1) {
|
if (state.range(0) == 1) {
|
||||||
|
Loading…
Reference in New Issue
Block a user