63 lines · c
1// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fsanitize=signed-integer-overflow,unsigned-integer-overflow -fsanitize-undefined-ignore-overflow-pattern=all %s -emit-llvm -o - | FileCheck %s2// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fsanitize=signed-integer-overflow,unsigned-integer-overflow -fsanitize-undefined-ignore-overflow-pattern=all -fwrapv %s -emit-llvm -o - | FileCheck %s3 4// Check for potential false positives from patterns that _almost_ match classic overflow-dependent or overflow-prone code patterns5extern unsigned a, b, c;6 7extern unsigned some(void);8 9// Make sure all these still have handler paths, we shouldn't be excluding10// instrumentation of any "near" patterns.11// CHECK-LABEL: close_but_not_quite12void close_but_not_quite(void) {13 // CHECK: br i1{{.*}}handler.14 if (a + b > a)15 c = 9;16 17 // CHECK: br i1{{.*}}handler.18 if (a - b < a)19 c = 9;20 21 // CHECK: br i1{{.*}}handler.22 if (a + b < a)23 c = 9;24 25 // CHECK: br i1{{.*}}handler.26 if (a + b + 1 < a)27 c = 9;28 29 // CHECK: br i1{{.*}}handler.30 // CHECK: br i1{{.*}}handler.31 if (a + b < a + 1)32 c = 9;33 34 // CHECK: br i1{{.*}}handler.35 if (b >= a + b)36 c = 9;37 38 // CHECK: br i1{{.*}}handler.39 if (a + a < a)40 c = 9;41 42 // CHECK: br i1{{.*}}handler.43 if (a + b == a)44 c = 9;45 46 // CHECK: br i1{{.*}}handler47 while (--a)48 some();49}50 51// CHECK-LABEL: function_calls52void function_calls(void) {53 // CHECK: br i1{{.*}}handler54 if (some() + b < some())55 c = 9;56}57 58// CHECK-LABEL: not_quite_a_negated_unsigned_const59void not_quite_a_negated_unsigned_const(void) {60 // CHECK: br i1{{.*}}handler61 a = -b;62}63