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
1 answer
Clang-tidy not finding header file
Note: This is done in RHEL 7.2 with clang 8.0.1.
I'm running the command
clang-tidy test.C -- -I/path/to/header.h
and I get the following error:
1 error generated.
Error while processing test.C.
test.C:28:10: error: 'header.h' file not found…

helloworld95
- 366
- 7
- 17
0
votes
1 answer
Why is clang-tidy not getting its options set through ALE?
I'm able to run clang-tidy with my source file clang-tidy -p build/compile_commands.json filename.h and it works as expected. When I open the file through vim I get errors with the first #includes, which happens if I leave the -p option off the…

Raiden Worley
- 394
- 1
- 4
- 14
0
votes
1 answer
clang not generating warning for "return a reference to a local object"
I have the following code:
int *&F(int *x) {
int **p = &x;
return *p;
}
int main() {
int A[] = {0, 1, 2, 3, 4}, *y = A + 2, *&q = F(y);
cout << *q << ' ' << *y << endl;
}
Now, i can see that we are returning the reference of x, but…

Alberto Sinigaglia
- 12,097
- 2
- 20
- 48
0
votes
1 answer
`virtual` `override` destructor
In the following example:
class A {
public:
virtual ~A() { std::cout << "~A" << std::endl; }
};
class B : public A {
public:
virtual ~B() override { std::cout << "~B" << std::endl; }
};
class C : public B {
public:
~C() override {…

rhughes
- 9,257
- 11
- 59
- 87
0
votes
0 answers
How to mark function as pure function for clang-tidy
I'm trying to use clang-tidy on my code base and I'm getting a lot of false positives from the following pattern
int *a;
if(config(some_value))
a = value;
...
if(config(some_value))
*a = other_value; // <-- deference of garbage value
the…

Mitchk
- 13
- 2
0
votes
1 answer
Do not declare C-style arrays, use std::array<> instead
From clang-tidy I get for
struct Foo {
private:
static constexpr char BAR[] = "\033[2J";
};
the warning
do not declare C-style arrays, use std::array<> instead
[cppcoreguidelines-avoid-c-arrays]
for BAR.
How can I declare with
#include…

ge45mue
- 677
- 8
- 23
0
votes
1 answer
Clang-Tidy not found after installed
After I installed the CLion. I used brew install llvm@7 and installed successfully.
The CMake options is set as
-DCMAKE_BUILD_TYPE=Debug
-DLLVM_DIR=/usr/local/Cellar/llvm@/7.0.1/lib/cmake/llvm/
..
And the path for Clang-Tidy is also…

ripfreeworld
- 143
- 1
- 13
0
votes
1 answer
c/c++ linting or format check code documentation
Is there anyway of using clang-tidy or cppcheck or any other tool to check for missing documentation including file header comment to class members. I am assuming doxygen.

Serj
- 51
- 1
- 6
0
votes
0 answers
Overriding move-assignement operator
I get a warning from clang-tidy when overriding the move-assignment operator in a subclass and moving the fields of the sub class after invoking the move-assignment operator of the base class.
Example:
class Base{
...
Base&…

peter
- 553
- 1
- 5
- 13
0
votes
1 answer
Clang-Tidy changes signature of c file, but not the associated header
I have this c file
#include "pointer.h"
int switcher(int * i) {
int a = *i;
switch (a) {
case 1:
return 0;
default:
return 1;
}
}
and the associated header contains only one line
int switcher(int…

schorsch312
- 5,553
- 5
- 28
- 57
-1
votes
1 answer
Clang-tidy readability-identifier-naming not catching all instances
I've been slowly working on enabling clang-tidy checks in my project and I'm running into an issue with the readability-identifier-naming check. Sometimes it just doesn't highlight some names as incorrectly formatted but it will only do that in…

bcaddy
- 73
- 5
-1
votes
1 answer
Why " throw" will display a warning?
#include
#include
using std::string;
using std::cout;
using std::endl;
using std::ostringstream;
class illegalParameterValue {
private:
string message;
public:
illegalParameterValue() : message("Illegal parameter…

ZCdream
- 11
- 4
-1
votes
2 answers
Writing a specific Clang check
I'm trying to implement my little custom check, for example trying to walk through this tutorial (which is out of date a bit).
I have several problems:
After I cloned the repos, implemented the check and runned cmake, the builds targets are…

Huszák Richárd
- 1
- 1
- 6
-2
votes
1 answer
Default arguments on virtual methods
I'm using Clang-Tidy to inspect my code. One of the tool's messages puzzled me:
clang-tidy: Default arguments on virtual or override methods are prohibited
I get the idea when I actually use a method override. But here in my case, I want to…

Sébastien Bémelmans
- 869
- 2
- 8
- 17