KhronosGroup / KhronosGroup/OpenCL-ICD-Loader

Add .clang-tidy and enable higher warning level

Open
#68 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C
Stars
304
Forks
171
Avg merge
11h 30m
Merged PRs (30d)
1

Description

The number of checks that we can use is highly limited since this is a C project, not C++ and we *have* to do a few things that are UB strictly speaking (like `void *` <-> function pointer casts), but there are a few things we can enable that are still useful. Examples:

* [readability-identifier-naming](https://clang.llvm.org/extra/clang-tidy/checks/readability-identifier-naming.html)
* [readability-redundant-control-flow](https://clang.llvm.org/extra/clang-tidy/checks/readability-redundant-control-flow.html)
* [readability-else-after-return](https://clang.llvm.org/extra/clang-tidy/checks/readability-else-after-return.html)
* [misc-definitions-in-headers](https://clang.llvm.org/extra/clang-tidy/checks/misc-definitions-in-headers.html)
* [Most of clang Static Analyzer](https://clang-analyzer.llvm.org/available_checks.html)
* `-Wall -Wextra` (`-Wpedantic` triggers on our unsafe pointer casts that are mandated by the OpenCL API)

---

Note that this requires the generation of a compilation database which is most easily achieved by passing `-DCMAKE_EXPORT_COMPILE_COMMANDS=ON` to CMake >= 3.4. This shouldn't be much of a problem, as the way I set up the testing matrix in #65 makes it easy to switch out different build tools for different jobs in the matrix (just add another Conan profile). This way we can use this feature on our CI and still ensure that the project builds correctly with older CMake versions.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the CMake and Conan testing-matrix setup described in the issue, especially compilation database generation via CMAKE_EXPORT_COMPILE_COMMANDS=ON and the changes from #65. Add a .clang-tidy configuration with the applicable checks, enable -Wall and -Wextra, and update CI so analysis runs while builds remain compatible with older CMake versions.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, cmake
Domain
build-system, ci-cd, tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.