1*67e74705SXin Li // RUN: %clang_cc1 -triple x86_64-apple-darwin %s -emit-llvm -o - -fsanitize=unsigned-integer-overflow | FileCheck %s --check-prefix=UNSIGNED 2*67e74705SXin Li // RUN: %clang_cc1 -triple x86_64-apple-darwin %s -emit-llvm -o - -ftrapv | FileCheck %s --check-prefix=TRAPV 3*67e74705SXin Li // RUN: %clang_cc1 -triple x86_64-apple-darwin %s -emit-llvm -o - -fsanitize=unsigned-integer-overflow -ftrapv | FileCheck %s --check-prefix=BOTH 4*67e74705SXin Li // Verify that -ftrapv and -fsanitize=unsigned-integer-overflow 5*67e74705SXin Li // work together as expected 6*67e74705SXin Li 7*67e74705SXin Li 8*67e74705SXin Li // UNSIGNED: @test_signed 9*67e74705SXin Li // TRAPV: @test_signed 10*67e74705SXin Li // BOTH: @test_signed test_signed()11*67e74705SXin Livoid test_signed() { 12*67e74705SXin Li extern volatile int a, b, c; 13*67e74705SXin Li // UNSIGNED: add nsw i32 14*67e74705SXin Li // UNSIGNED-NOT: overflow 15*67e74705SXin Li // TRAPV: sadd.with.overflow.i32 16*67e74705SXin Li // TRAPV-NOT: ubsan 17*67e74705SXin Li // TRAPV: llvm.trap 18*67e74705SXin Li // BOTH: sadd.with.overflow.i32 19*67e74705SXin Li // BOTH-NOT: ubsan 20*67e74705SXin Li // BOTH: llvm.trap 21*67e74705SXin Li a = b + c; 22*67e74705SXin Li } 23*67e74705SXin Li 24*67e74705SXin Li // UNSIGNED: @test_unsigned 25*67e74705SXin Li // TRAPV: @test_unsigned 26*67e74705SXin Li // BOTH: @test_unsigned test_unsigned()27*67e74705SXin Livoid test_unsigned() { 28*67e74705SXin Li extern volatile unsigned x, y, z; 29*67e74705SXin Li // UNSIGNED: uadd.with.overflow.i32 30*67e74705SXin Li // UNSIGNED-NOT: llvm.trap 31*67e74705SXin Li // UNSIGNED: ubsan 32*67e74705SXin Li // TRAPV-NOT: overflow 33*67e74705SXin Li // TRAPV-NOT: llvm.trap 34*67e74705SXin Li // BOTH: uadd.with.overflow.i32 35*67e74705SXin Li // BOTH: ubsan 36*67e74705SXin Li // BOTH-NOT: llvm.trap 37*67e74705SXin Li x = y + z; 38*67e74705SXin Li } 39