CI: use compile command database for clang-tidy

This commit is contained in:
SChernykh 2023-06-15 10:32:05 +02:00
parent e1de021fba
commit 30560e6cf8
3 changed files with 19 additions and 6 deletions

View file

@ -8,15 +8,17 @@ jobs:
runs-on: ubuntu-22.04
steps:
- name: Install dependencies
run: |
sudo apt update
sudo apt install -y libuv1-dev libzmq3-dev libcurl4-openssl-dev
- name: Install clang
run: |
wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
sudo ./llvm.sh 16
sudo apt-get install -y clang-tidy-16
- name: Verify clang-tidy configuration
run: |
clang-tidy-16 --verify-config
- name: Checkout repository
@ -24,7 +26,13 @@ jobs:
with:
submodules: true
- name: cmake p2pool
run: |
mkdir build
cd build
cmake .. -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_C_COMPILER=clang-16 -DCMAKE_CXX_COMPILER=clang++-16 -DDEV_CLANG_TIDY=ON
- name: Run clang-tidy
run: |
cd src
clang-tidy-16 *.cpp -checks=-clang-diagnostic-undefined-internal -warnings-as-errors=* -header-filter=^[^\.] -- -I../external/src/robin-hood-hashing/src/include -I../external/src/rapidjson/include -I../external/src/cryptonote -I../external/src/RandomX/src -I../external/src/cppzmq -I../external/src/libuv/include -I../external/src/libzmq/include -I../external/src/curl/include -I../external/src/miniupnp/miniupnpc/include -I../external/src -DCLANG_TIDY -DSIZE_MAX=UINT64_MAX -DRAPIDJSON_ENDIAN=RAPIDJSON_LITTLEENDIAN -DMINIUPNP_STATICLIB -DRAPIDJSON_PARSE_DEFAULT_FLAGS=kParseTrailingCommasFlag -DWITH_RANDOMX -DWITH_UPNP -DZMQ_STATIC
clang-tidy-16 *.cpp -p ../build -checks=-clang-diagnostic-undefined-internal -warnings-as-errors=* -header-filter=^[^\.]

View file

@ -12,6 +12,7 @@ option(DEV_WITH_TSAN "[Developer only] Compile with thread sanitizer" OFF)
option(DEV_WITH_MSAN "[Developer only] Compile with memory sanitizer" OFF)
option(DEV_WITH_UBSAN "[Developer only] Compile with undefined behavior sanitizer" OFF)
option(DEV_WITH_ASAN "[Developer only] Compile with address sanitizer" OFF)
option(DEV_CLANG_TIDY "[Developer only] Compile for clang-tidy" OFF)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake")
@ -51,6 +52,10 @@ if (DEV_WITH_ASAN)
add_definitions(-DDEV_WITH_ASAN)
endif()
if (DEV_CLANG_TIDY)
add_definitions(-DDEV_CLANG_TIDY)
endif()
include(cmake/flags.cmake)
set(HEADERS

View file

@ -204,7 +204,7 @@ struct
{
#ifdef _MSC_VER
_addcarry_u64(_addcarry_u64(0, lo, b.lo, &lo), hi, b.hi, &hi);
#elif defined(__GNUC__) && !defined(CLANG_TIDY)
#elif defined(__GNUC__) && !defined(DEV_CLANG_TIDY)
*reinterpret_cast<unsigned __int128*>(this) += *reinterpret_cast<const unsigned __int128*>(&b);
#else
const uint64_t t = lo;
@ -221,7 +221,7 @@ struct
{
#ifdef _MSC_VER
_subborrow_u64(_subborrow_u64(0, lo, b.lo, &lo), hi, b.hi, &hi);
#elif defined(__GNUC__) && !defined(CLANG_TIDY)
#elif defined(__GNUC__) && !defined(DEV_CLANG_TIDY)
*reinterpret_cast<unsigned __int128*>(this) -= *reinterpret_cast<const unsigned __int128*>(&b);
#else
const uint64_t t = b.lo;