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
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.
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.
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.
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)
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!
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
Your Name - @iamnewedia - vrajoo@purdue.edu
Project Link: https://github.com/Vedaant-Rajoo/testC