52 lines · cpp
1// RUN: %clang_analyze_cc1 -std=gnu++11 -analyzer-checker=alpha.clone.CloneChecker -analyzer-config alpha.clone.CloneChecker:MinimumCloneComplexity=10 -verify %s2 3// expected-no-diagnostics4 5 6bool foo1(int x) {7 start:8 if (x != 3) {9 ++x;10 void *ptr = &&start;11 goto start;12 }13 end:14 return false;15}16 17// Targeting a different label with the address-of-label operator.18bool foo2(int x) {19 start:20 if (x != 3) {21 ++x;22 void *ptr = &&end;23 goto start;24 }25 end:26 return false;27}28 29// Different target label in goto30bool foo3(int x) {31 start:32 if (x != 3) {33 ++x;34 void *ptr = &&start;35 goto end;36 }37 end:38 return false;39}40 41// FIXME: Can't detect same algorithm as in foo1 but with different label names.42bool foo4(int x) {43 foo:44 if (x != 3) {45 ++x;46 void *ptr = &&foo;47 goto foo;48 }49 end:50 return false;51}52