/testC

This repository contains file diff for legacy C code and CheckedC code. For basic programs in Arrays, Structs, Graph, Flow etc. algorti

Primary LanguageCMIT LicenseMIT

Contributors Forks Stargazers Issues MIT License LinkedIn


Analysing 3C

This project highlights the use of 3C and analyses it's usage. 3C is a tool used to automatically convert legacy C code to checked C code.
Explore the docs »

View Demo · Report Bug · Request Feature

Table of Contents
  1. About The Project
  2. Getting Started
  3. Usage
  4. Roadmap
  5. Contributing
  6. License
  7. Contact
  8. Acknowledgments

About The Project

Checked C adds static and dynamic checking to C to detect or prevent common programming errors such as buffer overruns and out-of-bounds memory accesses. The 3C (Checked-C-Convert) software facilitates conversion of existing C code to Checked C by automatically inferring as many Checked C annotations as possible and guiding the developer through the process of assigning the remaining ones. 3C aims to provide the first feasible way for organizations with large legacy C codebases (that they don't want to drop everything to rewrite in a better language) to comprehensively verify their code's spatial memory safety.

(back to top)

Getting Started

As described here, you can use either https://github.com/correctcomputation/checkedc-clang or https://github.com/microsoft/checkedc-clang (or, of course, a third-party fork, though we can't be responsible for that). Assuming you have already cloned one of these repositories, run the following (from the checkedc-clang directory or whatever you named your clone) for a basic build:

# Get a copy of the Checked C system headers. Use Microsoft's
# "checkedc" repository regardless of which "checkedc-clang"
# repository you use.
git clone https://github.com/microsoft/checkedc llvm/projects/checkedc-wrapper/checkedc

mkdir build && cd build
cmake ../llvm -G Ninja -DLLVM_ENABLE_PROJECTS=clang
ninja TARGET

where TARGET stands for the target(s) you want to build. For the 3c command-line tool, the target is 3c, but assuming you want to actually compile the Checked C source files generated by 3C, you'll also want to build clang (the Checked C compiler, which is a modified version of Clang). Executables will end up in build/bin; you'll likely want to add this directory to your $PATH or write suitable wrapper scripts.

Prerequisites

You need the clang compiled from the above section to be included in your PATH for 3c and clang to work on the checked C code.

Usage

To use this repo, go to a specific folder which consists of programs (Simple C programs) and run this command:

make original   // To compile the original Legacy C code.
make checked    // To compile the fixed 3C code (The ideal case after fixing)
make manual     // To compile the manually converted code. (The ideal case)
make just3c     // To compile the after running 3c for one pass (This might not compile for most cases due to problems in 3C)

(back to top)

Contributing

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

(back to top)

Contact

Your Name - @iamnewedia - vrajoo@purdue.edu

Project Link: https://github.com/Vedaant-Rajoo/testC

(back to top)