blob: 29f389a5eac2e8a600d9c2779120d583beee899e [file] [log] [blame]
Artem Dergachevba816322016-07-26 18:13:12 +00001// RUN: %clang_cc1 -analyze -std=c++11 -analyzer-checker=alpha.clone.CloneChecker -verify %s
2
3// This tests if we search for clones in functions.
4
5void log();
6
7int max(int a, int b) { // expected-warning{{Detected code clone.}}
8 log();
9 if (a > b)
10 return a;
11 return b;
12}
13
14int maxClone(int x, int y) { // expected-note{{Related code clone is here.}}
15 log();
16 if (x > y)
17 return x;
18 return y;
19}
20
21// Functions below are not clones and should not be reported.
22
23int foo(int a, int b) { // no-warning
24 return a + b;
25}