Skip to main content
Filter by
Sorted by
Tagged with
Advice
0 votes
1 replies
12 views

I'm currently writing a clang-tidy check for a particular monadic replacement for c++. Think of it something like, for particular types and notations, f(x) becomes x(f) - this, of course, requires an ...
lorro's user avatar
  • 10.9k
Tooling
1 vote
9 replies
133 views

I have inherited a project with over 8000 C source files from 26 years ago, so they have all kinds of old cruft that modern compilers (and best practices) won't put up with (old-style function ...
John Hascall's user avatar
  • 9,444
Tooling
0 votes
5 replies
96 views

I want to develop a tool that helps in transforming a code like this: #ifdef MYLIB_ENABLE_DEPRECATED_CODE ... some deprecated code ... #endif into: #ifdef MYLIB_ENABLE_DEPRECATED_CODE ...
Hari's user avatar
  • 1,985
3 votes
1 answer
66 views

I'm using a CMake project in combination with Conan package manager. Building my project works fine, but I'm currently struggling with Clang-tidy. I'm having this very simple file fmt_dummy.cpp: #...
Julian H's user avatar
-3 votes
1 answer
78 views

I'm trying QT Creator's Clang-Tidy interface. The documentation suggests I'll see something usable and aesthetically appealing, like this: The reality is a vomit of command-line output, like this: ...
John Perry's user avatar
  • 2,722
1 vote
2 answers
220 views

