Clang Project

clang_source_code/test/Analysis/copypaste/catch.cpp
1// RUN: %clang_analyze_cc1 -fcxx-exceptions -std=c++1z -analyzer-checker=alpha.clone.CloneChecker -analyzer-config alpha.clone.CloneChecker:MinimumCloneComplexity=10 -verify %s
2
3// expected-no-diagnostics
4
5bool foo1(int x) {
6  if (x > 0)
7    return false;
8  else if (x < 0)
9    try { x--; } catch (int i) {}
10  return true;
11}
12
13// Uses parenthesis instead of type
14bool foo2(int x) {
15  if (x > 0)
16    return false;
17  else if (x < 0)
18    try { x--; } catch (...) {}
19  return true;
20}
21
22// Catches a different type (long instead of int)
23bool foo3(int x) {
24  if (x > 0)
25    return false;
26  else if (x < 0)
27    try { x--; } catch (long i) {}
28  return true;
29}
30