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
2 answers

How to enable clang static analyzer flags from clang-tidy for alpha (experimental) checkers?

I'm trying to run the clang analyzer through its clang-tidy interface, but I need to pass the clang analyzer an additional flag. Specifically, I want to run an alpha checker for nondeterminism with clang-tidy -allow-enabling-analyzer-alpha-checkers…
ginginsha
  • 142
  • 1
  • 11
1
vote
1 answer

Prevent clang-tidy from running on generated files

We have a project that includes protobuf files that get pre-compiled into C++ files. Unfortunately, those files (like the other source files in the project) get checked by clang-tidy and generate a large number of warnings. The relevant top-level…
Alex O
  • 1,429
  • 2
  • 13
  • 20
1
vote
0 answers

clang-tidy + VSCode: how to see command line?

Is there a way to see the actual commmand line that VSCode is issuing to clang-tidy? I am trying to figure out why clang-tidy is giving clang-diagnostic-error messages about being unable to find certain header files, though I have configured…
user1757226
  • 193
  • 2
  • 9
1
vote
0 answers

Clang Diagnostic Error on file outside CPP project - "Error While processing"

Using gtkmm in a cpp project in vscode, everything can build normally even though I have this error. [{ "resource": "/d:/Dossiers/Repos/Cpp/Motion/src/main.cpp", "owner": "clang-tidy", "code": "clang-diagnostic-error", "severity":…
Edorion
  • 13
  • 3
1
vote
1 answer

TransformerClangTidyCheck drops required parentheses around bound `expr()`

I'd like to rename a function on one of the classes: class Container { public: int count() const; // old int size() const; // new }; So I've written a TransformerClangTidyCheck along the lines of the tutorial…
Marc Mutz - mmutz
  • 24,485
  • 12
  • 80
  • 90
1
vote
1 answer

How do I distinguish `&&` from `and` in llvm-clang?

It seems like to clang, binary operator && is exactly the same as and - its alternative operator representation. In the ast, both end up as BinaryOperator [...] 'bool' '&&'. Is there a way to distinguish them nevertheless? I was hoping to be able to…
SebastianWilke
  • 470
  • 1
  • 4
  • 15
1
vote
1 answer

Why are my custom clang-tidy checks not showing up after adding custom module?

I have a few custom clang-tidy checks. For instance one in the cppcoreguidelines module and another in the misc module. They work fine. Now I extended clang-tidy by a custom module to organize them into. When I rebuild, it succeeds but when I run…
SebastianWilke
  • 470
  • 1
  • 4
  • 15
1
vote
1 answer

Why does clang-tidy's modernize-use-emplace miss this warning?

a.cpp: #include using namespace std; int main() { vector> a; a.push_back(make_pair(1, 2)); //caught vector>> b(1); b[0].push_back(make_pair(1, 2)); //not caught return…
1
vote
1 answer

Matching std::optional with Clang AST

I'm trying to write a clang-tidy check for std::optional r = 5 to catch implicit conversions to bool. |-DeclStmt | `-VarDecl col:25 r 'std::optional':'std::optional' cinit | `-ExprWithCleanups…
1
vote
0 answers

Narrowing conversion size_t to long

How should I write this to appease clang-tidy? #include int main() { std::vector v(10); size_t index = 2; auto it = v.begin() + index; auto rollover = (index + 1) % v.size(); } clang-tidy complains Clang-Tidy:…
Captain Giraffe
  • 14,407
  • 6
  • 39
  • 67
1
vote
0 answers

clang-tidy 'iosfwd' file not found [clang-diagnostic-error]

i build my repo with bazel_clang_tidy,but meet some question,always report error: 'iosfwd' file not found bazel-out/k8-fastbuild/bin/external/com_github_google_glog/_virtual_includes/glog/glog/logging.h:42:10: error: 'iosfwd' file not found…
1
vote
0 answers

Why std::initializer_list cannot move?

P(std::initializer_list children) : Tag("p", std::move(children)) {} clang tidy warns as follows. error: std::move of the variable 'children' of the trivially-copyable type std::initializer_list has no effect; remove std::move()…
gahhu
  • 31
  • 3
1
vote
1 answer

Ignore 3rd party headers from clang-tidy in cmake

How can I avoid clang tidy warnings on my external library I am downloading using FetchContent. Is their an easy way to treat these as system libraries. I have done this in the past with my own header lib that I wanted to ignore…
user2020
  • 217
  • 2
  • 12
1
vote
1 answer

How can I match universal reference arguments to a member function using Clang AST matchers?

I'm trying to match arguments passed to a templated member function invocation using clang-query as a precursor to writing a clang-tidy check. Whilst I can get non-templated member functions to match, I'm unable to get templated member functions to.…
Mike Crowe
  • 642
  • 6
  • 18
1
vote
0 answers

problems in clang-tidy configuration

Recently, I saw a config file for clang-tidy as below. Checks: 'clang-diagnostic-*, clang-analyzer-*, -*, clang-analyzer-*, -clang-analyzer-cplusplus*' It first sets diagnostic and analyzer options, disable all options, and enables analyzer option…
John Yoon
  • 11
  • 1