For questions about clang-tidy as a static analyzer and code modernization tool. For more generic questions such as compiler diagnostic messages use the clang tag.
Questions tagged [clang-tidy]
404 questions
19
votes
1 answer
Handling "Thrown exception type is not nothrow copy constructible" Warning
Going back to C++ development after a 12 years hiatus. I'm using JetBrains's CLion software which is great since it provides a lot of input on possible issues on my class design. One of the warning I get in my class' constructor throw statement is:…

Guillaume Lavoie
- 567
- 4
- 19
18
votes
1 answer
overloaded "operator++" returns a non const, and clang-tidy complains
I have just got the following warning from clang-tidy:
overloaded "operator++" returns a non-constant object
instead of a constant object type
https://clang.llvm.org/extra/clang-tidy/checks/cert-dcl21-cpp.html
Unfortunately the link which they…

Ferenc Deak
- 34,348
- 17
- 99
- 167
17
votes
2 answers
How to integrate clang-tidy to CMake and GCC?
I want to integrate clang-tidy to our C and C++, CMake based project which is compiled using a custom GCC toolchain.
I've tried following this tutorial, setting CMAKE_CXX_CLANG_TIDY. I've also tried generating a compilation database by setting…

cereagni
- 171
- 1
- 1
- 6
16
votes
1 answer
What is "Clang-Tidy: Function is within a recursive call chain" ? How to fix it?
I'm writing a function dealing with string in C, which is recursive. Basically what it does is to find a string between some characters and '\0'. If before it finds '\0', it hits on the particular characters, it will recursively call itself.
When…

citrate
- 189
- 1
- 1
- 8
15
votes
1 answer
What values are allowed in the .clang-tidy config file?
Is there a place that documents the .clang-tidy config file? All I could find is this:
$ clang-tidy -dump-config
---
Checks: '-*,some-check'
WarningsAsErrors: ''
HeaderFilterRegex: ''
FormatStyle: none
User: …

Ezra
- 1,401
- 5
- 15
- 33
15
votes
1 answer
Clion Unintialized record type: player
I have started learning C++ a few weeks ago. I am seeing now classes and all the stuff, and I was wondering about object instantiation. In this code:
class Player
{
public:
int x, y;
int speed;
};
int main ()
{
Player player…

vrodriguez
- 335
- 3
- 11
15
votes
4 answers
cmake clang-tidy (or other script) as custom target
I am trying to create a custom cmake target for clang-tidy, to lint my project. The source folder looks something like this:
src/scripts/run-clang-tidy.py
src/.clang-tidy
src/...
So far my plan was to copy both these files to the build directory…

fuji
- 1,173
- 1
- 10
- 27
14
votes
3 answers
how to use clang-tidy modernize with visual studio
I'm trying to apply clang modernization on files either from within visual studio, or from the command line, making use of the includes paths and settings in my visual studio 2015 C++ projects.
I created a clang-tidy settings file, like…

Johan Lundberg
- 26,184
- 12
- 71
- 97
14
votes
3 answers
Getting clang-tidy to fix header files
I'm in the process of moving a project currently compiling with gcc to clang,
and have a bunch of warnings that gcc didn't generate (-Winconsistent-missing-override). clang-tidy works for fixing these errors in the *.cpp files, however it doesn't…

nishantjr
- 1,788
- 1
- 15
- 39
13
votes
3 answers
Ignore certain files when using clang-tidy
I'm trying to integrate clang-tidy with cmake, but there are some files that belong to a particular target which I would like to ignore.
Is there any way to make clang-tidy to ignore files under certain directory or whose name matches a certain…

Dan
- 2,452
- 20
- 45
13
votes
3 answers
Exclude specific headers from clang-tidy
I have several projects with many headers that I want to parse, but there are several headers which I do not want to parse with clang-tidy
My folder hierarchy is as follows
A\
|
|-B\
| |
| |-C\
| | |
| | └-coco.h
| └-D\
└-E\
My projects are inside…

S BI
- 351
- 1
- 2
- 12
12
votes
3 answers
C++ Core Guidelines for static member variables
I have a private static vector in my class that keeps a pointer to all objects created from it. It's necessary as each object needs access to information from all the other objects to perform some calculations:
// Header file:
class Example…

M47
- 400
- 2
- 13
12
votes
1 answer
Using clang-tidy to check c++17 code
I installed clang-tidy on Ubuntu using:
sudo apt install clang-tidy
I ran it on a simple C++ 17 file, and got a warning and errors:
/home/erelsgl/Dropbox/ariel/CPLUSPLUS/intro/01-single-file/ptr.cpp:17:3: warning: 'auto' type specifier is a C++11…

Erel Segal-Halevi
- 33,955
- 36
- 114
- 183
12
votes
3 answers
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'?…

parsley72
- 8,449
- 8
- 65
- 98
11
votes
1 answer
How to use and configure clang-tidy on windows?
I'm trying to use clang-tidy code analysis so I can check for CppCoreGuidelines. I downloaded LLVM 7.0.0 pre-built binary for Win 7 64 bits. I'm able to successfully compile with clang, I did a basic example compiling this code, I named the source…

Wambitz
- 355
- 1
- 2
- 13