Skip to content

Commit

Permalink
#12: update documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
cz4rs committed Feb 24, 2021
1 parent 5356eb9 commit 3a55551
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 20 deletions.
36 changes: 16 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,6 @@ docker-compose build vt-base
docker-compose pull sanitizer-base
```

- Bring images up on `docker-compose` (will build base sanitizer image if
needed):

```shell
docker-compose up
```

- Compile and build the latest sanitizer code:

```shell
Expand All @@ -64,22 +57,25 @@ docker-compose run vt-base /bin/bash

## Running

Once the `sanitizer` binary is built, it can be run on a C++ file with a JSON
compilation database so it knows how to compile the C++ file (includes, flags,
etc).
Once the `sanitizer` plugin is built, it can be run on C++ files by just
appending the sanitizer options to a regular build command (keeping all
includes, flags, etc).

```shell
# /serialization-sanitizer/sanitizer /build/vt/compile-comands.json /vt/examples/hello_world.cc
clang++ -std=gnu++14 -c tests/test-inner-class.cc \
-Xclang -load -Xclang /build/serialization-sanitizer/libsanitizer.so \
-Xclang -plugin -Xclang sanitizer
```

A compilation database can be generated for a cmake project by defining a cmake
variable for that project. Set `-DCMAKE_EXPORT_COMPILE_COMMANDS=1` while
configuring the project that is going to be sanitized. When that variable is
set, the JSON compilation database will be generated in the cmake build
directory with the file name `compile_commands.json`.
This would normally be added to a target in `CMakeLists.txt`.

### Command template
```shell
./sanitizer -p <json-compilation-database> <cc-file> -extra-arg=-std=c++1y
### Plugin options

```
These can be added with: `-Xclang -plugin-arg-sanitizer -Xclang -option`.

| Flag | Description |
| -------------- | ------------------------------------- |
| -include-input | output input file with generated code |
| -o | filename to output generated code |
| -inline | generate code inline and modify files |
| -Ivt | include VT headers in generated code |
7 changes: 7 additions & 0 deletions src/plugin/plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,13 @@

namespace plugin {

/**
* \struct SanitizerMatcher
*
* \brief Checks if all fields are serialized in a matched `serialize` function.
*
* \note This is a compile time, static check.
*/
struct SanitizerMatcher : public clang::ast_matchers::MatchFinder::MatchCallback {
void run(clang::ast_matchers::MatchFinder::MatchResult const&) override;
};
Expand Down

0 comments on commit 3a55551

Please sign in to comment.