clang-tidy

What is the correct way of providing header-filter for clang-tidy in Cmake?

纵然是瞬间 提交于 2020-04-16 05:48:11
问题 I have projects that sets Clang-tidy configuration as following set(CMAKE_CXX_CLANG_TIDY "clang-tidy;-checks=google-*,cppcoreguidelines-*;") However, I have noticed that it was checking all the files that are not even in the current repo like /opt/ros/melodic/include/ros/console.h and all the .h/.hpp files of submodules... I tried to add a regex to filter the target .h files but couldn't get it working... I have given absolute path for a single .hpp file but it was still evaluating /opt/ros

Exclude specific headers from clang-tidy

大兔子大兔子 提交于 2020-01-04 02:04:27
问题 I have several projects with many headers that I want to parse, but there are several headers which I do not want to parse with clang-tidy My folder hierarchy is as follows A\ B\ C\ coco.h D\ E\ My projects are inside C and D folders and I want them to parse all headers under B so my solution was HeaderFilterRegex: 'B/*' There are many headers that i want to include so I can't name each one. however inside C and D folders there are several headers which I would like to exclude (for example

clang-tidy header guard style warning

久未见 提交于 2019-12-31 03:11:56
问题 I want to use clang-tidy (LLVM v7.0.0) with the llvm-header-guard on Windows 10 with CMake for following header file #ifndef _BAR_H_ #define _BAR_H_ namespace FOO { namespace BAR { class BarC { public: BarC() = default; ~BarC() = default; BarC(const BarC &iValue) = delete; const BarC &operator=(const BarC &iValue) = delete; BarC(BarC &&iValue) = delete; BarC &operator=(BarC &&iValue) = delete; }; } // namespace BAR } // namespace FOO #endif // _BAR_H_ where the ROOT is C:\User\Zlatan\Project

Which clang-tidy checks provide automated fixes?

被刻印的时光 ゝ 提交于 2019-12-22 08:20:02
问题 I'd like to find out which of the clang-tidy checks are possible to run with the -fix option, i.e. automatically generate fixed code. I know all the modernize-* checks can do this and some other checks can too (like google-readability-casting) but nowhere did I find a complete list. Is there a list somewhere? Or a method to find out other than reading the source of each and every check? 回答1: grep --include=\*.cpp -rc './' -e "FixItHint"|grep -v ':0$' > FixItChecks.txt I ran this grep command

Is there a way to avoid this warning from clang-tidy (fuchsia-default-arguments) while initializing a string?

蓝咒 提交于 2019-12-22 05:34:11
问题 Consider this piece of code: #include <iostream> int main () { std::string str = "not default"; std::cout << str << std::endl; return 0; } Running clang-tidy -checks=* string.cpp gives the following: 7800 warnings generated. /tmp/clang_tidy_bug/string.cpp:4:21: warning: calling a function that uses a default argument is disallowed [fuchsia-default-arguments] std::string str = "not default"; ^ /../lib64/gcc/x86_64-pc-linux-gnu/8.1.1/../../../../include/c++/8.1.1/bits/basic_string.h:509:39:

How can I enable clang-tidy's “modernize” checks?

假如想象 提交于 2019-12-21 11:33:12
问题 I just installed ClangOnWin,and I'm trying to get clang-tidy 's "modernize" checks to work. Unfortunately, clang-tidy doesn't seem to know about them: clang-tidy -list-checks foo.cpp -- | grep modernize produces no output. The "modernize" checks are listed here, but that page seems to document Clang 3.8, and the version I have installed is 3.7. However, version 3.7 is the current one listed at the LLVM Download Page. clang-tidy knows about a variety of security checks, so I think I have it

“Use of a signed integer operand with a binary bitwise operator” - when using unsigned short

痴心易碎 提交于 2019-12-11 15:19:19
问题 In the following C snippet that checks if the first two bits of a 16-bit sequence are set: bool is_pointer(unsigned short int sequence) { return (sequence >> 14) == 3; } CLion's Clang-Tidy is giving me a "Use of a signed integer operand with a binary bitwise operator" warning, and I can't understand why. Is unsigned short not unsigned enough? 回答1: The code for this check seems to care if either operand to the bitwise operator is signed. It is not sequence causing the warning, but 14 , and you

Handling “Thrown exception type is not nothrow copy constructible” Warning

丶灬走出姿态 提交于 2019-12-08 15:16:47
问题 Going back to C++ development after a 12 years hiatus. I'm using JetBrains's CLion software which is great since it provides a lot of input on possible issues on my class design. One of the warning I get in my class' constructor throw statement is: Thrown exception type is not nothrow copy constructible . Here is a code sample that generates this warning: #include <exception> #include <iostream> using std::invalid_argument; using std::string; class MyClass { public: explicit MyClass(string

cmake clang-tidy (or other script) as custom target

泪湿孤枕 提交于 2019-12-08 15:00:10
问题 I am trying to create a custom cmake target for clang-tidy, to lint my project. The source folder looks something like this: src/scripts/run-clang-tidy.py src/.clang-tidy src/... So far my plan was to copy both these files to the build directory with a custom command: add_custom_command( OUTPUT run-clang-tidy.py .clang-tidy COMMAND cp ${CMAKE_SOURCE_DIR}/scripts/run-clang-tidy.py ${CMAKE_SOURCE_DIR}/.clang-tidy ${CMAKE_CURRENT_BINARY_DIR}) I now want to call run-clang-tidy.py in the build

clang-tidy cmake exclude file from check

▼魔方 西西 提交于 2019-12-07 12:03:26
问题 I have a dependency as source in my project that I have no control over. I'm using cmake's clang-tidy integration to analyze my code, and this dependency is firing A LOT of warnings. Is there a way to tell cmake not to run clang-tidy on specific files ? I tried to add the files to the -line-filter option of clang-tidy, but this doesn't work: set_target_properties(target PROPERTIES CXX_CLANG_TIDY "${clang_tidy_loc};\ ${TIDY_CONFIG} \ -line-filter=\"[\ {\"name\":\"path/to/file.cpp\"},\ {\"name\