Trusted-CPP Documentation

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:

Building from Source

  1. Clone the repository:
    git clone https://github.com/afteri-ru/trusted-cpp.git
    cd trusted-cpp
    
  2. Create a build directory and navigate to it:
    mkdir build
    cd build
    
  3. Configure the project with CMake:
    cmake ..
    
  4. 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:

For circular reference analysis, you’ll need to run the plugin twice:

  1. First pass with --circleref-write to collect class information
  2. Second pass with --circleref-read to 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.