Skip to content

jdmitrovic/ShiftingChecker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 

Repository files navigation

ShiftingChecker

ShiftingChecker is a Clang Static Analyzer checker which checks for improper shifting: shifting by a negative value or by a value too large.

Installation

  1. Build LLVM following the instructions from the Github page. (NOTE: Over 8GiB of RAM highly recommended).
  2. Copy ShiftingChecker.cpp to the llvm-project/clang/lib/StaticAnalyzer/Checkers folder.
  3. Edit the CMakeLists.txt file in the aforementioned Checkers folder so that cmakecould recognize added ShiftingChecker.cpp file.
  4. Add following block of code into Checkers.td file contained in llvm-project/clang/include/clang/StaticAnalyzer/Checkers:
let ParentPackage = UnixAlpha in {
    ...
    def ShiftingChecker : Checker<"ShiftingChecker">,  
                          HelpText<"Check for shifting by negative value or value too large">,  
                          Documentation<NotDocumented>;  
    ...
} // end "alpha.unix" 
  1. In the build directory, run make clang. This will only rebuild Clang (you can use this command for making any subsequent changes to the checker, as well).

Usage

For applications written in C, run:

clang --analyze -Xanalyzer -analyzer-checker=unix,alpha example.c

For applications written in C++, run:

clang++ --analyze -Xanalyzer -analyzer-checker=unix,alpha example.cpp

Both clang and clang++ can be found in llvm-project/build/bin.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages