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

Enforce verbose return code documentation in cpp

In my cpp codebase, we have a set of return codes. (let's say: enum class RC: UINT32 { kSucess, kNoMem, kIoError, kNetworkError ...} ) We use Doxygen and clang to enforce all kinds of coding conventions, Specifically, every function must follow a…
0
votes
0 answers

clang-tidy has warning enabled but never throws it

I'm trying to make my clang-tidy to emit errors for unsafe API usage. My .clang-tidy looks as follows: --- Checks: …
Roman
  • 1,396
  • 4
  • 15
  • 39
0
votes
0 answers

Clang-Tidy CMake VisualStudio

How to execute clang-tidy with CMake in Visual studio just as single target? 1.OS: Windows 2.IDE: Visual Studio 2022 3.LLVM: Installed 4.Clang-Tidy: 15.0.6 5.Ninja: Installed (and added to path) CMakeLists.txt add_custom_target(tidy COMMAND…
0
votes
1 answer

Disable clang-tidy for ALL (specific) function invocations

My specific problem is that cppcoreguidelines-avoid-magic-numbers is flagging calls to setters. For example: auto person = Person(); person.set_height(6); // <--- Flagged as "magic number" This really isn't a magic number, as the context for what…
Matt Messersmith
  • 12,939
  • 6
  • 51
  • 52
0
votes
1 answer

How to configure clang checkers when using flycheck

When using clang checkers via clang-tidy manually, I can add and remove some checks using a .clang-tidy file. However when using lsp-mode within emacs, with flycheck activated, clang checkers are run, which is fine, but my .clang-tidy configuration…
shodanex
  • 14,975
  • 11
  • 57
  • 91
0
votes
2 answers

clang-tidy and boost::intrusive_ptr

I use boost::intrusive_ptr in my project and have such code: void foo(boost::intrusive_ptr obj) { // do something with obj } And I have clang-tidy diagnostic: Clang-Tidy: The parameter 'obj' is copied for each invocation but only used…
kiv_apple
  • 491
  • 3
  • 13
0
votes
0 answers

Clang-tidy complains about "rule of 5" member functions deleted in a superclass

Running clang-tidy on the following (simplified) code: struct Base { Base() = default; virtual ~Base() = default; Base(const Base&) = delete; Base& operator=(const Base&) = delete; Base(Base&&) = delete; // not really needed …
Alex O
  • 1,429
  • 2
  • 13
  • 20
0
votes
0 answers

clang isConstQualified() method does not work with const placement

I'm trying to implement a clang-tidy check to warn about the use of output parameters. As registerMatchers method, I have the following: void AvoidouputparametersCheck::registerMatchers(MatchFinder *Finder) { Finder->addMatcher( …
0
votes
1 answer

(clang AST matchers) How to match consecutive statements?

I'm planning a bunch of refactorings on a large code base that I'd like to automate using Clang tooling. For this, I'm trying to write a Clang AST Matcher expression. Specifically, I'm trying to match pairs of statements that I'd like to replace…
Marc Mutz - mmutz
  • 24,485
  • 12
  • 80
  • 90
0
votes
0 answers

How to build standalone clang-tidy rpm

I'm attempting to build my own RPM for clang-tidy with the llvm 12.0.1 release from github for legacy reasons. I'd like to just build clang-tidy without the rest of llvm keep it small. Currently I can only get it to work if I install everything in…
Philip Nelson
  • 1,027
  • 12
  • 28
0
votes
0 answers

Can clang-tidy warnings from selected code branches be suppressed?

I use LLVM version 12.0.0. Let's assume that there is library code that contains some weird code for testing purposes. This code will never be accessed during normal library use, but is only there for unit testing. Now if a project uses that library…
0
votes
2 answers

C++ error: The right operand of '*' is a garbage value

I finally completed my code and when I submit it I received a couple errors. It keeps telling me 73:15 Incorrect spacing around >=. 73:31 Incorrect spacing around <=. for this line, I've tried putting it together and no change if (quantity >=5 &&…
raelyn
  • 17
  • 5
0
votes
1 answer

The proper way to initialize array of char with constant string

I use a struct to transfer data over TCP-IP and I have to stick with certain packet size, so I use char array of fixed size for text data. Due to the fact that I can't initialize it otherwise, I forced to copy string to that array in constructor…
user15611331
0
votes
1 answer

strncmp() Clang-Tidy: Comparison length too long and might lead to buffer overflow

I am iterating over my command line arguments and checking for matches with if (!strncmp(argv[i], "-f", 3)) {} Clang-Tidy warns me that the 3 is too large comparison length and might lead to a buffer overflow. In my understanding, that should be…
ZwergofPhoenix
  • 141
  • 1
  • 6
0
votes
2 answers

Clang-Tidy: Calling a base constructor other than the copy constructor

I'm getting the following message from Clang-Tidy: Clang-Tidy: Calling a base constructor other than the copy constructor The code is this: #include #include using namespace std; class Node :…
traveh
  • 2,700
  • 3
  • 27
  • 44