Installation Guide
This guide will help you install and set up Trusted-CPP on your system.
Prerequisites
Before installing Trusted-CPP, ensure you have the following:
- A C++ compiler that supports C++20 (clang++ 20 or above recommended)
- CMake 3.12 or higher
- Git (for cloning the repository)
Building from Source
- Clone the repository:
git clone https://github.com/afteri-ru/trusted-cpp.git cd trusted-cpp - Create a build directory and navigate to it:
mkdir build cd build - Configure the project with CMake:
cmake .. - Build the project:
make
This will build both the Clang plugin (trusted-cpp_clang.so) and the test executable.
Using the Plugin
After building, you can use the plugin with clang++ to analyze your C++ code:
clang++ -std=c++20 -Xclang -load -Xclang ./trusted-cpp_clang.so -Xclang -add-plugin -Xclang trust -Xclang -plugin-arg-trust -Xclang circleref-disable your_file.cpp
Replace your_file.cpp with the path to your C++ source file.
Plugin Options
The plugin supports several command-line arguments:
--circleref-disable: Disable circular reference analysis (default)--circleref-write: Write class information for circular reference analysis (first pass)--circleref-read: Read class information for circular reference analysis (second pass)
For circular reference analysis, you’ll need to run the plugin twice:
- First pass with
--circleref-writeto collect class information - Second pass with
--circleref-readto perform the analysis
Example for circular reference analysis:
# First pass
clang++ -std=c++20 -Xclang -load -Xclang ./trusted-cpp_clang.so -Xclang -add-plugin -Xclang trust -Xclang -plugin-arg-trust -Xclang circleref-write -fsyntax-only your_file.cpp
# Second pass
clang++ -std=c++20 -Xclang -load -Xclang ./trusted-cpp_clang.so -Xclang -add-plugin -Xclang trust -Xclang -plugin-arg-trust -Xclang circleref-read your_file.cpp
Using the Library
Include the trust.h header in your C++ files to use the library features:
#include "trust.h"
// Your code here
The header-only library provides enhanced smart pointer types and thread safety mechanisms.
Running Tests
To run the tests, build the test executable and run it:
./trusted-cpp_test
This will execute all the unit tests for the Trusted-CPP library and plugin.