You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Previously, the turning on/off clang-tidy, include-what-you-use and
cppcheck was handled by a combination of an option and the use of macros
for specific details. This has meant only straightforward usage was
accomodated.
Rather, there is a desire to be more flexible, to allow for difference
code to be compiled with different options, or to turn on/off tools
altogether for specific scopes.
The options of `CLANG_TIDY`, `IWYU` and `CPPCHECK` have been removed.
Instead, it is up to the including project on when/how to enable these
tools. The ability to 'reset' the tools, to disable them for certain
scopes has been accomodated via the use of `reset_*` macros.
# Sources provided here are run with clang-tidy with the header-filter options provided to it from above
354
+
add_execuable(test1 main1.cpp)
355
+
target_sources(big_test test1.c test1.cpp)
356
+
357
+
reset_clang_tidy()
358
+
359
+
# Sources provided here are not run with clang-tidy at all
360
+
add_executable(test3 main3.cpp)
361
+
target_sources(big_test test3.c test3.cpp)
362
+
363
+
clang_tidy()
364
+
365
+
# Sources provided here are run with clang-tidy with no options
366
+
add_executable(test4 main4.cpp)
367
+
target_sources(big_test test4.c test4.cpp)
368
+
```
369
+
341
370
### clang-tidy
342
371
343
372
> clang-tidy is a clang-based C++ “linter” tool. Its purpose is to provide an extensible framework for diagnosing and fixing typical programming errors, like style violations, interface misuse, or bugs that can be deduced via static analysis. clang-tidy is modular and provides a convenient interface for writing new checks.
When detected, [clang-tidy](https://clang.llvm.org/extra/clang-tidy/) can be enabled by using the option of `-DCLANG_TIDY=ON`, as it is disabled by default.
348
-
349
-
To use, add the `clang_tidy()` function, with the arguments being the options to pass to the clang tidy program, such as '-checks=*'.
376
+
To use, add the `clang_tidy()` macro, with the arguments being the options passed to the clang-tidy call in the form of `clang-tidy ${ARGS}`. The settings used with clang-tidy can be changed by calling `clang_tidy()` macro again. It can be turned off by calling the `reset_clang_tidy()` macro.
350
377
351
378
### include-what-you-use
352
379
353
-
This tool helps to organize headers for all files encompass all items being used in that file, without accidentally relying upon headers deep down a chain of other headers. This is disabled by default, and can be enabled via have the program installed and adding `-DIWYU=ON`.
380
+
> "Include what you use" means this: for every symbol (type, function variable, or macro) that you use in foo.cc, either foo.cc or foo.h should #include a .h file that exports the declaration of that symbol. The include-what-you-use tool is a program that can be built with the clang libraries in order to analyze #includes of source files to find include-what-you-use violations, and suggest fixes for them.
381
+
>
382
+
> The main goal of include-what-you-use is to remove superfluous #includes. It does this both by figuring out what #includes are not actually needed for this file (for both .cc and .h files), and replacing #includes with forward-declares when possible.
To use, add the `include_what_you_use()`function, with the arguments being the options to pass to the program.
386
+
To use, add the `include_what_you_use()`macro, with the arguments being the options passed to the include_what_you_use call in the form of `include-what-you-use ${ARGS}`. The settings used with include-what-you-use can be changed by calling `include_what_you_use()` macro again. It can be turned off by calling the `reset_include_what_you_use()` macro.
356
387
357
388
### cppcheck
358
389
359
-
This tool is another static analyzer in the vein of clang-tidy, which focuses on having no false positives. This is by default disabled, and can be enabled via have the program installed and adding `-DCPPCHECK=ON`.
390
+
> Cppcheck is a static analysis tool for C/C++ code. It provides unique code analysis to detect bugs and focuses on detecting undefined behaviour and dangerous coding constructs. The goal is to have very few false positives. Cppcheck is designed to be able to analyze your C/C++ code even if it has non-standard syntax (common in embedded projects).
391
+
>
392
+
> [cppcheck](http://cppcheck.net/)
360
393
361
-
To use, add the `cppcheck()`function, with the arguments being the options to pass to the program.
394
+
To use, add the `cppcheck()`macro, with the arguments being the options passed to the cppcheck call in the form of `cppcheck ${ARGS}`. The settings used with iwyu can be changed by calling `cppcheck()` macro again. It can be turned off by calling the `reset_cppcheck()` macro.
0 commit comments