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
0
votes
0 answers
Clang-Tidy: Operator=() should return '...&'
I've got a very simple piece of code
class instance assignement:
class ABC {
public:
void set(const ABC* obj) {
*this = *obj;
}
ABC& operator=(const ABC* obj);
};
ABC& ABC::operator = (const ABC *obj){
if(obj!= this)…

sinoptic
- 303
- 3
- 12
0
votes
1 answer
How to prohibit private includes to other libraries when using merged header placement
I am in favour of merged header placement for a C++ project layout because
of several reasons also mentioned in the proposal P1204R0. Also I am trying to adhere to the Pitchfork guidlines.
I am using CMake to define the libraries and also the…

Gabriel
- 8,990
- 6
- 57
- 101
0
votes
1 answer
Clang-tidy cppcoreguidelines-owning-memory warning for Google Test macros
I have a simple c++ project with Bazel.
I'm running some simple tests using the Google Test framework.
Clang-tidy seems to complain about almost every single macro from that framework.
Is there a way to get clang to ignore those macros?
I tried…

Stefan Arnautu
- 1
- 2
0
votes
1 answer
clang-tidy bundled with Qt Creator [clang-diagnostic-error]
I have a CMake project where i try to run clang-tidy checks and fixes during the build. Everything works with clang-tidy from llvm 12.0.1(also tried 11.0.0) installed with brew.
When i try to use the clang-tidy(11.0.0 and 12.0.0 from Qt Creator…

emKaroly
- 756
- 1
- 10
- 22
0
votes
0 answers
clang-tidy cannot find C standard library headers files like , , etc
I am using clang-tidy as a linter for ALE in Vim.
I am running on a Windows 10 machine.
Everything works as expected but every time there is some header file from the standard library like or I got a file not found error.
When…

Barzi2001
- 989
- 8
- 24
0
votes
1 answer
Clang-Tidy: 'fscanf' used to convert a string to an integer value, but function will not report conversion errors; consider using 'strtol' instead
Somewhat unexperienced with C here!
I'm using CLion to write a program and keep getting this warning message whenever I use fscanf to store a value from an input file into a variable:
Clang-Tidy: 'fscanf' used to convert a string to an integer…

Felipe Evaristo
- 15
- 1
- 6
0
votes
1 answer
Convert function names to snake case with clang-tidy
I have a bunch of C code whose function names are in CamelCase and I have to convert them all to snake_case.
I found that there is a tool call clang-tidy that seems to be able to do this but I can't make sense of the documentation, there are a lot…

cassepipe
- 371
- 6
- 16
0
votes
1 answer
What GitHub projects automatically run clang-tidy as part of their continuous integration?
I am curious to know to what extent linters such as clang-tidy are in day-to-day use in large projects, as a part of a continuous integration process. Is there a way I can search GitHub for projects that run a certain tool, such as clang-tidy,…

Erel Segal-Halevi
- 33,955
- 36
- 114
- 183
0
votes
1 answer
[[nodiscard]] for constant getter functions
Is there a good reason why Clang-Tidy complains about missing [[nodiscard]] for a constant member function without parameters? Could the compiler not work that out itself and warn if the return value gets discarded?
In my opinion this is redundant…

Henk
- 826
- 3
- 14
0
votes
0 answers
Clang-Tidy warning when using typedef enums
I am looking over some older code someone else wrote and the person is often using this type of code:
typedef enum {
id1=1
id2=11
id3=2
id4=3
} enumName_e
This type is then used in functions all over the place. While this works clang-tidy…

Jundarer
- 45
- 6
0
votes
0 answers
clang-tidy check to remove unnecessary class name before member function
Is there a clang-tidy check for replacing A::bar(); with just bar(); in the following example?
class A {
void bar() {
};
void foo() {
A::bar();
};
};

Curious
- 2,783
- 3
- 29
- 45
0
votes
0 answers
how to fix expected unqualified-id error with clang-tidy
I have following c++ code for an embedded system:
//LIBRARY code:
typedef struct { /*!< (@ 0x48028100) PORT1 Structure */
__IO uint32_t OUT; …

Moritz
- 41
- 4
0
votes
1 answer
Run clang-tidy on project with headers
I have a project that I recently split up into headers + sources, and now clang-tidy wont "actually" check my test files that include these headers. Below is an example of the situation:
File Structure:
src/
main.c
a.h
a.c
test/
…

Dosisod
- 307
- 2
- 15
0
votes
0 answers
How to suppress clang-tidy warnings from thirdparty though cmake?
I want to see warnings only from /src directory, and don't see from thirdparty.
I write the next commands
set_target_properties(lolkeklol PROPERTIES CXX_CLANG_TIDY
…

Это Мы
- 21
- 4
0
votes
1 answer
Clang-Tidy: Resolving No Match error when adding Arguments
I'm trying to get clang-tidy working to analyze my code. Currently, I have this command:
clang-tidy file.C -- -I/all/my/include/files -L/all/my/libs
I'm assuming this works fine because I get this result:
End of search…

helloworld95
- 366
- 7
- 17