LogoLogo
Open TrustInSoft CI
  • Overview
  • Introduction tutorial
    • Prepare the demo project
    • Set up the continuous analysis
    • Find the root cause of the undefined behavior
    • Prove the absence of undefined behaviors
    • Go beyond your test suite
  • C++ tutorial
    • Prerequisites
    • Identifiers, constructors and calling conventions
    • Learn more
  • Configuration files
    • Build preparation stage
    • Analyses configuration
    • Tips: Switching from a Global configuration to a Committed configuration
    • Tips: Generalize analyses for several architectures
    • Tips: Factorize options between several analyses
  • Get help
  • Changelog
  • Glossary
  • FAQ
  • REFERENCE
    • Supported architectures
    • Add a status badge
    • GitHub organizations
    • CWE coverage
Powered by GitBook
On this page
  • Introduction to Cxx_matrix
  • Launching the analyzer
  1. C++ tutorial

Prerequisites

PreviousC++ tutorialNextIdentifiers, constructors and calling conventions

Last updated 3 years ago

Introduction to Cxx_matrix

The tutorial is based on the C++ project .

Its source code on GitHub contains 2 source files:

  • matrix.h that is a matrix operations library coded in C++

  • matrix.cpp that is a simple test over this library

Let's familiarize ourselves with the main function in matrix.cpp:

int
main(void) {
    Matrix<2U, 2U> matrix_a {
        2., 1.,
        4., 2. };

    auto id = identity<2>();
    bool has_inverse = is_invertible(id);
    std::cout << "identity is inversible: " << (has_inverse ? "yes\n" : "no\n");

    Matrix<2U, 2U> matrix_b = matrix_a + (5 ^ id);
    Matrix<2, 1> res = solve(matrix_b,  { 6., 10. });
    std::cout << "RESULT IS:\n" << res;

    return 0;
    (void) has_inverse;
}

The test implemented in main performs the following step:

  • It initializes a 2 x 2 matrix

  • It verifies if the matrix is invertible

  • It performs some basic operations on this matrix

  • It solves a matrix equation

Launching the analyzer

We also launched the analysis in TrustInSoft CI:

There is only one analysis, as one entry point, and no undefined behavior on the tested path:

2. Launch TrustInSoft CI Analyzer by clicking the #1 analysis and then on the Inspect with TrustInSoft CI Analyzer button.

Next let's dive into C++ identifiers, constructions and calling conventions in TrustInSoft CI Analyzer.

We already configured the project for TrustInSoft CI by adding a file to the repository. In our example, the specifies the source file matrix.cpp to analyze, the analysis entry point function main and the preprocessor option -I..

1. Load the following URL in your browser to visualize a summary of the analysis results:

Cxx_matrix
Cxx_matrix
.trustinsoft/config.json
Analyses configuration
https://ci.trust-in-soft.com/projects/TrustInSoft-CI/Cxx_matrix/latest