Consider the following example: struct DefaultSettings { std::string tcpIpAddress = "127.0.0.1"; uint16_t tcpPort = 1993; // Marked as magic number! } clang-tidy (with readability-magic-...
boris blokland's user avatar
1 vote
1 answer
347 views

I'm using spdlog with fmt::format_string to log messages, and I also want to capture the call location using std::source_location. My goal is to have a simple logging function like this: Logger::Error(...
ATOM's user avatar
  • 59
2 votes
1 answer
97 views

Can (and maybe should) my coroutine promise class MyCoroutine::Promise have static or non-static initial_suspend and final_suspend methods? static std::suspend_always initial_suspend() noexcept { ...
Jens's user avatar
  • 479
0 votes
0 answers
103 views

Not exactly sure how to title this nicely. I've got a large CMake project that is targeting the MSVC compiler with Ninja build files. I'd like to integrate Clang-Tidy to analyze our code but am ...
Derek C.'s user avatar
  • 1,026
1 vote
0 answers
88 views

Running clang-tidy v19 on Ubuntu 24.04 $ clang-tidy-19 --version Ubuntu LLVM version 19.1.7 The code is for Arduino, so there is: #include "Arduino.h" That generates 3 clang-tidy warnings: ...
JohnA's user avatar
  • 899
1 vote
1 answer
99 views

Running clang-tidy v19 on Ubuntu 24.04 $ clang-tidy-19 --version Ubuntu LLVM version 19.1.7 Generated a compile_commands.json: has 2 entries in it: [ { "arguments": [ "/usr/...
JohnA's user avatar
  • 899
4 votes
1 answer
101 views

clang-tidy reports the following piece of code as bugprone-use-after-move template <typename F, typename Tuple, size_t... I> auto transform_tuple_impl(F&& f, Tuple&& tuple, std::...
Stégosaure's user avatar
2 votes
1 answer
166 views

Consider the following code: #include <string> auto f1(auto&& v) { return v; } auto f2(auto&& v) { return std::forward<decltype(v)>(v); } int main() { return ...
xmllmx's user avatar
  • 44.6k
1 vote
1 answer
221 views

I did a static_assert to make sure that a valid type was used. I don't know if I just should have checked if the type is void, or whether any type can have size zero (I think it can with [[...
Zebrafish's user avatar
  • 16.3k
0 votes
0 answers
86 views

Here is my .clang-tidy: Checks: > clang-analyzer-*, bugprone-*, cppcoreguidelines-*, misc-*, performance-*, portability-*, cert-*, -fuchsia-*, -llvm-header-guard, -hicpp-*, -...
Venelin's user avatar
  • 3,344
4 votes
2 answers
235 views

We are using clang-tidy to do static analysis, and we've enabled cpp-core-guidelines. As per previous advice (by one of the authors of cpp-core-guidelines), we have a abstract base class with a ...
Werner Erasmus's user avatar
1 vote
1 answer
63 views

I am writing a module of clang-tidy, which finds declarations of variables with the necessary condition and perform FixItHint:CreateReplacement() for them. I found VarDecl, which defined via a strange ...
Umrikhin Vasiliy's user avatar
-1 votes
2 answers
84 views

I have a .clang-tidy file which includes CheckOptions: - { key: readability-identifier-naming.ClassMethodCase, value: CamelCase } - { key: readability-identifier-naming.FunctionCase, value: ...
jjcasmar's user avatar
  • 1,757
2 votes
1 answer
235 views

Consider the following program: #include <array> int main() { throw std::logic_error("hi"); } With some C++ compilers (or rather, standard libraries) - this compiles. For example,...
einpoklum's user avatar
  • 137k
2 votes
0 answers
348 views

I'm trying to remove all clang-tidy warnings in my C++ project. But I get alternating modernize-deprecated-headers and misc-include-cleaner warnings. For example: I use open_memstream in a file, so I ...
DeZe's user avatar
  • 23
0 votes
0 answers
55 views

I'm using Trunk in VS Code to run clang-tidy as a linter for my C++ project. When I run: trunk check I can see clang-tidy running in the output, and it does find issues: ... ... ... 10:2 medium ...
Itay Shalev's user avatar
2 votes
0 answers
127 views

I have a VS solution with multiple projects. The code is written in C. I am using Visual Studio 17.12.4 Enterprise. When I run the Code Analysis within VS, the analysis is successful on all ...
Christopher Gillam's user avatar
3 votes
2 answers
104 views

I have code using container_of macros to get parent structure pointer from inner structure pointer. However, it triggers the clang-tidy security.ArrayBound warning. For instance the following code #...
shodanex's user avatar
  • 15.5k
2 votes
1 answer
483 views

I'm using clang-tidy version 17 to enforce the usage of "m_" prefix on class members (regardless of public/private/protected) but not on structs. Only adding readability-identifier-naming....
Jorge's user avatar
  • 37
0 votes
1 answer
93 views

My IDE is running clang-tidy (v20) on my C++ code. I have an enum where one of the identifiers is isnt_owning. And - clang tidy complains about the typo. <sarcasm>Thanks a bunch! I'll go right ...
einpoklum's user avatar
  • 137k
1 vote
0 answers
124 views

I am writing a test that checks whether a variable already exists in the same scope. There should be a warning if there is already a similar variable in the same scope. For example, an error should be ...
sophie's user avatar
  • 11
1 vote
0 answers
81 views

I've got the below piece of code that causes a warning with clang-tidy. void process(const std::vector<uint8_t> &buffer) { // ... process the message ... } void process(std::vector<...
Caglayan Dokme's user avatar
2 votes
1 answer
72 views

Background The built-in C++ types don't have defined sizes (just a minimum size), so we require all integer types to use explicitly-defined typedefs so the size is the same across all platforms, ...
Chris's user avatar
  • 516
1 vote
1 answer
90 views

I would like to use Clang-Tidy to lint my Cmake QT project, which I develop in QTCreator. It is a C++ project that uses Pybind11 to interface with Python code. Unfortunately, running Clang-tidy from ...
Tyler Shellberg's user avatar
0 votes
1 answer
1k views

I want to use clang-tidy in VsCode to establish a consistent coding style. The project does not use Cmake and I am currently not feeding compiler-options to clang-tidy. I am running into problems ...
user44791's user avatar
5 votes
2 answers
487 views

When I have a C++ lambda that captures an object by value, and that object can throw an exception in its copy constructor, clang-tidy will show a warning: warning: an exception may be thrown in ...
oliver's user avatar
  • 6,890
0 votes
2 answers
231 views

While trying to create a socket connection to my port I encounter the following warning from CLion Clang-Tidy: Uninitialized record type: 'server_address' Here is my code: #include <iostream> #...
march's user avatar
  • 5
0 votes
0 answers
402 views

I'm trying to use clang-tidy with readability-identifier-naming fix to change the naming style in a small project, i.e. I want to rename multiple symbols across multiple files. For some reason clang-...
w128's user avatar
  • 4,978
1 vote
1 answer
480 views

I have some legacy code that reads like this: bool has_attribute(int kvidx) const { void* v = nullptr; int flag = 0; MPI_Comm_get_attr(impl_, kvidx, &v, &flag); return flag != ...
alfC's user avatar
  • 16.8k
3 votes
1 answer
107 views

I would like to write a clang-tidy check that finds field declarations with copy initialization (ICIS_CopyInit) and can change them into direct list initializations (ICIS_ListInit). There is a way to ...
Benjamin Bihler's user avatar
1 vote
1 answer
91 views

I would like to know whether my C++ method is public, protected or private when writing a clang-tidy check. That seems to be a very simple task. But I could not figure out how to solve this, as clang::...
Benjamin Bihler's user avatar
1 vote
1 answer
890 views

I would like to use the misc-include-cleaner check from clang-tidy in my codebase, but unfortunately, the <windows.h> header used throughout WinAPI conflicts with IWYU philosophy. Technically, I ...
Pavel T.'s user avatar
1 vote
1 answer
341 views

I'm writing (my first) clang-tidy check. It should detect when macros define types, like: #define MY_INT int #define MY_STRING std::string class MyClass {} #define MY_CLASS MyClass #define ...
dif's user avatar
  • 2,503
2 votes
1 answer
76 views

I would like to write a clang-tidy check that adds an lvalue ref qualifier to certain C++ methods. I have managed to detect the methods to fix, but I have troubles finding the right source location to ...
Benjamin Bihler's user avatar
1 vote
0 answers
211 views

Currently we are integrating clang-tidy into our project and we found that it has troubles when we introduce interfaces to classes (in multiple files). Consider following code //driver_interface.hpp ...
Zdeno Pavlik's user avatar
0 votes
1 answer
86 views

my C++ code has calls to classes such as std::ifstream to open a file for reading or std::filesystem methods that iterate over directories or check if a file exists - I intend to abstract these away ...
lielb's user avatar
  • 41
0 votes
2 answers
186 views

I have an STM32 project which is compiled using CMake and generates a compile_commands.json STM32CubeMX generates an assembly file (i.e. startup_stm32f103xb.s) and adds it to the compilation database. ...
foxygentleman's user avatar
0 votes
0 answers
72 views

When ever I include windows.h when writing C, the analyzer would give me a thousand errors , I could just simply ignore them but the problem is that it won't detect any problem in the code I write I ...
abdelrahman Mohamed's user avatar
1 vote
0 answers
334 views

I'm trying to create an azure pipeline to run clang-tidy to check my Qt code. The file: trigger: - development pool: vmImage: 'ubuntu-latest' jobs: - job: Lint displayName: 'Lint C++ code with ...
Mart's user avatar
  • 544
2 votes
2 answers
344 views

I wanted to know if there is any compiler option or clang-tidy checks for this situation: #include<iostream> #include <ostream> int glob = 12; int& test(int d){ std::cout <<...
Ahmad Mansoori's user avatar
0 votes
1 answer
480 views

I'm using clang-tidy in my C++ project, and I'm encountering errors related to third-party dependencies, specifically Abseil (absl). I want to skip checking these dependencies. jiawei@DESKTOP-AEQS7B5:~...
Jiawei Lu's user avatar
  • 577
0 votes
1 answer
86 views

In my Memory.hpp file, I have a namespace boolean named isMHinit: namespace Memory { static bool isMHInit = false; DWORD HookFunction(LPVOID pTarget, LPVOID pDetour, LPVOID pTrampoline, BOOL ...
Surasia's user avatar
  • 27
1 vote
0 answers
144 views

I have this CMakeLists.txt: # ... find_program(CLANG_TIDY_EXE NAMES "clang-tidy") set(CLANG_TIDY_COMMAND "${CLANG_TIDY_EXE}") macro(target_enable_clang_tidy TARGET) ...
Gashmob's user avatar
  • 135
1 vote
1 answer
173 views

I try to match all expressions that call to std::sort, so I wrote code like this Unfortunately, the check function of this class is not called. I also tried AddMatcher code like this: but it still ...
Yun Zuo's user avatar
  • 11
0 votes
0 answers
53 views

I have this class constructor struct CosseratRodPrecomputation { CosseratRodPrecomputation(Scalar L0, const Vec3 &xA_, const Vec3 &...
jjcasmar's user avatar
  • 1,757

1
2 3 4 5
10