Manual checks

Tests that cannot be automatized should occasionally be run manually.

Unused code

Unused code, in particular unused functions, can be detected with the tool xunused.

cd build
cmake .. -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
emacs compile_commands.json # rm source files in 3rdparty and Fit/3rdparty
xunused compile_commands.json 2>&1 >/dev/null | tee /io/unused.txt

Use judgement: not all currently unused functions must be removed.

Static code analysis with clang-tidy

cd debug
cmake .. -GNinja -DCMAKE_BUILD_TYPE=Debug -BA_TIDY=ON -DBORNAGAIN_PYTHON=OFF
ninja

Coverage

Address Sanitizer (ASan)

Experimental (jul25)

cd debug
cmake .. -GNinja -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DBA_SANITIZER=ON
export ASAN_OPTIONS=detect_leaks=1:detect_stack_use_after_return=1:detect_container_overflow=1:malloc_context_size=20:check_initialization_order=1:symbolize=1
LD_PRELOAD=/usr/lib/llvm-19/lib/clang/19/lib/linux/libclang_rt.asan-x86_64.so ASAN_OPTIONS=abort_on_error=1:fast_unwind_on_malloc=0 gdb bin/bornagain

Valgrind

Valgrind is incompatible with Address Sanitizer.

Compile with debug symbols, then

valgrind --leak-check=full --show-leak-kinds=definite,indirect --track-origins=yes --suppressions=/usr/libexec/valgrind/default.supp  --error-limit=no bin/bornagain