39 lines · c
1// RUN: %clang_cc1 -triple x86_64-apple-darwin %s -emit-llvm -o - -fsanitize=unsigned-integer-overflow | FileCheck %s --check-prefix=UNSIGNED2// RUN: %clang_cc1 -triple x86_64-apple-darwin %s -emit-llvm -o - -ftrapv | FileCheck %s --check-prefix=TRAPV3// RUN: %clang_cc1 -triple x86_64-apple-darwin %s -emit-llvm -o - -fsanitize=unsigned-integer-overflow -ftrapv | FileCheck %s --check-prefix=BOTH4// Verify that -ftrapv and -fsanitize=unsigned-integer-overflow5// work together as expected6 7 8// UNSIGNED: @test_signed9// TRAPV: @test_signed10// BOTH: @test_signed11void test_signed(void) {12 extern volatile int a, b, c;13 // UNSIGNED: add nsw i3214 // UNSIGNED-NOT: overflow15 // TRAPV: sadd.with.overflow.i3216 // TRAPV-NOT: @__ubsan17 // TRAPV: llvm.ubsantrap18 // BOTH: sadd.with.overflow.i3219 // BOTH-NOT: @__ubsan20 // BOTH: llvm.ubsantrap21 a = b + c;22}23 24// UNSIGNED: @test_unsigned25// TRAPV: @test_unsigned26// BOTH: @test_unsigned27void test_unsigned(void) {28 extern volatile unsigned x, y, z;29 // UNSIGNED: uadd.with.overflow.i3230 // UNSIGNED-NOT: llvm.trap31 // UNSIGNED: ubsan32 // TRAPV-NOT: overflow33 // TRAPV-NOT: llvm.trap34 // BOTH: uadd.with.overflow.i3235 // BOTH: @__ubsan36 // BOTH-NOT: llvm.ubsantrap37 x = y + z;38}39