Questions tagged [clang-tidy]

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.

404 questions
1
vote
0 answers

Also get inherited fields of CXXRecordDecl

Is it possible to get all fields that are defined explicitly and implicitly (inherited from parent classes) apart from iterating over a CXXRecordDecl's bases recursively and evaluating along the way, using C++'s inheritance and access rules, whether…
llambdaa
  • 65
  • 6
1
vote
1 answer

clang-tidy: Assigned value is garbage or undefined when accessing raw memory of an array or struct

When running clang-tidy I get an warning when accessing an address of an array: src/main.cpp:10:9: warning: Assigned value is garbage or undefined [clang-analyzer-core.uninitialized.Assign] sum += *(addr++); ^ The code is stripped down…
Charly
  • 1,270
  • 19
  • 42
1
vote
1 answer

How to exclude single checks from clang-tidy file?

Let's talk about this simple example: #include int main(int argc, char *argv[]) { std::cout << "started " << argv[0] << " with " << argc << " params." << std::endl; return 0; } We have a minimal .clang-tidy file which looks like…
Charly
  • 1,270
  • 19
  • 42
1
vote
1 answer

Clang-Tidy : readability-function-cognitive-complexity.DescribeBasicIncrements value has no effect

While running clang-tidy on an example code provided at https://clang.llvm.org/extra/clang-tidy/checks/readability/function-cognitive-complexity.html (function3 in the examples). with the below command clang-tidy.exe Example.cpp -config="{Checks:…
talekeDskobeDa
  • 372
  • 2
  • 13
1
vote
0 answers

Clang Tidy Integration with msbuild command line

I have worked on previous projects using CMake and clang tidy and was able to generate the compilation database. However, I am working on project using C++ builder and would like to run clang tidy on the codebase. There doesn't seem to be much…
user2020
  • 217
  • 2
  • 12
1
vote
0 answers

I want to show a clang-tidy parsing report in SonarQube, but there is no output after loading

I want to show a clang-tidy parsing report in SonarQube (Community Edition) using the "C ++ (Community)" plugin. But there is no output after loading. From sonarcub I need to display clang-tidy reports and no analysis is needed. file…
1
vote
1 answer

Why is clang-tidy scanning other header files?

I'm running clang-tidy on a header file header.h. However as some of the warning outputs, it's outputting system headers: .../include/c++/8/bits/std_abs.h:46:8: error: expected identifier or '(' [clang-diagnostic-error] extern…
helloworld95
  • 366
  • 7
  • 17
1
vote
1 answer

clang-tidy readability-identifier-naming IgnoredRegexp

I want to exclude certain regex patterns from linting for readability-identifier-naming. Part of .clang-tidy I'm using: Checks: 'readability-*' CheckOptions: - key: readability-identifier-naming.TypeAliasCase value: …
PHD
  • 595
  • 1
  • 8
  • 18
1
vote
1 answer

Clang tidy doesn't work for StaticConstantCase

I'm trying to use clang-tidy (10.0.0) to check the formatting on my file: #include "blabla.h" static const int status = 1000; static const int STATUS_REPLY_TIMEOUT_MS = 100; namespace foo { The .clang-tidy file I'm using is: Checks:…
Frank
  • 2,446
  • 7
  • 33
  • 67
1
vote
0 answers

Clang: How can I tell whether size of constant size array declaration is a macro expansion

I'm working on a clang-tidy checker to spot some problematic idioms in a large codebase. I need to look at constant-size arrays declared in structs, and determine whether the size was given as an integer literal, or if the size results from a macro…
1
vote
0 answers

Writing a Clang-Tidy check, how do I find if a pointer is initialized before it is called?

I am trying to port some static checks from an old in-house C++ static checker to clang-tidy. Since I am really new to this tool, I am having a really hard time doing it and I am starting to think that it's not the proper tool to do what I want. So…
FLP
  • 11
  • 3
1
vote
1 answer

Matching variadic template arguments using an AST Matcher

I have the following sample code. template T add(T first, Args... rest) { return first + add(rest...); } int add(int a, int b) { return a + b; } When I run it through clang-check -ast-dump, I get the following…
1
vote
0 answers

Why don't I get a warning when passing a negative integer to a function that accepts unsigned int?

If I write this function: void f(unsigned int i) { .. } and then call it like this: int main() { f(-1); } it is allowed by the standard, but it is most probably a risky bug that can cause, for example, a very long runtime (if f tries to loop from…
Erel Segal-Halevi
  • 33,955
  • 36
  • 114
  • 183
1
vote
1 answer

How to turn off checks on a per-file or per-function basis?

I am wondering what the best approach is to turn off some clang-tidy checks for either a given file or for a given function. For example, I want to turn on multi-thread warnings for the whole project, but I have a simple tool that uses the library…
jens
  • 168
  • 5
1
vote
0 answers

Why are xutility, xstddef, … analyzed by clang-tidy although they're not used in the build?

I'm linting a project with clang-tidy and I'm getting errors from files which are not included in the project. These files are for example: C:\Program Files (x86)\Microsoft Visual…
marcel
  • 25
  • 6