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
3
votes
0 answers

Is it possible ot enable gcc extensions when using clang-tidy

Gcc is quite liberal when it comes to constexpr. For example, it allows to use math and string comparisons in constexpr context. However, clang does not. Ie ./core/cmd_line_parser/command_line.hpp:223:12: note: non-constexpr function 'strncmp'…
user877329
  • 6,717
  • 8
  • 46
  • 88
3
votes
0 answers

[VSCode][CMake][clang-tidy] error: PCH file uses an older PCH format that is no longer supported

First of all: My project is on CMake tools I'm working in VSCode workspace I'm trying to using clang-tidy as code static checking What i entounter: Some of CMake targets enable pch target_precompile_headers when that enables, clang-tidy checking…
fallen ink
  • 31
  • 2
3
votes
1 answer

How can I comment a line in a .clang-tidy config file?

Please help me to understand how can I comment out a single line from a clang-tidy configuration file.
Erez Fridman
  • 119
  • 1
  • 12
3
votes
1 answer

Clang-Tidy - Android Studio 4.1.1

Really struggling to find documentation / examples so thought I'd reach out. My goal: I want clang-tidy to produce a report that I can eventually submit to sonarqube for analysis. Setting the scene: I have an Android project that's a hybrid of Java…
Szanxor
  • 31
  • 4
3
votes
1 answer

Clang Static Analyzer complains about memory leak when using protobuf's set_allocated_*

With the following proto file message Foo { // ... } message MyMessage { Foo foo = 1; } I set foo with the generated set_allocated_foo method which takes ownership of the pointer: MyMessage m; m.set_allocated_foo(new Foo); clang-tidy…
jhasse
  • 2,379
  • 1
  • 30
  • 40
3
votes
1 answer

No compile_commands.json file using cmake with vs code on windows

I am trying to integrate the Clang-Tidy static analysis tool into my build system. I am getting a few issues with my setup. Step cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON .. is not generating compile_commands.json file. Hence, clang-tidy is giving…
Avi
  • 310
  • 2
  • 4
  • 16
3
votes
0 answers

Change the name of a function *and* modify a string literal argument using Clang's AST API?

I'm trying to write a clang-tidy rule that will change the name of a function and modify a string literal parameter. The goal is to auto-port from tinyFormat to libfmt. I've got what I think is a good matcher here: finder->addMatcher( …
Walrus
  • 405
  • 4
  • 10
3
votes
2 answers

Is there a way to get -isystem for FetchContent targets?

NO_SYSTEM_FROM_IMPORTED tells us that IMPORTED targets automagically get -isystem. Does that also hold for targets introduced to the project with FetchContent? If not (I assume so due to having problems with clang-tidy warnings on fetched targets),…
3
votes
1 answer

Clang-tidy enabling C++17 extensions

I use Visual Studio 2019 and clang-tidy. I have a file in my solution with name .clang-tidy and it has rows like modernize-, -modernize-pass-by-value* I've used if statements with initializer which has come with C++17 standards but I get a…
RainMan14
  • 105
  • 1
  • 9
3
votes
0 answers

Static Code Analysis/Linting: Warn about == being called on unordered_set

For an unordered_set using a custom equality function, that equality definition is ignored when two sets are compared. Example: #include #include #include struct Hash { size_t operator()(const std::string&…
mrks
  • 8,033
  • 1
  • 33
  • 62
3
votes
1 answer

Perfect forwarding interpreted as rvalue reference

My understanding was that ConcreteType&& was an rvalue and TemplateType&& was "perfect forwarding". I'm trying to use perfect forwarding, but clang-tidy interprets it as rvalue reference. clang and gcc don't complain, but clang-tidy marks it as…
user100046
  • 422
  • 4
  • 11
3
votes
1 answer

How to use SYSTEM headers with CMake and clang-tidy?

I am trying to use clang-tidy in my CMake (3.17.1) project however it crashes on the Catch2 test library header. Setting the Catch2 as a system header does not seem to help. The command invoked for clang-tidy contains the path to Catch2 as a system…
Resurrection
  • 3,916
  • 2
  • 34
  • 56
3
votes
0 answers

clang-tidy does not find standard headers

I am trying to run clang-tidy in my project for a submodule, but it throws errors for the standard libraries, like 'string' file not found or the same for 'cmath'. Development is under Windows with Qt Creator and MinGW. This is my Cmake…
3
votes
2 answers

clang-tidy report error unknown argument when contain other compiler options

I have a project, I built it with intel compiler. I want use the clang-tidy to help detect code problems. I am using CMake to generate compile_commands.json and I'm getting the follow error when I using clang-tidy: $ run-clang-tidy # output #…
Xu Hui
  • 1,213
  • 1
  • 11
  • 24
3
votes
1 answer

How do I tell clang-tidy that slicing a particular class is ok?

I have a class Point that inherits publicly from another class Vec3 and adds some data members. For example, when asking a spline for it's coordinate some distance along it the extra data returned could be the index of the nearest control point. A…