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

clang-tidy can not find header files integrated with cmake on windows

I use clang-tidy in cmake like this: cmake_minimum_required(VERSION 3.10) project(clang_tidy_test) set(CMAKE_CXX_STANDARD 17) # generate compile_commands.json if possible set(CMAKE_EXPORT_COMPILE_COMMANDS ON) set(CMAKE_VERBOSE_MAKEFILE ON) #…
maidamai
  • 712
  • 9
  • 26
1
vote
1 answer

How to tell AndroidStudio to be less pedantic about native code

I am using AndroidStudio to build NDK based applications with C and C++ code. The IDE goes overboard with warnings, like the one below: How can I disable this and other gratuitous warnings from the IDE? Is this done on a per-project base, or an IDE…
Bram
  • 7,440
  • 3
  • 52
  • 94
1
vote
1 answer

Is it possible to write new clang-tidy modernize rules?

In particular, I'm using Qt; our codebase is still littered with old foreach macros, like foreach (T foo, bar) { ... }. I'd like to turn that to for (T foo : bar) { ... }. Is there a way to write a clang-tidy rule to do this?
Ben
  • 9,184
  • 1
  • 43
  • 56
1
vote
4 answers

How do tools like clang-tidy or cppcheck compare to klocwork?

Is there a fundamental difference between these tools? After all, klocwork is relatively expensive and the other ones are free? Both do static code analysis after some rules. Are there differences in the quality of rules? Does it only depend on the…
1
vote
1 answer

clang-tidy: Blacklist some checks (or regex for checks)

I agree with the majority of the clang-tidy checks, but some I don't see tremendous value in. Mostly these are the fuschia* checks, such as the default argument warnings: error: calling a function that uses a default argument is disallowed…
bremen_matt
  • 6,902
  • 7
  • 42
  • 90
1
vote
1 answer

Clang tidy replace reinterpret_cast with static_cast

Is there any rule which makes clang tidy to warn about useless reinterpret_cast where static_cast can be used ? E.g. void f(void* p) { int* x = reinterpret_cast(p); // static_cast is enough here }
NN_
  • 1,593
  • 1
  • 10
  • 26
1
vote
2 answers

False warnings on Android Studio 3.3 (NDK)

With the most recent 3.3 update, Android Studio seems to have a very annoying bug giving false warnings in C/C++ codes. As you can see in the image above, the IDE signals warnings on every bit operation incorporating an immediate value even if it's…
Jake 'Alquimista' LEE
  • 6,197
  • 2
  • 17
  • 25
1
vote
0 answers

Using llvm-header-guard with run-clang-tidy.py

I checked following links What is proper LLVM header guard style? clang-tidy header guard style warning but I can't solve the problem with the llvm-header-guard in combination with run-clang-tidy.py I have following CMakeLists.txt…
ge45mue
  • 677
  • 8
  • 23
1
vote
0 answers

How to use clang-tidy with -Wdocumentation flag

I want to use my custom check and clang-diagnostics (-Wdocumentation) at the same time, but i don't want to have compile_commands.json at all. I tried this: clang-tidy.exe -checks="mycheckmodule-*" -fix-errors %FILE% -- -Wdocumentation but it…
1
vote
0 answers

clang-tidy incorrectly replaces template parameter in typedef

I ran clang-tidy over a selection of my codebase, and noticed a few typedefs including template parameters being incorrectly replaced with concrete types. I managed to replicate at least one of this issues with this example file, test.cc: template…
John Ilacqua
  • 906
  • 5
  • 19
1
vote
1 answer

clang analyzer can't detect null dereferencing

I'm playing with clang static analyzer ( clang++ --analyze or clang-tidy, win64, v6.0.1). Clang analyzer can detect a null dereference in this case: class SomeClass { public: int a = 5; }; int GetA( SomeClass* someClass ) { return…
1
vote
1 answer

How do I pass GslHeader argument to clang-tidy while using -fix option?

I couldn't find sample code for a clang-tidy command line for fixing the following error: [archlinux@thinkpad fizzbuzz]$ clang-tidy fizzbuzz2.cpp -checks=cppcoreguidelines-pro-bounds-constant-array-index 5 warnings generated. fizzbuzz2.cpp:21:18:…
urmish
  • 127
  • 1
  • 6
1
vote
0 answers

Clang-Tidy: Use of a signed integer operand with a binary bitwise operator

I want to split a long long (a 64-bit value) into two ints (32-bit each). For this I'm using the "standard way" of shifting the long long right by 32 to get the upper 32-bit and cast the long long to an int to get the lower 32-bit. However,…
BullyWiiPlaza
  • 17,329
  • 10
  • 113
  • 185
1
vote
1 answer

Clang format output errors

Is it possible to have clang-format issue output as warnings saying what to fix similar to clang tidy. I would prefer to use clang-format due to the ease of setting up styles.
1
vote
1 answer

macOS homebrew llvm clang tidy some checks are missing

I have installed LLVM via brew on macOS with the below mentioned command: brew install --with-toolchain llvm@3.9 I would like to use clang-tidy but some checks are missing, for example misc-string-compare. What could be the problem?
tmsblgh
  • 517
  • 5
  • 21