summaryrefslogtreecommitdiffstats
path: root/clang/test/Analysis/copypaste/functions.cpp
blob: 29f389a5eac2e8a600d9c2779120d583beee899e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
// RUN: %clang_cc1 -analyze -std=c++11 -analyzer-checker=alpha.clone.CloneChecker -verify %s

// This tests if we search for clones in functions.

void log();

int max(int a, int b) { // expected-warning{{Detected code clone.}}
  log();
  if (a > b)
    return a;
  return b;
}

int maxClone(int x, int y) { // expected-note{{Related code clone is here.}}
  log();
  if (x > y)
    return x;
  return y;
}

// Functions below are not clones and should not be reported.

int foo(int a, int b) { // no-warning
  return a + b;
}
OpenPOWER on IntegriCloud