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

How to use clang-tidy with Visual Studio and CMake?

My ultimate goal is to do a one-off automated modernization of some code and apply our identifier capitalization rules that are expressed in .clang-tidy. Being able to repeat this over time would be nice. We use Visual Studio 2015, CMake 3.13, and…
All The Rage
  • 743
  • 5
  • 24
3
votes
0 answers

clang-tidy: What is the check to detect memory leak due to missing free before throw?

Is there a check / configuration to detect memory leak due to missing free before throw as in following code using clang-tidy? Clang detects if free is missing before end of the block / function ASN_STRUCT_FREE(asn_DEF_ConnectionResponse,…
harsha
  • 933
  • 1
  • 12
  • 26
3
votes
1 answer

How to add -fix option to .clang-tidy file?

Checks: 'modernize-use-auto, modernize-use-nullptr, modernize-loop-convert' CheckOptions: - key: modernize-loop-convert.MinConfidence value: safe I have a configration file like this and want to add -fix flag to apply…
user4640261
3
votes
1 answer

Is there a static code checker for C that would flag a missing mutex unlock?

In the code below, two threads are working with the same function and each thread is supposed to acquire the lock before starting. So the first thread gets the lock, does the job, and leaves, but without releasing the lock, since the unlock command…
Branex
  • 362
  • 1
  • 6
  • 14
3
votes
1 answer

C++98, but clang-tidy says use nullptr?

I am using Clion and my project is set to C++98, but clang-tidy has suggestions to use nullptr instead of NULL. Is there a clang-tidy setting somewhere in the IDE or is it something else?
Mode77
  • 991
  • 8
  • 28
3
votes
1 answer

LLVM on MacOs - unknown type name 'template' in standard file iosfwd

I installed LLVM on MacOS 10.13 using homebrew: brew install --with-toolchain llvm Then I exported required variables, based on this guide. export PATH="/usr/local/opt/llvm/bin:$PATH" export CC=/usr/local/opt/llvm/bin/clang export…
Fedorov7890
  • 1,173
  • 13
  • 28
3
votes
1 answer

Use clang-tidy to output issues with formatting

Is it possible to set up clang-tidy to output issues it has found with the formatting of the source code as defined by the .clang-format file. Basically, telling you what kind of changes clang-format would do if it ran on the file. Something along…
3
votes
2 answers

clang-tidy ignores readability-identifier-naming on Windows

I want to use clang-tidy to enforce the style guidelines of my company. I'm working on Windows 10. I've installed LLVM v6.0.1. Here's my test file: class foo_bar { public: foo_bar() = default; private: int bar_; }; And here's the command line…
Cyril
  • 559
  • 5
  • 17
3
votes
0 answers

Clang-tidy false positive with boost::variant

When running clang-tidy on this minimal example posted below I get the (imho) false positive error from clang-tidy (full error trace at the end) Value assigned to field 'id' in implicit constructor is garbage or undefined…
user823255
  • 980
  • 9
  • 19
3
votes
0 answers

Why clang-tidy's deadcode.DeadStores raises warning in case of RAII with reference_wrapper usage?

Code snippet: #include #include class OnExit { public: explicit OnExit(const std::function& f):f_(f){} ~OnExit(){f_();} private: std::function f_; }; void finish(const bool& details) { …
rafal_rr
  • 31
  • 1
3
votes
1 answer

C++ using clang-tidy with external libraries

I'm first time user of clang-tidy. I am working on my thesis using OpenCV. My issue is that when I configure clang-tidy to "Fix" the issues it finds, it will fix the issue it finds in the OpenCV library as well. My question is: how can I make it so…
Marius T
  • 783
  • 5
  • 10
3
votes
1 answer

suppress clang-tidy -Wdocumentation "empty paragraph" errors

I can't seem to find where I might be able to suppress these specific errors or why they are even registering in the first place. error: empty paragraph passed to '@param' command Here is the documentation that I have that is generating this…
Maggie S.
  • 1,076
  • 4
  • 20
  • 30
3
votes
1 answer

clang-tidy: Analyze file with multiple errors

Is it possible to analyze a C/C++ file in clang-tidy, while ignoring its syntax/compilation errors? I have a very big file that has several compilation errors, but I still want to analyze it with clang-tidy. I'm getting the following error…
3
votes
1 answer

Is there a pre-made clang-tidy clion configuration for C++03?

CLion has a nice integration of Clang-Tidy, but the default configuration is targeted to modern C++. The compiler I'm stuck with however is C++03 only and all the advices of Clang-Tidy on modernizing my code just continue to rub in the fact that my…
pesche
  • 3,054
  • 4
  • 34
  • 35
3
votes
2 answers

Evaluate return value from ninja clang-tidy using CMake in batch

I am using CMake 3.6 to generate a ninja 1.6.0 configuration, compile and statically analyze my code using clang-tidy (LLVM version 3.9.1): # file copied from…
Mihai Galos
  • 1,707
  • 1
  • 19
  • 38