]> granicus.if.org Git - clang/commit
[analyzer] Teach CloneDetector to find clones that look like copy-paste errors.
authorArtem Dergachev <artem.dergachev@gmail.com>
Thu, 18 Aug 2016 12:29:41 +0000 (12:29 +0000)
committerArtem Dergachev <artem.dergachev@gmail.com>
Thu, 18 Aug 2016 12:29:41 +0000 (12:29 +0000)
commitac4644401fe7e7305aed433541d6274203a69b97
treed8e5d36b8019fcada8d21bfe83b6caf2fa6e08a7
parent9d09f35654f5b4bbbf94a97bf9156f885301d6f5
[analyzer] Teach CloneDetector to find clones that look like copy-paste errors.

The original clone checker tries to find copy-pasted code that is exactly
identical to the original code, up to minor details.

As an example, if the copy-pasted code has all references to variable 'a'
replaced with references to variable 'b', it is still considered to be
an exact clone.

The new check finds copy-pasted code in which exactly one variable seems
out of place compared to the original code, which likely indicates
a copy-paste error (a variable was forgotten to be renamed in one place).

Patch by Raphael Isemann!

Differential Revision: https://reviews.llvm.org/D23314

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@279056 91177308-0d34-0410-b5e6-96231b3b80d8
include/clang/Analysis/CloneDetection.h
lib/Analysis/CloneDetection.cpp
lib/StaticAnalyzer/Checkers/CloneChecker.cpp
test/Analysis/copypaste/suspicious-clones.cpp [new file with mode: 0644]