Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

clang-tidy reporting unknown warnings

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
like image 676
parsley72 Avatar asked Oct 29 '17 23:10

parsley72


People also ask

How do I disable clang tidy checks?

To suppress a Clang-Tidy check for a particular line, use the Suppress "check_name" for line option.

What does clang tidy do?

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.

How do I use clang tidy in Visual Studio?

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.


2 Answers

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

like image 145
valiano Avatar answered Jan 01 '23 17:01

valiano


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.

like image 27
tgpfeiffer Avatar answered Jan 01 '23 18:01

tgpfeiffer