[analyzer] Add basic capabilities to detect source code clones.
This patch adds the CloneDetector class which allows searching source code for clones. For every statement or group of statements within a compound statement, CloneDetector computes a hash value, and finds clones by detecting identical hash values. This initial patch only provides a simple hashing mechanism that hashes the kind of each sub-statement. This patch also adds CloneChecker - a simple static analyzer checker that uses CloneDetector to report copy-pasted code. Patch by Raphael Isemann! Differential Revision: https://reviews.llvm.org/D20795 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@276782 91177308-0d34-0410-b5e6-96231b3b80d8
Showing
- include/clang/Analysis/CloneDetection.h 235 additions, 0 deletionsinclude/clang/Analysis/CloneDetection.h
- include/clang/StaticAnalyzer/Checkers/Checkers.td 16 additions, 0 deletionsinclude/clang/StaticAnalyzer/Checkers/Checkers.td
- lib/Analysis/CMakeLists.txt 1 addition, 0 deletionslib/Analysis/CMakeLists.txt
- lib/Analysis/CloneDetection.cpp 277 additions, 0 deletionslib/Analysis/CloneDetection.cpp
- lib/StaticAnalyzer/Checkers/CMakeLists.txt 1 addition, 0 deletionslib/StaticAnalyzer/Checkers/CMakeLists.txt
- lib/StaticAnalyzer/Checkers/CloneChecker.cpp 96 additions, 0 deletionslib/StaticAnalyzer/Checkers/CloneChecker.cpp
- test/Analysis/copypaste/blocks.cpp 19 additions, 0 deletionstest/Analysis/copypaste/blocks.cpp
- test/Analysis/copypaste/false-positives.cpp 29 additions, 0 deletionstest/Analysis/copypaste/false-positives.cpp
- test/Analysis/copypaste/functions.cpp 25 additions, 0 deletionstest/Analysis/copypaste/functions.cpp
- test/Analysis/copypaste/objc-methods.m 27 additions, 0 deletionstest/Analysis/copypaste/objc-methods.m
- test/Analysis/copypaste/sub-sequences.cpp 27 additions, 0 deletionstest/Analysis/copypaste/sub-sequences.cpp
Loading
Please register or sign in to comment