I have a CMake build using GCC. I generated compile_commands.json then ran clang-tidy but I'm getting hundreds of:
error: unknown warning option '-Wno-maybe-uninitialized'; did you mean '-Wno-uninitialized'? [clang-diagnostic-unknown-warning-option]
error: unknown warning option '-Wno-psabi' [clang-diagnostic-unknown-warning-option]
How can I disable or remove these warnings? I saw clang++ warning: “warning: unknown warning option '-Wno-maybe-uninitialized'” but adding "-Wno-unknown-warning-option" gives me an error:
run-clang-tidy-3.8.py: error: unrecognized arguments: -Wno-unknown-warning-option
To suppress a Clang-Tidy check for a particular line, use the Suppress "check_name" for line option.
clang-tidy is a clang-based C++ “linter” tool. Its purpose is to provide an extensible framework for diagnosing and fixing typical programming errors, like style violations, interface misuse, or bugs that can be deduced via static analysis.
Clang-Tidy configurationIn the project Property Pages dialog, open the Configuration Properties > Code Analysis > Clang-Tidy page. Enter checks to run in the Clang-Tidy Checks property. A good default set is clang-analyzer-* . This property value is provided to the --checks argument of the tool.
Try appending -extra-arg=-Wno-unknown-warning-option
to clang-tidy command line.
Using -extra-arg=
asks clang-tidy to pass -Wno-unknown-warning-option
to the underlying clang. Otherwise, it tries to interpret it as a clang-tidy flag.
Edit:
The run-clang-tidy.py
script supports -extra-arg
starting version 5.0. In prior versions, you'd need to edit the script and add that -extra-arg
manually.
If you're on Ubuntu 16.04, you can get clang-tidy-5.0
from:
https://www.ubuntuupdates.org/package/xorg-edgers/xenial/main/base/clang-tidy-5.0
For me,
set(CMAKE_CXX_CLANG_TIDY "clang-tidy-8;--extra-arg=-Wno-error=unknown-warning-option")
solved the issue when running clang-tidy from within CMake.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With