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

Why isn't CLion checking for MISRA?

I want to run the MISRA checks on my code and when I click "Inspect Code" it shows only Clang-Tidy even though I have checked the MISRA setting in the Inspections menu. Inspections menu And this are the results of the Analysis. Analysis results No…
I4mbut4mI
  • 11
  • 1
1
vote
0 answers

How can I use clang tidy without compile_commands.json in Windows (Powershell)?

I am not using CMake and I could not figure out how to build the compile_commands.json file separately; so, I have created a custom script that runs clang tidy on files. In Linux, the command works without issues: clang-tidy -header-filter=.*…
Gasim
  • 7,615
  • 14
  • 64
  • 131
1
vote
1 answer

Is Clang-Tidy check "member is const qualified" too strict?

Clang-tidy check cppcoreguidelines-avoid-const-or-ref-data-members warns about const qualified members, referring to C++ Core Guidelines C.12 Don’t make data members const or references in a copyable or movable type,…
Jens
  • 187
  • 8
1
vote
1 answer

Clang tidy does not detect missing virtual destructor

Consider following MWE: reference.cpp: #include class A { public: virtual void foo() = 0; }; class B : public A { public: void foo() override { std::cout << "test"; } }; If I run clang-tidy…
Roman
  • 1,396
  • 4
  • 15
  • 39
1
vote
1 answer

How to avoid Clang-Tidy warning when using QLibrary::resolve?

QLibrary documentation suggests casting the QFunctionPointer returned to a specific function pointer. However, following code results in a Clang-Tidy warning "Do not use C-style cast to convert between unrelated types": using FooFactory = Foo*…
Jens
  • 187
  • 8
1
vote
1 answer

Creating an AST Matcher using hasAnyArgument

I am trying to build a matcher which will find the usage of a forbidden enum value, e.g. foo(enumDeprecated); e.g.: static internal::Matcher buildSimpleFunctionArgumentMatcher( const std::string argumentName, const std::string binding)…
1
vote
1 answer

Include errors with clang-tidy, CMake, Ninja, MinGW and Visual Studio on Windows

When compiling the following Hello World project in Visual Studio with MinGW toolchain using Ninja, iostream cannot be found by clang-tidy. CMakeLists.txt: cmake_minimum_required(VERSION 3.12) project(my_project) add_executable(my_project…
OLEGSHA
  • 388
  • 3
  • 13
1
vote
0 answers

use clang-query to match specified string

how should I use clang-query to match specified string souece code: int main() { __asm__ __volatile__("pause"); } I want to substituted "yield" for "pause" what I have tried in clang-query, I can only match the stringLiteral and I cant match…
1
vote
2 answers

How to get Visual Studio use a .clang-tidy configuration file when invoking clang-tidy?

Visual Studio (Desktop) has a clang-tidy integration. you can make VS invoke clang-tidy with a list of checks. however, I could not find a way to make it use an existing .clang-tidy configuration file. The documentation hints that it is…
Elad Maimoni
  • 3,703
  • 3
  • 20
  • 37
1
vote
1 answer

clang tidy emits errors about exceptions being disabled when the are enabled

I enabled clang-tidy integration to a CMake project like so: set(CMAKE_CXX_CLANG_TIDY clang-tidy; -header-filter=.; --config-file=${MY_CLANG_TIDY_CONFIG_PATH}; ) In the .clang-tidy config file, there are rules for checking naming conventions…
Elad Maimoni
  • 3,703
  • 3
  • 20
  • 37
1
vote
0 answers

Clang-tidy problem encountered with multiple architectures

I'm working on creating a custom clang-tidy checker for a large codebase. To run my clang-tidy checker, I need to generate a compile_commands.json database for all files. The problem I'm facing is that this is a multi architecture project, so most…
JDGross
  • 83
  • 1
  • 8
1
vote
2 answers

Using clang-tidy with compile-commands.json to parse multiple files

I am having trouble getting clang-tidy to read my compilation-database. If I try: clang-tidy --config-file ./.clang-tidy -checks=* -p ./target or clang-tidy --config-file ./.clang-tidy -checks=* -p ./target/compile-commands.json I get Error: no…
Bruce Adams
  • 4,953
  • 4
  • 48
  • 111
1
vote
0 answers

how to get type from `cxxNewExpr` in `clang-tidy`

I'm trying to do a quick rewrite of our codebase to replace all instances of new T(...) with New(...) (a custom function), so I can do some local measurements. I think clang-tidy is the way to go here, so I've made a small clang tidy script,…
CoffeeTableEspresso
  • 2,614
  • 1
  • 12
  • 30
1
vote
0 answers

clang-tidy not applying naming

I'm trying to use clang-tidy on Windows from MSVC (Clang 13.0.1 for MSVC 2022 amd). The renaming is applied to the header file, but not fully to the cpp file. .clang-tidy Checks: '-*,readability-identifier-naming' CheckOptions: - { key:…
1
vote
1 answer

clang-tooling: replacing out parameter with a return value

I'm writing a clang tool that would roughly do the following: Before: encode(in, out); After: out = encode(in); The problem is I would like to remove the unnecessary temporary variables too. At the very least I'd like: std::string…
Denis Yaroshevskiy
  • 1,218
  • 11
  • 24