SortChecker++ is an extension of SortChecker tool
to C++ sorting APIs like std::sort
or std::binary_search
.
It verifies that comparators satisfy the Strict Weak Ordering
axioms.
We tested the tool on LLVM 6.0 (Ubuntu 18.04) and 10.0 (Ubuntu 20.04) for now.
It is currently work in progress.
To use, first install dependencies:
$ sudo apt install libclang-dev llvm-dev
Then build the tool
$ make clean all
SortChecker works by instrumenting, i.e. inserting additional checking code, into the source file. You can run it manually:
$ SortChecker file.cpp -- $CXXFLAGS
and then compile via
$ g++ file.cpp $CXXFLAGS -Ipath/to/sortcheck.h
You could also use compiler wrappers in scripts/
folder to combine instrumentation and compilation:
$ PATH=path/to/scripts:$PATH make clean all
Instrumented program may be controlled with environment variables:
SORTCHECK_VERBOSE
- verbositySORTCHECK_SYSLOG
- dump messages to syslog (in addition to stderr)SORTCHECK_ABORT_ON_ERROR
- callabort()
on detected errorSORTCHECK_EXIT_CODE
- callexit(CODE)
on detected errorSORTCHECK_OUTPUT
- write detected errors to file instead of stdoutSORTCHECK_CHECKS
- set which checks are enabled via bitmask
tbd
- apply to test packages
- integrate to old sortcheck (?)