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

How to strictly target C++98 in CLion

For some reason I cannot configure CLion to only use C++98 for my project I keep getting clang-tidy for c++11 instead of c++98 (How do I set it to C++98) I do not get any red lines or compiler errors when I use syntax for C++ versions greater than…
Tim
  • 1,606
  • 2
  • 21
  • 42
1
vote
1 answer

clang tidy pro type member init resharper

I've got some code parsing json like so: QJsonParseError errors; auto doc = QJsonDocument::fromJson(myJson.toUtf8(), &errors); Resharper's clang tidy suggestions flags that QJsonParseError errors is an 'uninitialized record type' The suggested…
CaptRespect
  • 1,985
  • 1
  • 16
  • 24
1
vote
1 answer

clang-tidy check to require parentheses around compound expressions

I would like to catch cases like this: if(a == 2 && b == 3) and convert them to: if((a == 2) && (b == 3)) I didn't see anything that sounded like this here - is there a way to enable this?
David Doria
  • 9,873
  • 17
  • 85
  • 147
0
votes
1 answer

Unclear message on clang-tidy

I run clang-tidy on a folder and it shows Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well. Found compiler error(s). But it did not show additional message on the…
kstn
  • 537
  • 4
  • 14
0
votes
0 answers

Integrating Custom build of clang-tidy in CodeChecker

I successfully installed CodeChecker (https://codechecker.readthedocs.io/en/latest/#install-guide). The check and analyze commands that CodeChecker provided work on my input files. Now, my task is to integrate checkers that I want to run on the…
0
votes
0 answers

Generate Clang-tidy Report and attach to AzureDevOps pullrequest (yml pipeline)

I have to Generate a Clang-tidy scan report and attach this report to the AzureDevOps Pull request. If there is no error this pull request can be accepted before merging it into the master branch. I found nothing over the internet, any help or…
faiqali
  • 11
  • 5
0
votes
1 answer

How to specify casing for const-reference parameter with clang-tidy?

a.cpp: #include void func(const int& a, const int b, int c) { std::cout << a + b + c << std::endl; } int main() { func(1, 2, 3); return 0; } I want to specify casing for parameters a and b, but not c with clang-tidy. How to…
0
votes
1 answer

Custom check in clang-tidy not available

I wanted to add a custom check to clang-tidy so I followed the official documentation using the command clang-tidy/add_new_check.py misc passes (https://clang.llvm.org/extra/clang-tidy/Contributing.html) Check is registered in CMakeLists.txt and…
0
votes
1 answer

How to disable a check like `misc-unused-using-decls` in Visual Studio Code

I have a bunch of these warnings showing up in my C++ code. I don't want to see them. So I added the key to the list of disabled warnings. But there is no change. Visual Studio Code keeps showing me these things in the "Problems" list. How do I…
Rob N
  • 15,024
  • 17
  • 92
  • 165
0
votes
2 answers

Out of bounds check in C with clang-tidy

Why I can easily detect this trivial case of out of bounds array accessing (marked as OK), using clang-tidy, but I can't detect the one marked as KO? I understand pointer decay in C, but I would suppose that if I'm passing the array as a fixed size…
Sam
  • 27
  • 1
  • 8
0
votes
1 answer

Unable to Provide the YAML config file for Clang Taint Analysis clang-tidy and scan-build

I came accross this clang article for taint analysis: https://clang.llvm.org/docs/analyzer/user-docs/TaintAnalysisConfiguration.html#clangsa-taint-configuration-example In the article, it is mentioned that source and sink can be specified using a…
F1o0T
  • 1
  • 1
0
votes
1 answer

Getting seemingly useless "performance-inefficient-string-concatenation" warning with clang-tidy

In my C++ app I'm concatenating a few strings using the + operator as follows in a reproducible example: #include #include #include #include std::string download_file_contents(const…
BullyWiiPlaza
  • 17,329
  • 10
  • 113
  • 185
0
votes
1 answer

Is there a way to warn C++ developers when they accidentally include internal implementation headers of std library?

How to let know developers automatically that this "bits/shared_ptr.h" is internal to standard library (gcc and clang). #include // some code using std::shared_ptr The best would be to also inform should be used…
PiotrNycz
  • 23,099
  • 7
  • 66
  • 112
0
votes
0 answers

How can I debug a custom clang-tidy check which I have written in Windows Visual Studio?

I have build the LLV.sln files using the debug build(all pdb and binaries are getting created). My newly written checks are in check-clang-tools project. When I apply breakpoint in one of my checks and click on local windows debugger, it does not…
0
votes
0 answers

clang-tidy false positive: stddef.h size_t

On Windows 11 with vscode and the ESP-IDF plugin compiling with riscv32-esp-elf/esp-2022r1-11.2.0/riscv32-esp-elf/bin/riscv32-esp-elf-gcc.exe, if settings.json has "C_Cpp.codeAnalysis.clangTidy.enabled": true, then the standard libraries fail…
Reinderien
  • 11,755
  • 5
  • 49
  • 77