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
1 answer

Clang-tidy: how to configure size_t, uintptr_t and pointers to 32-bits?

Clang-tidy is now part of the C/C++ plugin for VS Code. Earlier I were using the clang-tidy extension, and it was working fine. The issue is that clang-tidy now treats size_t, uintptr_t and all pointers as 64-bits, and issues warnings for…
vjalle
  • 549
  • 4
  • 13
0
votes
0 answers

Is there a check in clang-tidy to reveal the most vexing parse cases?

I would like to speed up the compilation time of a legacy C++ project with millions of lines of code. I didn't find any compiler benchmarks focusing on refactoring the "most vexing parse" described by Scott Meyers…
Robert
  • 53
  • 1
  • 6
0
votes
0 answers

How can I run clang-tidy on all the cpp files in my project in a performant way?

I have a CI script that runs clang tidy on all the cpp files to ensure that all the files are written using the rules set up in the config file. Currently, I have a script that finds all the necessary files (cpp and shader files) and runs clang tidy…
Gasim
  • 7,615
  • 14
  • 64
  • 131
0
votes
1 answer

How to get the parent funtion name in clang-tidy ASTMatch at CallExpr Position

I add a Matcher in callExpr, Finder->addMatcher(callExpr().bind("call"), this); In my check function, I want to get parent function name in this callexpr node, here is my checkfunction context. Parent varible always returns nullptr. How to deal with…
Langewin
  • 1
  • 2
0
votes
1 answer

Understanding clang-tidy "DeadStores" and "NewDeleteLeaks" warnings

I am relatively new to c++ programming, especially when dealing with OOP and pointers. I am trying to implement a binary search tree, and here is the code I have struct TreeNode { int val; TreeNode* left; TreeNode* right; TreeNode() :…
Gareth Ma
  • 199
  • 10
0
votes
0 answers

Warnings from clang-tidy

When testing a class, clang-tidy started giving warnings like this. What are they and how to remove them? warning: invalid configuration value '0' for option 'cppcoreguidelines-pro-bounds-constant-array-index.IncludeStyle'…
0
votes
0 answers

VSCode Clang-Tidy squiggling header because "__float128 is not supported on this target"

As seen in this video, the C++ Linter provided in the C/C++ extension from Microsoft (clang-tidy) in VSCode squiggles the header of the standard library, producing an irresolvable problem. However, outside of this fact, the linter works as…
user16667377
0
votes
0 answers

CLang tidy does not recognize namespace keyword and interprets it as a variable

I am ramping up a Platform IO project. Within there I am using clang-tidy for different checks (see documentation for PIO clang-tidy here). Given the folder structure - . -- include -- src I placed a header file in the include folder, called…
stev-e
  • 436
  • 6
  • 15
0
votes
1 answer

Integer to pointer cast pessimism optimization opportunities

The from_base function returns the memory address from the base to a selected value in a program. I want to retrieve this value and return it in a function, however, I am getting a warning that says integer to pointer cast pessimism optimization…
Dany Gagnon
  • 102
  • 1
  • 9
0
votes
1 answer

Writing a specific Clang-tidy check to avoid passing an expression into std::vector::reserve()

In our codebase, we always use std::vector::reserve() to achieve higher performance. Most of the time they work well. Also, sometimes we might pass an expression into the reserve() function. For example, const double length = GetLength(); const…
0
votes
0 answers

clang-tidy fails with OpenCV code that compiles fine

clang-tidy fails on this simple program: #include int main() { cv::Mat m; m.at(12, 34); return 0; } when run with clang-tidy-13 test.cpp -- -I/usr/include/opencv4…
iliis
  • 878
  • 8
  • 19
0
votes
1 answer

How to change c++ code to make clang-tidy modernize-use-transparent-functors happy

We have the following c++ code using catch2 framework: auto check2 = [](size_t exp, size_t val, auto comp) { REQUIRE(comp(exp, val)); }; check2(10, 20, std::equal_to{}); and clang-tidy generates the following /test_lingua.cpp:1236:36:…
0
votes
0 answers

Value stored to `item` during its initialization is never read in range base loop

I am trying to fix analyzer errors, but I am stuck at this error, have no idea why I am getting this error here is my code. struct Config{ std::shared_ptr> data; std::shared_ptr> getData(){ return data; …
foragerDev
  • 1,307
  • 1
  • 9
  • 22
0
votes
1 answer

using clang-tidy to findout all uncaught exceptions

I want to use clang-tidy to find out all uncaught exceptions by its direct or indirect caller, up to main, but this demo has no effect. Generally, I want to clang-tidy to report that the function cc is throwing an exception that not being caught by…
ddwolf
  • 91
  • 2
  • 10
0
votes
0 answers

How can I get no-injected-class-name from clang::ParmVarDecl without using std::string operation

The parameter type is a Record and I have no idea to get the no-injected-class-name from clang::ParmVarDecl without using std::string operation. struct A{}; void showA(const A& a) {} I get "const struct A&" by invoking…
Gehry
  • 1