[analyzer] Add basic capabilities to detect source code clones.
authorArtem Dergachev <artem.dergachev@gmail.com>
Tue, 26 Jul 2016 18:13:12 +0000 (18:13 +0000)
committerArtem Dergachev <artem.dergachev@gmail.com>
Tue, 26 Jul 2016 18:13:12 +0000 (18:13 +0000)
commitba816326f336beddd19e59067577d4bf0e592efa
tree9e13de8ed65e90063ff73d8c538f225a2655646b
parentf8df4d111758ef0939e7c10773cfeb6adc872618
[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

llvm-svn: 276782
clang/include/clang/Analysis/CloneDetection.h [new file with mode: 0644]
clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
clang/lib/Analysis/CMakeLists.txt
clang/lib/Analysis/CloneDetection.cpp [new file with mode: 0644]
clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt
clang/lib/StaticAnalyzer/Checkers/CloneChecker.cpp [new file with mode: 0644]
clang/test/Analysis/copypaste/blocks.cpp [new file with mode: 0644]
clang/test/Analysis/copypaste/false-positives.cpp [new file with mode: 0644]
clang/test/Analysis/copypaste/functions.cpp [new file with mode: 0644]
clang/test/Analysis/copypaste/objc-methods.m [new file with mode: 0644]
clang/test/Analysis/copypaste/sub-sequences.cpp [new file with mode: 0644]