45 lines · cpp
1// RUN: %clang_analyze_cc1 -triple x86_64-unknown-linux -analyzer-checker=alpha.clone.CloneChecker -analyzer-config alpha.clone.CloneChecker:MinimumCloneComplexity=10 -verify %s2 3// expected-no-diagnostics4 5int foo1(int src) {6 int dst = src;7 if (src < 100 && src > 0) {8 9 asm ("mov %1, %0\n\t"10 "add $1, %0"11 : "=r" (dst)12 : "r" (src));13 14 }15 return dst;16}17 18// Identical to foo1 except that it adds two instead of one, so it's no clone.19int foo2(int src) {20 int dst = src;21 if (src < 100 && src > 0) {22 23 asm ("mov %1, %0\n\t"24 "add $2, %0"25 : "=r" (dst)26 : "r" (src));27 28 }29 return dst;30}31 32// Identical to foo1 except that its a volatile asm statement, so it's no clone.33int foo3(int src) {34 int dst = src;35 if (src < 100 && src > 0) {36 37 asm volatile ("mov %1, %0\n\t"38 "add $1, %0"39 : "=r" (dst)40 : "r" (src));41 42 }43 return dst;44}45