Skip to content

Commit e73bdf4

Browse files
committed
Updated documentation
1 parent 4c42d1a commit e73bdf4

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

README.md

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ This is a collection of quite useful scripts that expand the possibilities for b
88

99
Using the functions `cxx_11()`, `cxx_14()`, `cxx_17()` or `cxx_20()` this adds the appropriated flags for both unix and MSVC compilers, even for those before 3.11 with improper support.
1010

11+
These obviously force the standard to be required, and also disables compiler-specific extensions, ie `--std=gnu++11`. This helps to prevent fragmenting the code base with items not available elsewhere, adhering to the agreed C++ standards only.
12+
1113
## Sanitizer Builds `sanitizers.cmake`
1214

1315
Sanitizers are tools that perform checks during a program’s runtime and returns issues, and as such, along with unit testing, code coverage and static analysis, is another tool to add to the programmers toolbox. And of course, like the previous tools, are tragically simple to add into any project using CMake, allowing any project and developer to quickly and easily use.
@@ -42,7 +44,11 @@ These are used by declaring the `USE_SANITIZER` CMake variable as one of:
4244

4345
## Code Coverage `code-coverage.cmake`
4446

45-
Generating code coverage during a run of a program can help determine which blocks, regions, or even lines of code are being used, and for how many times.
47+
> In computer science, test coverage is a measure used to describe the degree to which the source code of a program is executed when a particular test suite runs. A program with high test coverage, measured as a percentage, has had more of its source code executed during testing, which suggests it has a lower chance of containing undetected software bugs compared to a program with low test coverage. Many different metrics can be used to calculate test coverage; some of the most basic are the percentage of program subroutines and the percentage of program statements called during execution of the test suite.
48+
>
49+
> [Wikipedia, Code Coverage](https://en.wikipedia.org/wiki/Code_coverage)
50+
51+
Code coverage is the detailing of, during the execution of a binary, which regions, functions, or lines of code are *actually* executed. This can be used in a number of ways, from figuring out areas that automated testing is lacking or not touching, to giving a user an instrumented binary to determine which areas of code are used most/least to determine which areas to focus on. Although this does come with the caveat that coverage is no guarantee of good testing, just of what code has been.
4652

4753
Coverage here is supported on both GCC and Clang. GCC requires the `lcov` program, and Clang requires `llvm-cov` and `llvm-profdata`, often provided with the llvm toolchain.
4854

@@ -120,8 +126,6 @@ target_code_coverage(theExe AUTO ALL EXCLUDE non_covered.cpp test/*) # As an exe
120126

121127
Allows for easy use of some pre-made compiler options for the major compilers.
122128

123-
### Enable All Warnings
124-
125129
Using `-DENABLE_ALL_WARNINGS=ON` will enable almost all of the warnings available for a compiler:
126130

127131
| Compiler | Options |
@@ -153,6 +157,10 @@ clang_format(${TARGET_NAME} ${ALL_CODE_FILES})
153157

154158
### clang-tidy
155159

160+
> 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.
161+
>
162+
> [clang-tidy page](https://clang.llvm.org/extra/clang-tidy/)
163+
156164
When detected, [clang-tidy](https://clang.llvm.org/extra/clang-tidy/) can be enabled by using the option of `-DCLANG_TIDY=ON`. Disabled by default.
157165

158166
### include-what-you-use

example/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,27 +11,32 @@ cxx_11()
1111

1212
enable_testing()
1313

14+
# Fails with ThreadSanitizer
1415
add_executable(tsanFail tsan_fail.cpp)
1516
target_code_coverage(tsanFail AUTO ALL)
1617
if(UNIX)
1718
target_link_libraries(tsanFail PUBLIC pthread)
1819
endif()
1920
add_test(tsan tsanFail)
2021

22+
# Fails with LeakSanitizer
2123
add_executable(lsanFail lsan_fail.c)
2224
target_code_coverage(lsanFail AUTO ALL)
2325
add_test(lsan lsanFail)
2426

27+
# Fails with AddressSanitizer
2528
if(USE_SANITIZER MATCHES "[Aa]ddress")
2629
add_executable(asanFail asan_fail.cpp)
2730
target_code_coverage(asanFail AUTO ALL)
2831
add_test(asan asanFail)
2932
endif()
3033

34+
# Fails with MemorySanitizer
3135
add_executable(msanFail msan_fail.cpp)
3236
target_code_coverage(msanFail AUTO ALL)
3337
add_test(msan msanFail)
3438

39+
# Fails with UndefinedBehaviourSanitizer
3540
add_executable(ubsanFail ubsan_fail.cpp)
3641
target_code_coverage(ubsanFail AUTO ALL)
3742
add_test(ubsan ubsanFail)

0 commit comments

Comments
 (0)