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.
Provided the following code, in the global scope, clang-tidy gives no warning:
auto test = []{};
However, when doing the following, it does:
#include
auto test = []{
std::tuple t{1, 2, 3};
};
:3:6: warning: initialization of…
I have this cmake project that I would like to modernize using clang-tidy. In order not to have too many things happening at once, I only activated the modernize-use-override option. However, when I apply this:
$> run-clang-tidy -header-filter='.*'…
I have code like the following
int do_thing( int arg1, int arg2, int arg3 ) { // NOLINT : don't care that arg2 and arg3 aren't used
return arg1;
}
the NOLINT comment suppresses a clang-tidy warning normally. However, how can I 'reenable'…
Several static analysis tools designed for C/C++ exist, but they are not particularly useful for testing CUDA sources.
Since clang version 6 is able to compile CUDA, I wanted to check what are my options with using clang-tidy, which does not seem to…
I have a build which uses clang-tidy through cmake:
set_target_properties(project
PROPERTIES
...
CXX_CLANG_TIDY
"/usr/bin/clang-tidy"
"-checks=modernize-*,readability-*,performance-*"
"-fix"
)
While building it I…
CLion (2023.1.2) is running clang-tidy v17 on a project of mine. It's complaining about me passing an std::experimental::optional (from C++14) by value instead of by reference. That seems egregious to me... how can I increase the "object weight…
struct Thing {
std::string something;
};
Clang-tidy complains:
warning: an exception may be thrown in function 'Thing' which should not throw exceptions [bugprone-exception-escape]
I know about the…
I do not understand why Clang-Tidy produces the error Clang-Tidy: Do not implicitly decay an array into a pointer in the following example:
struct Foo {
explicit Foo(std::string _identifier) : identifier(std::move(_identifier)) {}
std::string…
Note December 2022: it seems that this problem is solved in clang-tidy 14. Just by experimentation I can reproduce the problem with clang-tidy 11, 12 and 13 but not with 14.
I have a Cmake project that uses Boost.UnitTest for testing.
When I do…
I have a simple setup where CMake produces the following compile command:
cd /workspaces/cmake-general/tests/project/build/examples/hello-world && /usr/local/bin/cmake -E __run_co_compile
--iwyu=/usr/local/bin/include-what-you-use…
I am looking for the best way to avoid cppcoreguidelines-init-variables warnings with clang-tidy.
std::istringstream in(line);
float x, y, z, rotx, roty, rotz;
in >> x >> y >> z >> rotx >> roty >> rotz;
-> variable 'x' is not initialized,…
I'm trying to implement a state pattern as explained in this example. I've gotten to code similar as below.
class State {
public:
virtual void enter() {};
virtual void update() = 0;
virtual void exit() {};
virtual void…
I want to remove/ignore a clang warning for a block of code and found multiple examples of how to use pragamas for this. For example if the warning is unused-variable you can disable it by using:
#pragma clang diagnostic push
#pragma clang…
I want to use the default configuration of enabled/disabled checks from CLion (with some small changes) and I want to enforce it when building my application.
Enforcing clang-tidy works perfectly by using the cmake directive for clang-tidy, for…
Using clang++-11 with libstdc++-11 and clang-tidy-11, I run into failures when linting the code with clang-tidy - namely parsing error when dealing with the well-known sleeper std::this_thread::sleep_for(std::chrono::seconds(1));.
clang-tidy-11…